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: 2 -*- |
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 | #ifndef nsDocShellTreeOwner_h__ |
michael@0 | 8 | #define nsDocShellTreeOwner_h__ |
michael@0 | 9 | |
michael@0 | 10 | // Helper Classes |
michael@0 | 11 | #include "nsCOMPtr.h" |
michael@0 | 12 | #include "nsString.h" |
michael@0 | 13 | |
michael@0 | 14 | // Interfaces Needed |
michael@0 | 15 | #include "nsIBaseWindow.h" |
michael@0 | 16 | #include "nsIDocShellTreeOwner.h" |
michael@0 | 17 | #include "nsIInterfaceRequestor.h" |
michael@0 | 18 | #include "nsIInterfaceRequestorUtils.h" |
michael@0 | 19 | #include "nsIWebBrowserChrome.h" |
michael@0 | 20 | #include "nsIDOMEventListener.h" |
michael@0 | 21 | #include "nsIEmbeddingSiteWindow.h" |
michael@0 | 22 | #include "nsIWebProgressListener.h" |
michael@0 | 23 | #include "nsWeakReference.h" |
michael@0 | 24 | #include "nsITimer.h" |
michael@0 | 25 | #include "nsIPrompt.h" |
michael@0 | 26 | #include "nsIAuthPrompt.h" |
michael@0 | 27 | #include "nsITooltipListener.h" |
michael@0 | 28 | #include "nsITooltipTextProvider.h" |
michael@0 | 29 | #include "nsCTooltipTextProvider.h" |
michael@0 | 30 | #include "nsIDroppedLinkHandler.h" |
michael@0 | 31 | #include "nsCommandHandler.h" |
michael@0 | 32 | |
michael@0 | 33 | namespace mozilla { |
michael@0 | 34 | namespace dom { |
michael@0 | 35 | class EventTarget; |
michael@0 | 36 | } |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | class nsWebBrowser; |
michael@0 | 40 | class ChromeTooltipListener; |
michael@0 | 41 | class ChromeContextMenuListener; |
michael@0 | 42 | |
michael@0 | 43 | // {6D10C180-6888-11d4-952B-0020183BF181} |
michael@0 | 44 | #define NS_ICDOCSHELLTREEOWNER_IID \ |
michael@0 | 45 | { 0x6d10c180, 0x6888, 0x11d4, { 0x95, 0x2b, 0x0, 0x20, 0x18, 0x3b, 0xf1, 0x81 } } |
michael@0 | 46 | |
michael@0 | 47 | /* |
michael@0 | 48 | * This is a fake 'hidden' interface that nsDocShellTreeOwner implements. |
michael@0 | 49 | * Classes such as nsCommandHandler can QI for this interface to be |
michael@0 | 50 | * sure that they're dealing with a valid nsDocShellTreeOwner and not some |
michael@0 | 51 | * other object that implements nsIDocShellTreeOwner. |
michael@0 | 52 | */ |
michael@0 | 53 | class nsICDocShellTreeOwner : public nsISupports |
michael@0 | 54 | { |
michael@0 | 55 | public: |
michael@0 | 56 | NS_DECLARE_STATIC_IID_ACCESSOR(NS_ICDOCSHELLTREEOWNER_IID) |
michael@0 | 57 | }; |
michael@0 | 58 | |
michael@0 | 59 | NS_DEFINE_STATIC_IID_ACCESSOR(nsICDocShellTreeOwner, |
michael@0 | 60 | NS_ICDOCSHELLTREEOWNER_IID) |
michael@0 | 61 | |
michael@0 | 62 | class nsDocShellTreeOwner : public nsIDocShellTreeOwner, |
michael@0 | 63 | public nsIBaseWindow, |
michael@0 | 64 | public nsIInterfaceRequestor, |
michael@0 | 65 | public nsIWebProgressListener, |
michael@0 | 66 | public nsIDOMEventListener, |
michael@0 | 67 | public nsICDocShellTreeOwner, |
michael@0 | 68 | public nsSupportsWeakReference |
michael@0 | 69 | { |
michael@0 | 70 | friend class nsWebBrowser; |
michael@0 | 71 | friend class nsCommandHandler; |
michael@0 | 72 | |
michael@0 | 73 | public: |
michael@0 | 74 | NS_DECL_ISUPPORTS |
michael@0 | 75 | |
michael@0 | 76 | NS_DECL_NSIBASEWINDOW |
michael@0 | 77 | NS_DECL_NSIDOCSHELLTREEOWNER |
michael@0 | 78 | NS_DECL_NSIDOMEVENTLISTENER |
michael@0 | 79 | NS_DECL_NSIINTERFACEREQUESTOR |
michael@0 | 80 | NS_DECL_NSIWEBPROGRESSLISTENER |
michael@0 | 81 | |
michael@0 | 82 | protected: |
michael@0 | 83 | nsDocShellTreeOwner(); |
michael@0 | 84 | virtual ~nsDocShellTreeOwner(); |
michael@0 | 85 | |
michael@0 | 86 | void WebBrowser(nsWebBrowser* aWebBrowser); |
michael@0 | 87 | |
michael@0 | 88 | nsWebBrowser* WebBrowser(); |
michael@0 | 89 | NS_IMETHOD SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner); |
michael@0 | 90 | NS_IMETHOD SetWebBrowserChrome(nsIWebBrowserChrome* aWebBrowserChrome); |
michael@0 | 91 | |
michael@0 | 92 | NS_IMETHOD AddChromeListeners(); |
michael@0 | 93 | NS_IMETHOD RemoveChromeListeners(); |
michael@0 | 94 | |
michael@0 | 95 | nsresult FindItemWithNameAcrossWindows(const char16_t* aName, |
michael@0 | 96 | nsIDocShellTreeItem* aRequestor, |
michael@0 | 97 | nsIDocShellTreeItem* aOriginalRequestor, |
michael@0 | 98 | nsIDocShellTreeItem **aFoundItem); |
michael@0 | 99 | |
michael@0 | 100 | void EnsurePrompter(); |
michael@0 | 101 | void EnsureAuthPrompter(); |
michael@0 | 102 | |
michael@0 | 103 | void AddToWatcher(); |
michael@0 | 104 | void RemoveFromWatcher(); |
michael@0 | 105 | |
michael@0 | 106 | // These helper functions return the correct instances of the requested |
michael@0 | 107 | // interfaces. If the object passed to SetWebBrowserChrome() implements |
michael@0 | 108 | // nsISupportsWeakReference, then these functions call QueryReferent on |
michael@0 | 109 | // that object. Otherwise, they return an addrefed pointer. If the |
michael@0 | 110 | // WebBrowserChrome object doesn't exist, they return nullptr. |
michael@0 | 111 | already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome(); |
michael@0 | 112 | already_AddRefed<nsIEmbeddingSiteWindow> GetOwnerWin(); |
michael@0 | 113 | already_AddRefed<nsIInterfaceRequestor> GetOwnerRequestor(); |
michael@0 | 114 | |
michael@0 | 115 | protected: |
michael@0 | 116 | |
michael@0 | 117 | // Weak References |
michael@0 | 118 | nsWebBrowser* mWebBrowser; |
michael@0 | 119 | nsIDocShellTreeOwner* mTreeOwner; |
michael@0 | 120 | nsIDocShellTreeItem* mPrimaryContentShell; |
michael@0 | 121 | |
michael@0 | 122 | nsIWebBrowserChrome* mWebBrowserChrome; |
michael@0 | 123 | nsIEmbeddingSiteWindow* mOwnerWin; |
michael@0 | 124 | nsIInterfaceRequestor* mOwnerRequestor; |
michael@0 | 125 | |
michael@0 | 126 | nsWeakPtr mWebBrowserChromeWeak; // nsIWebBrowserChrome |
michael@0 | 127 | |
michael@0 | 128 | // the objects that listen for chrome events like context menus and tooltips. |
michael@0 | 129 | // They are separate objects to avoid circular references between |this| |
michael@0 | 130 | // and the DOM. These are strong, owning refs. |
michael@0 | 131 | ChromeTooltipListener* mChromeTooltipListener; |
michael@0 | 132 | ChromeContextMenuListener* mChromeContextMenuListener; |
michael@0 | 133 | |
michael@0 | 134 | nsCOMPtr<nsIPrompt> mPrompter; |
michael@0 | 135 | nsCOMPtr<nsIAuthPrompt> mAuthPrompter; |
michael@0 | 136 | }; |
michael@0 | 137 | |
michael@0 | 138 | |
michael@0 | 139 | // |
michael@0 | 140 | // class ChromeTooltipListener |
michael@0 | 141 | // |
michael@0 | 142 | // The class that listens to the chrome events and tells the embedding |
michael@0 | 143 | // chrome to show tooltips, as appropriate. Handles registering itself |
michael@0 | 144 | // with the DOM with AddChromeListeners() and removing itself with |
michael@0 | 145 | // RemoveChromeListeners(). |
michael@0 | 146 | // |
michael@0 | 147 | class ChromeTooltipListener : public nsIDOMEventListener |
michael@0 | 148 | { |
michael@0 | 149 | public: |
michael@0 | 150 | NS_DECL_ISUPPORTS |
michael@0 | 151 | |
michael@0 | 152 | ChromeTooltipListener ( nsWebBrowser* inBrowser, nsIWebBrowserChrome* inChrome ) ; |
michael@0 | 153 | virtual ~ChromeTooltipListener ( ) ; |
michael@0 | 154 | |
michael@0 | 155 | NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); |
michael@0 | 156 | NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent); |
michael@0 | 157 | |
michael@0 | 158 | // Add/remove the relevant listeners, based on what interfaces |
michael@0 | 159 | // the embedding chrome implements. |
michael@0 | 160 | NS_IMETHOD AddChromeListeners(); |
michael@0 | 161 | NS_IMETHOD RemoveChromeListeners(); |
michael@0 | 162 | |
michael@0 | 163 | private: |
michael@0 | 164 | |
michael@0 | 165 | // various delays for tooltips |
michael@0 | 166 | enum { |
michael@0 | 167 | kTooltipAutoHideTime = 5000 // 5000ms = 5 seconds |
michael@0 | 168 | }; |
michael@0 | 169 | |
michael@0 | 170 | NS_IMETHOD AddTooltipListener(); |
michael@0 | 171 | NS_IMETHOD RemoveTooltipListener(); |
michael@0 | 172 | |
michael@0 | 173 | NS_IMETHOD ShowTooltip ( int32_t inXCoords, int32_t inYCoords, const nsAString & inTipText ) ; |
michael@0 | 174 | NS_IMETHOD HideTooltip ( ) ; |
michael@0 | 175 | |
michael@0 | 176 | nsWebBrowser* mWebBrowser; |
michael@0 | 177 | nsCOMPtr<mozilla::dom::EventTarget> mEventTarget; |
michael@0 | 178 | nsCOMPtr<nsITooltipTextProvider> mTooltipTextProvider; |
michael@0 | 179 | |
michael@0 | 180 | // This must be a strong ref in order to make sure we can hide the tooltip |
michael@0 | 181 | // if the window goes away while we're displaying one. If we don't hold |
michael@0 | 182 | // a strong ref, the chrome might have been disposed of before we get a chance |
michael@0 | 183 | // to tell it, and no one would ever tell us of that fact. |
michael@0 | 184 | nsCOMPtr<nsIWebBrowserChrome> mWebBrowserChrome; |
michael@0 | 185 | |
michael@0 | 186 | bool mTooltipListenerInstalled; |
michael@0 | 187 | |
michael@0 | 188 | nsCOMPtr<nsITimer> mTooltipTimer; |
michael@0 | 189 | static void sTooltipCallback ( nsITimer* aTimer, void* aListener ) ; |
michael@0 | 190 | int32_t mMouseClientX, mMouseClientY; // mouse coordinates for last mousemove event we saw |
michael@0 | 191 | int32_t mMouseScreenX, mMouseScreenY; // mouse coordinates for tooltip event |
michael@0 | 192 | bool mShowingTooltip; |
michael@0 | 193 | |
michael@0 | 194 | // a timer for auto-hiding the tooltip after a certain delay |
michael@0 | 195 | nsCOMPtr<nsITimer> mAutoHideTimer; |
michael@0 | 196 | static void sAutoHideCallback ( nsITimer* aTimer, void* aListener ) ; |
michael@0 | 197 | void CreateAutoHideTimer ( ) ; |
michael@0 | 198 | |
michael@0 | 199 | // The node hovered over that fired the timer. This may turn into the node that |
michael@0 | 200 | // triggered the tooltip, but only if the timer ever gets around to firing. |
michael@0 | 201 | // This is a strong reference, because the tooltip content can be destroyed while we're |
michael@0 | 202 | // waiting for the tooltip to pup up, and we need to detect that. |
michael@0 | 203 | // It's set only when the tooltip timer is created and launched. The timer must |
michael@0 | 204 | // either fire or be cancelled (or possibly released?), and we release this |
michael@0 | 205 | // reference in each of those cases. So we don't leak. |
michael@0 | 206 | nsCOMPtr<nsIDOMNode> mPossibleTooltipNode; |
michael@0 | 207 | |
michael@0 | 208 | }; // ChromeTooltipListener |
michael@0 | 209 | |
michael@0 | 210 | |
michael@0 | 211 | // |
michael@0 | 212 | // class ChromeContextMenuListener |
michael@0 | 213 | // |
michael@0 | 214 | // The class that listens to the chrome events and tells the embedding |
michael@0 | 215 | // chrome to show context menus, as appropriate. Handles registering itself |
michael@0 | 216 | // with the DOM with AddChromeListeners() and removing itself with |
michael@0 | 217 | // RemoveChromeListeners(). |
michael@0 | 218 | // |
michael@0 | 219 | class ChromeContextMenuListener : public nsIDOMEventListener |
michael@0 | 220 | { |
michael@0 | 221 | public: |
michael@0 | 222 | NS_DECL_ISUPPORTS |
michael@0 | 223 | |
michael@0 | 224 | ChromeContextMenuListener ( nsWebBrowser* inBrowser, nsIWebBrowserChrome* inChrome ) ; |
michael@0 | 225 | virtual ~ChromeContextMenuListener ( ) ; |
michael@0 | 226 | |
michael@0 | 227 | // nsIDOMContextMenuListener |
michael@0 | 228 | NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent); |
michael@0 | 229 | |
michael@0 | 230 | // Add/remove the relevant listeners, based on what interfaces |
michael@0 | 231 | // the embedding chrome implements. |
michael@0 | 232 | NS_IMETHOD AddChromeListeners(); |
michael@0 | 233 | NS_IMETHOD RemoveChromeListeners(); |
michael@0 | 234 | |
michael@0 | 235 | private: |
michael@0 | 236 | |
michael@0 | 237 | NS_IMETHOD AddContextMenuListener(); |
michael@0 | 238 | NS_IMETHOD RemoveContextMenuListener(); |
michael@0 | 239 | |
michael@0 | 240 | bool mContextMenuListenerInstalled; |
michael@0 | 241 | |
michael@0 | 242 | nsWebBrowser* mWebBrowser; |
michael@0 | 243 | nsCOMPtr<mozilla::dom::EventTarget> mEventTarget; |
michael@0 | 244 | nsCOMPtr<nsIWebBrowserChrome> mWebBrowserChrome; |
michael@0 | 245 | |
michael@0 | 246 | }; // class ChromeContextMenuListener |
michael@0 | 247 | |
michael@0 | 248 | |
michael@0 | 249 | |
michael@0 | 250 | #endif /* nsDocShellTreeOwner_h__ */ |
michael@0 | 251 | |
michael@0 | 252 | |
michael@0 | 253 | |
michael@0 | 254 | |
michael@0 | 255 | |
michael@0 | 256 | |
michael@0 | 257 | |
michael@0 | 258 | |
michael@0 | 259 | |
michael@0 | 260 | |
michael@0 | 261 | |
michael@0 | 262 |