Sat, 03 Jan 2015 20:18:00 +0100
Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- |
michael@0 | 2 | * |
michael@0 | 3 | * This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /* The long avoided variant support for xpcom. */ |
michael@0 | 8 | |
michael@0 | 9 | #ifndef nsVariant_h |
michael@0 | 10 | #define nsVariant_h |
michael@0 | 11 | |
michael@0 | 12 | #include "nsIVariant.h" |
michael@0 | 13 | #include "nsStringFwd.h" |
michael@0 | 14 | #include "mozilla/Attributes.h" |
michael@0 | 15 | |
michael@0 | 16 | class nsCycleCollectionTraversalCallback; |
michael@0 | 17 | |
michael@0 | 18 | /** |
michael@0 | 19 | * Map the nsAUTF8String, nsUTF8String classes to the nsACString and |
michael@0 | 20 | * nsCString classes respectively for now. These defines need to be removed |
michael@0 | 21 | * once Jag lands his nsUTF8String implementation. |
michael@0 | 22 | */ |
michael@0 | 23 | #define nsAUTF8String nsACString |
michael@0 | 24 | #define nsUTF8String nsCString |
michael@0 | 25 | #define PromiseFlatUTF8String PromiseFlatCString |
michael@0 | 26 | |
michael@0 | 27 | /** |
michael@0 | 28 | * nsDiscriminatedUnion is a type that nsIVariant implementors *may* use |
michael@0 | 29 | * to hold underlying data. It has no methods. So, its use requires no linkage |
michael@0 | 30 | * to the xpcom module. |
michael@0 | 31 | */ |
michael@0 | 32 | |
michael@0 | 33 | struct nsDiscriminatedUnion |
michael@0 | 34 | { |
michael@0 | 35 | union { |
michael@0 | 36 | int8_t mInt8Value; |
michael@0 | 37 | int16_t mInt16Value; |
michael@0 | 38 | int32_t mInt32Value; |
michael@0 | 39 | int64_t mInt64Value; |
michael@0 | 40 | uint8_t mUint8Value; |
michael@0 | 41 | uint16_t mUint16Value; |
michael@0 | 42 | uint32_t mUint32Value; |
michael@0 | 43 | uint64_t mUint64Value; |
michael@0 | 44 | float mFloatValue; |
michael@0 | 45 | double mDoubleValue; |
michael@0 | 46 | bool mBoolValue; |
michael@0 | 47 | char mCharValue; |
michael@0 | 48 | char16_t mWCharValue; |
michael@0 | 49 | nsIID mIDValue; |
michael@0 | 50 | nsAString* mAStringValue; |
michael@0 | 51 | nsAUTF8String* mUTF8StringValue; |
michael@0 | 52 | nsACString* mCStringValue; |
michael@0 | 53 | struct { |
michael@0 | 54 | nsISupports* mInterfaceValue; |
michael@0 | 55 | nsIID mInterfaceID; |
michael@0 | 56 | } iface; |
michael@0 | 57 | struct { |
michael@0 | 58 | nsIID mArrayInterfaceID; |
michael@0 | 59 | void* mArrayValue; |
michael@0 | 60 | uint32_t mArrayCount; |
michael@0 | 61 | uint16_t mArrayType; |
michael@0 | 62 | } array; |
michael@0 | 63 | struct { |
michael@0 | 64 | char* mStringValue; |
michael@0 | 65 | uint32_t mStringLength; |
michael@0 | 66 | } str; |
michael@0 | 67 | struct { |
michael@0 | 68 | char16_t* mWStringValue; |
michael@0 | 69 | uint32_t mWStringLength; |
michael@0 | 70 | } wstr; |
michael@0 | 71 | } u; |
michael@0 | 72 | uint16_t mType; |
michael@0 | 73 | }; |
michael@0 | 74 | |
michael@0 | 75 | /** |
michael@0 | 76 | * nsVariant implements the generic variant support. The xpcom module registers |
michael@0 | 77 | * a factory (see NS_VARIANT_CONTRACTID in nsIVariant.idl) that will create |
michael@0 | 78 | * these objects. They are created 'empty' and 'writable'. |
michael@0 | 79 | * |
michael@0 | 80 | * nsIVariant users won't usually need to see this class. |
michael@0 | 81 | * |
michael@0 | 82 | * This class also has static helper methods that nsIVariant *implementors* can |
michael@0 | 83 | * use to help them do all the 'standard' nsIVariant data conversions. |
michael@0 | 84 | */ |
michael@0 | 85 | |
michael@0 | 86 | class nsVariant MOZ_FINAL : public nsIWritableVariant |
michael@0 | 87 | { |
michael@0 | 88 | public: |
michael@0 | 89 | NS_DECL_ISUPPORTS |
michael@0 | 90 | NS_DECL_NSIVARIANT |
michael@0 | 91 | NS_DECL_NSIWRITABLEVARIANT |
michael@0 | 92 | |
michael@0 | 93 | nsVariant(); |
michael@0 | 94 | |
michael@0 | 95 | static nsresult Initialize(nsDiscriminatedUnion* data); |
michael@0 | 96 | static nsresult Cleanup(nsDiscriminatedUnion* data); |
michael@0 | 97 | |
michael@0 | 98 | static nsresult ConvertToInt8(const nsDiscriminatedUnion& data, uint8_t *_retval); |
michael@0 | 99 | static nsresult ConvertToInt16(const nsDiscriminatedUnion& data, int16_t *_retval); |
michael@0 | 100 | static nsresult ConvertToInt32(const nsDiscriminatedUnion& data, int32_t *_retval); |
michael@0 | 101 | static nsresult ConvertToInt64(const nsDiscriminatedUnion& data, int64_t *_retval); |
michael@0 | 102 | static nsresult ConvertToUint8(const nsDiscriminatedUnion& data, uint8_t *_retval); |
michael@0 | 103 | static nsresult ConvertToUint16(const nsDiscriminatedUnion& data, uint16_t *_retval); |
michael@0 | 104 | static nsresult ConvertToUint32(const nsDiscriminatedUnion& data, uint32_t *_retval); |
michael@0 | 105 | static nsresult ConvertToUint64(const nsDiscriminatedUnion& data, uint64_t *_retval); |
michael@0 | 106 | static nsresult ConvertToFloat(const nsDiscriminatedUnion& data, float *_retval); |
michael@0 | 107 | static nsresult ConvertToDouble(const nsDiscriminatedUnion& data, double *_retval); |
michael@0 | 108 | static nsresult ConvertToBool(const nsDiscriminatedUnion& data, bool *_retval); |
michael@0 | 109 | static nsresult ConvertToChar(const nsDiscriminatedUnion& data, char *_retval); |
michael@0 | 110 | static nsresult ConvertToWChar(const nsDiscriminatedUnion& data, char16_t *_retval); |
michael@0 | 111 | static nsresult ConvertToID(const nsDiscriminatedUnion& data, nsID * _retval); |
michael@0 | 112 | static nsresult ConvertToAString(const nsDiscriminatedUnion& data, nsAString & _retval); |
michael@0 | 113 | static nsresult ConvertToAUTF8String(const nsDiscriminatedUnion& data, nsAUTF8String & _retval); |
michael@0 | 114 | static nsresult ConvertToACString(const nsDiscriminatedUnion& data, nsACString & _retval); |
michael@0 | 115 | static nsresult ConvertToString(const nsDiscriminatedUnion& data, char **_retval); |
michael@0 | 116 | static nsresult ConvertToWString(const nsDiscriminatedUnion& data, char16_t **_retval); |
michael@0 | 117 | static nsresult ConvertToISupports(const nsDiscriminatedUnion& data, nsISupports **_retval); |
michael@0 | 118 | static nsresult ConvertToInterface(const nsDiscriminatedUnion& data, nsIID * *iid, void * *iface); |
michael@0 | 119 | static nsresult ConvertToArray(const nsDiscriminatedUnion& data, uint16_t *type, nsIID* iid, uint32_t *count, void * *ptr); |
michael@0 | 120 | static nsresult ConvertToStringWithSize(const nsDiscriminatedUnion& data, uint32_t *size, char **str); |
michael@0 | 121 | static nsresult ConvertToWStringWithSize(const nsDiscriminatedUnion& data, uint32_t *size, char16_t **str); |
michael@0 | 122 | |
michael@0 | 123 | static nsresult SetFromVariant(nsDiscriminatedUnion* data, nsIVariant* aValue); |
michael@0 | 124 | |
michael@0 | 125 | static nsresult SetFromInt8(nsDiscriminatedUnion* data, uint8_t aValue); |
michael@0 | 126 | static nsresult SetFromInt16(nsDiscriminatedUnion* data, int16_t aValue); |
michael@0 | 127 | static nsresult SetFromInt32(nsDiscriminatedUnion* data, int32_t aValue); |
michael@0 | 128 | static nsresult SetFromInt64(nsDiscriminatedUnion* data, int64_t aValue); |
michael@0 | 129 | static nsresult SetFromUint8(nsDiscriminatedUnion* data, uint8_t aValue); |
michael@0 | 130 | static nsresult SetFromUint16(nsDiscriminatedUnion* data, uint16_t aValue); |
michael@0 | 131 | static nsresult SetFromUint32(nsDiscriminatedUnion* data, uint32_t aValue); |
michael@0 | 132 | static nsresult SetFromUint64(nsDiscriminatedUnion* data, uint64_t aValue); |
michael@0 | 133 | static nsresult SetFromFloat(nsDiscriminatedUnion* data, float aValue); |
michael@0 | 134 | static nsresult SetFromDouble(nsDiscriminatedUnion* data, double aValue); |
michael@0 | 135 | static nsresult SetFromBool(nsDiscriminatedUnion* data, bool aValue); |
michael@0 | 136 | static nsresult SetFromChar(nsDiscriminatedUnion* data, char aValue); |
michael@0 | 137 | static nsresult SetFromWChar(nsDiscriminatedUnion* data, char16_t aValue); |
michael@0 | 138 | static nsresult SetFromID(nsDiscriminatedUnion* data, const nsID & aValue); |
michael@0 | 139 | static nsresult SetFromAString(nsDiscriminatedUnion* data, const nsAString & aValue); |
michael@0 | 140 | static nsresult SetFromAUTF8String(nsDiscriminatedUnion* data, const nsAUTF8String & aValue); |
michael@0 | 141 | static nsresult SetFromACString(nsDiscriminatedUnion* data, const nsACString & aValue); |
michael@0 | 142 | static nsresult SetFromString(nsDiscriminatedUnion* data, const char *aValue); |
michael@0 | 143 | static nsresult SetFromWString(nsDiscriminatedUnion* data, const char16_t *aValue); |
michael@0 | 144 | static nsresult SetFromISupports(nsDiscriminatedUnion* data, nsISupports *aValue); |
michael@0 | 145 | static nsresult SetFromInterface(nsDiscriminatedUnion* data, const nsIID& iid, nsISupports *aValue); |
michael@0 | 146 | static nsresult SetFromArray(nsDiscriminatedUnion* data, uint16_t type, const nsIID* iid, uint32_t count, void * aValue); |
michael@0 | 147 | static nsresult SetFromStringWithSize(nsDiscriminatedUnion* data, uint32_t size, const char *aValue); |
michael@0 | 148 | static nsresult SetFromWStringWithSize(nsDiscriminatedUnion* data, uint32_t size, const char16_t *aValue); |
michael@0 | 149 | |
michael@0 | 150 | static nsresult SetToVoid(nsDiscriminatedUnion* data); |
michael@0 | 151 | static nsresult SetToEmpty(nsDiscriminatedUnion* data); |
michael@0 | 152 | static nsresult SetToEmptyArray(nsDiscriminatedUnion* data); |
michael@0 | 153 | |
michael@0 | 154 | static void Traverse(const nsDiscriminatedUnion& data, |
michael@0 | 155 | nsCycleCollectionTraversalCallback &cb); |
michael@0 | 156 | |
michael@0 | 157 | private: |
michael@0 | 158 | ~nsVariant(); |
michael@0 | 159 | |
michael@0 | 160 | protected: |
michael@0 | 161 | nsDiscriminatedUnion mData; |
michael@0 | 162 | bool mWritable; |
michael@0 | 163 | }; |
michael@0 | 164 | |
michael@0 | 165 | /** |
michael@0 | 166 | * Users of nsIVariant should be using the contractID and not this CID. |
michael@0 | 167 | * - see NS_VARIANT_CONTRACTID in nsIVariant.idl. |
michael@0 | 168 | */ |
michael@0 | 169 | |
michael@0 | 170 | #define NS_VARIANT_CID \ |
michael@0 | 171 | { /* 0D6EA1D0-879C-11d5-90EF-0010A4E73D9A */ \ |
michael@0 | 172 | 0xd6ea1d0, \ |
michael@0 | 173 | 0x879c, \ |
michael@0 | 174 | 0x11d5, \ |
michael@0 | 175 | {0x90, 0xef, 0x0, 0x10, 0xa4, 0xe7, 0x3d, 0x9a}} |
michael@0 | 176 | |
michael@0 | 177 | #endif // nsVariant_h |