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: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | ////////////////////////////////////////////////////////////////////////////////////////// |
michael@0 | 7 | |
michael@0 | 8 | #ifndef nsXBLService_h_ |
michael@0 | 9 | #define nsXBLService_h_ |
michael@0 | 10 | |
michael@0 | 11 | #include "nsString.h" |
michael@0 | 12 | #include "nsWeakReference.h" |
michael@0 | 13 | #include "nsTArray.h" |
michael@0 | 14 | #include "nsDataHashtable.h" |
michael@0 | 15 | #include "nsHashKeys.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsXBLBinding; |
michael@0 | 18 | class nsXBLDocumentInfo; |
michael@0 | 19 | class nsIContent; |
michael@0 | 20 | class nsIDocument; |
michael@0 | 21 | class nsString; |
michael@0 | 22 | class nsIURI; |
michael@0 | 23 | class nsIPrincipal; |
michael@0 | 24 | |
michael@0 | 25 | namespace mozilla { |
michael@0 | 26 | namespace dom { |
michael@0 | 27 | class EventTarget; |
michael@0 | 28 | } |
michael@0 | 29 | } |
michael@0 | 30 | |
michael@0 | 31 | class nsXBLService MOZ_FINAL : public nsSupportsWeakReference |
michael@0 | 32 | { |
michael@0 | 33 | NS_DECL_ISUPPORTS |
michael@0 | 34 | |
michael@0 | 35 | static nsXBLService* gInstance; |
michael@0 | 36 | |
michael@0 | 37 | static void Init(); |
michael@0 | 38 | |
michael@0 | 39 | static void Shutdown() { |
michael@0 | 40 | NS_IF_RELEASE(gInstance); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | static nsXBLService* GetInstance() { return gInstance; } |
michael@0 | 44 | |
michael@0 | 45 | static bool IsChromeOrResourceURI(nsIURI* aURI); |
michael@0 | 46 | |
michael@0 | 47 | // This function loads a particular XBL file and installs all of the bindings |
michael@0 | 48 | // onto the element. aOriginPrincipal must not be null here. |
michael@0 | 49 | nsresult LoadBindings(nsIContent* aContent, nsIURI* aURL, |
michael@0 | 50 | nsIPrincipal* aOriginPrincipal, |
michael@0 | 51 | nsXBLBinding** aBinding, bool* aResolveStyle); |
michael@0 | 52 | |
michael@0 | 53 | // Indicates whether or not a binding is fully loaded. |
michael@0 | 54 | nsresult BindingReady(nsIContent* aBoundElement, nsIURI* aURI, bool* aIsReady); |
michael@0 | 55 | |
michael@0 | 56 | // This method checks the hashtable and then calls FetchBindingDocument on a |
michael@0 | 57 | // miss. aOriginPrincipal or aBoundDocument may be null to bypass security |
michael@0 | 58 | // checks. |
michael@0 | 59 | nsresult LoadBindingDocumentInfo(nsIContent* aBoundElement, |
michael@0 | 60 | nsIDocument* aBoundDocument, |
michael@0 | 61 | nsIURI* aBindingURI, |
michael@0 | 62 | nsIPrincipal* aOriginPrincipal, |
michael@0 | 63 | bool aForceSyncLoad, |
michael@0 | 64 | nsXBLDocumentInfo** aResult); |
michael@0 | 65 | |
michael@0 | 66 | // Used by XUL key bindings and for window XBL. |
michael@0 | 67 | static nsresult AttachGlobalKeyHandler(mozilla::dom::EventTarget* aTarget); |
michael@0 | 68 | static nsresult DetachGlobalKeyHandler(mozilla::dom::EventTarget* aTarget); |
michael@0 | 69 | |
michael@0 | 70 | private: |
michael@0 | 71 | nsXBLService(); |
michael@0 | 72 | virtual ~nsXBLService(); |
michael@0 | 73 | |
michael@0 | 74 | protected: |
michael@0 | 75 | // This function clears out the bindings on a given content node. |
michael@0 | 76 | nsresult FlushStyleBindings(nsIContent* aContent); |
michael@0 | 77 | |
michael@0 | 78 | // This method synchronously loads and parses an XBL file. |
michael@0 | 79 | nsresult FetchBindingDocument(nsIContent* aBoundElement, nsIDocument* aBoundDocument, |
michael@0 | 80 | nsIURI* aDocumentURI, nsIURI* aBindingURI, |
michael@0 | 81 | bool aForceSyncLoad, nsIDocument** aResult); |
michael@0 | 82 | |
michael@0 | 83 | /** |
michael@0 | 84 | * This method calls the one below with an empty |aDontExtendURIs| array. |
michael@0 | 85 | */ |
michael@0 | 86 | nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI, |
michael@0 | 87 | bool aPeekFlag, nsIPrincipal* aOriginPrincipal, |
michael@0 | 88 | bool* aIsReady, nsXBLBinding** aResult); |
michael@0 | 89 | |
michael@0 | 90 | /** |
michael@0 | 91 | * This method loads a binding doc and then builds the specific binding |
michael@0 | 92 | * required. It can also peek without building. |
michael@0 | 93 | * @param aBoundElement the element to get a binding for |
michael@0 | 94 | * @param aURI the binding URI |
michael@0 | 95 | * @param aPeekFlag if true then just peek to see if the binding is ready |
michael@0 | 96 | * @param aIsReady [out] if the binding is ready or not |
michael@0 | 97 | * @param aResult [out] where to store the resulting binding (not used if |
michael@0 | 98 | * aPeekFlag is true, otherwise it must be non-null) |
michael@0 | 99 | * @param aDontExtendURIs a set of URIs that are already bound to this |
michael@0 | 100 | * element. If a binding extends any of these then further loading |
michael@0 | 101 | * is aborted (because it would lead to the binding extending itself) |
michael@0 | 102 | * and NS_ERROR_ILLEGAL_VALUE is returned. |
michael@0 | 103 | * |
michael@0 | 104 | * @note This method always calls LoadBindingDocumentInfo(), so it's |
michael@0 | 105 | * enough to funnel all security checks through that function. |
michael@0 | 106 | */ |
michael@0 | 107 | nsresult GetBinding(nsIContent* aBoundElement, nsIURI* aURI, |
michael@0 | 108 | bool aPeekFlag, nsIPrincipal* aOriginPrincipal, |
michael@0 | 109 | bool* aIsReady, nsXBLBinding** aResult, |
michael@0 | 110 | nsTArray<nsIURI*>& aDontExtendURIs); |
michael@0 | 111 | |
michael@0 | 112 | // MEMBER VARIABLES |
michael@0 | 113 | public: |
michael@0 | 114 | static bool gDisableChromeCache; |
michael@0 | 115 | static bool gAllowDataURIs; // Whether we should allow data |
michael@0 | 116 | // urls in -moz-binding. Needed for |
michael@0 | 117 | // testing. |
michael@0 | 118 | }; |
michael@0 | 119 | |
michael@0 | 120 | #endif |