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: 40; 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 file, |
michael@0 | 4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef mozilla_dom_power_WakeLock_h |
michael@0 | 7 | #define mozilla_dom_power_WakeLock_h |
michael@0 | 8 | |
michael@0 | 9 | #include "nsCOMPtr.h" |
michael@0 | 10 | #include "nsIDOMEventListener.h" |
michael@0 | 11 | #include "nsIObserver.h" |
michael@0 | 12 | #include "nsString.h" |
michael@0 | 13 | #include "nsWeakReference.h" |
michael@0 | 14 | #include "nsWrapperCache.h" |
michael@0 | 15 | #include "mozilla/ErrorResult.h" |
michael@0 | 16 | |
michael@0 | 17 | class nsIDOMWindow; |
michael@0 | 18 | |
michael@0 | 19 | namespace mozilla { |
michael@0 | 20 | namespace dom { |
michael@0 | 21 | |
michael@0 | 22 | class ContentParent; |
michael@0 | 23 | |
michael@0 | 24 | class WakeLock MOZ_FINAL |
michael@0 | 25 | : public nsIDOMEventListener |
michael@0 | 26 | , public nsWrapperCache |
michael@0 | 27 | , public nsIObserver |
michael@0 | 28 | , public nsSupportsWeakReference |
michael@0 | 29 | { |
michael@0 | 30 | public: |
michael@0 | 31 | NS_DECL_NSIDOMEVENTLISTENER |
michael@0 | 32 | NS_DECL_NSIOBSERVER |
michael@0 | 33 | |
michael@0 | 34 | NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
michael@0 | 35 | NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(WakeLock, nsIDOMEventListener) |
michael@0 | 36 | |
michael@0 | 37 | // Note: WakeLock lives for the lifetime of the document in order to avoid |
michael@0 | 38 | // exposing GC behavior to pages. This means that |
michael@0 | 39 | // |var foo = navigator.requestWakeLock('cpu'); foo = null;| |
michael@0 | 40 | // doesn't unlock the 'cpu' resource. |
michael@0 | 41 | |
michael@0 | 42 | WakeLock(); |
michael@0 | 43 | virtual ~WakeLock(); |
michael@0 | 44 | |
michael@0 | 45 | // Initialize this wake lock on behalf of the given window. Null windows are |
michael@0 | 46 | // allowed; a lock without an associated window is always considered |
michael@0 | 47 | // invisible. |
michael@0 | 48 | nsresult Init(const nsAString &aTopic, nsIDOMWindow* aWindow); |
michael@0 | 49 | |
michael@0 | 50 | // Initialize this wake lock on behalf of the given process. If the process |
michael@0 | 51 | // dies, the lock is released. A wake lock initialized via this method is |
michael@0 | 52 | // always considered visible. |
michael@0 | 53 | nsresult Init(const nsAString &aTopic, ContentParent* aContentParent); |
michael@0 | 54 | |
michael@0 | 55 | // WebIDL methods |
michael@0 | 56 | |
michael@0 | 57 | nsISupports* GetParentObject() const; |
michael@0 | 58 | |
michael@0 | 59 | virtual JSObject* |
michael@0 | 60 | WrapObject(JSContext* aCx) MOZ_OVERRIDE; |
michael@0 | 61 | |
michael@0 | 62 | void GetTopic(nsAString& aTopic); |
michael@0 | 63 | |
michael@0 | 64 | void Unlock(ErrorResult& aRv); |
michael@0 | 65 | |
michael@0 | 66 | private: |
michael@0 | 67 | void DoUnlock(); |
michael@0 | 68 | void DoLock(); |
michael@0 | 69 | void AttachEventListener(); |
michael@0 | 70 | void DetachEventListener(); |
michael@0 | 71 | |
michael@0 | 72 | bool mLocked; |
michael@0 | 73 | bool mHidden; |
michael@0 | 74 | |
michael@0 | 75 | // The ID of the ContentParent on behalf of whom we acquired this lock, or |
michael@0 | 76 | // CONTENT_PROCESS_UNKNOWN_ID if this lock was acquired on behalf of the |
michael@0 | 77 | // current process. |
michael@0 | 78 | uint64_t mContentParentID; |
michael@0 | 79 | nsString mTopic; |
michael@0 | 80 | |
michael@0 | 81 | // window that this was created for. Weak reference. |
michael@0 | 82 | nsWeakPtr mWindow; |
michael@0 | 83 | }; |
michael@0 | 84 | |
michael@0 | 85 | } // namespace dom |
michael@0 | 86 | } // namespace mozilla |
michael@0 | 87 | |
michael@0 | 88 | #endif // mozilla_dom_power_WakeLock_h |