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 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 3 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 4 | |
michael@0 | 5 | #include "IccManager.h" |
michael@0 | 6 | #include "mozilla/dom/MozIccManagerBinding.h" |
michael@0 | 7 | #include "GeneratedEvents.h" |
michael@0 | 8 | #include "Icc.h" |
michael@0 | 9 | #include "IccListener.h" |
michael@0 | 10 | #include "mozilla/dom/IccChangeEvent.h" |
michael@0 | 11 | #include "mozilla/Preferences.h" |
michael@0 | 12 | #include "nsIDOMIccInfo.h" |
michael@0 | 13 | |
michael@0 | 14 | using namespace mozilla::dom; |
michael@0 | 15 | |
michael@0 | 16 | NS_IMPL_CYCLE_COLLECTION_CLASS(IccManager) |
michael@0 | 17 | |
michael@0 | 18 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IccManager, |
michael@0 | 19 | DOMEventTargetHelper) |
michael@0 | 20 | NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END |
michael@0 | 21 | |
michael@0 | 22 | NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IccManager, |
michael@0 | 23 | DOMEventTargetHelper) |
michael@0 | 24 | NS_IMPL_CYCLE_COLLECTION_UNLINK_END |
michael@0 | 25 | |
michael@0 | 26 | // QueryInterface implementation for IccManager |
michael@0 | 27 | NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IccManager) |
michael@0 | 28 | NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper) |
michael@0 | 29 | |
michael@0 | 30 | NS_IMPL_ADDREF_INHERITED(IccManager, DOMEventTargetHelper) |
michael@0 | 31 | NS_IMPL_RELEASE_INHERITED(IccManager, DOMEventTargetHelper) |
michael@0 | 32 | |
michael@0 | 33 | IccManager::IccManager(nsPIDOMWindow* aWindow) |
michael@0 | 34 | : DOMEventTargetHelper(aWindow) |
michael@0 | 35 | { |
michael@0 | 36 | uint32_t numberOfServices = |
michael@0 | 37 | mozilla::Preferences::GetUint("ril.numRadioInterfaces", 1); |
michael@0 | 38 | |
michael@0 | 39 | for (uint32_t i = 0; i < numberOfServices; i++) { |
michael@0 | 40 | nsRefPtr<IccListener> iccListener = new IccListener(this, i); |
michael@0 | 41 | mIccListeners.AppendElement(iccListener); |
michael@0 | 42 | } |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | IccManager::~IccManager() |
michael@0 | 46 | { |
michael@0 | 47 | Shutdown(); |
michael@0 | 48 | } |
michael@0 | 49 | |
michael@0 | 50 | JSObject* |
michael@0 | 51 | IccManager::WrapObject(JSContext* aCx) |
michael@0 | 52 | { |
michael@0 | 53 | return MozIccManagerBinding::Wrap(aCx, this); |
michael@0 | 54 | } |
michael@0 | 55 | |
michael@0 | 56 | void |
michael@0 | 57 | IccManager::Shutdown() |
michael@0 | 58 | { |
michael@0 | 59 | for (uint32_t i = 0; i < mIccListeners.Length(); i++) { |
michael@0 | 60 | mIccListeners[i]->Shutdown(); |
michael@0 | 61 | mIccListeners[i] = nullptr; |
michael@0 | 62 | } |
michael@0 | 63 | mIccListeners.Clear(); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | nsresult |
michael@0 | 67 | IccManager::NotifyIccAdd(const nsAString& aIccId) |
michael@0 | 68 | { |
michael@0 | 69 | MozIccManagerBinding::ClearCachedIccIdsValue(this); |
michael@0 | 70 | |
michael@0 | 71 | IccChangeEventInit init; |
michael@0 | 72 | init.mBubbles = false; |
michael@0 | 73 | init.mCancelable = false; |
michael@0 | 74 | init.mIccId = aIccId; |
michael@0 | 75 | |
michael@0 | 76 | nsRefPtr<IccChangeEvent> event = |
michael@0 | 77 | IccChangeEvent::Constructor(this, NS_LITERAL_STRING("iccdetected"), init); |
michael@0 | 78 | |
michael@0 | 79 | return DispatchTrustedEvent(event); |
michael@0 | 80 | } |
michael@0 | 81 | |
michael@0 | 82 | nsresult |
michael@0 | 83 | IccManager::NotifyIccRemove(const nsAString& aIccId) |
michael@0 | 84 | { |
michael@0 | 85 | MozIccManagerBinding::ClearCachedIccIdsValue(this); |
michael@0 | 86 | |
michael@0 | 87 | IccChangeEventInit init; |
michael@0 | 88 | init.mBubbles = false; |
michael@0 | 89 | init.mCancelable = false; |
michael@0 | 90 | init.mIccId = aIccId; |
michael@0 | 91 | |
michael@0 | 92 | nsRefPtr<IccChangeEvent> event = |
michael@0 | 93 | IccChangeEvent::Constructor(this, NS_LITERAL_STRING("iccundetected"), init); |
michael@0 | 94 | |
michael@0 | 95 | return DispatchTrustedEvent(event); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | // MozIccManager |
michael@0 | 99 | |
michael@0 | 100 | void |
michael@0 | 101 | IccManager::GetIccIds(nsTArray<nsString>& aIccIds) |
michael@0 | 102 | { |
michael@0 | 103 | nsTArray<nsRefPtr<IccListener>>::size_type i; |
michael@0 | 104 | for (i = 0; i < mIccListeners.Length(); ++i) { |
michael@0 | 105 | nsRefPtr<Icc> icc = mIccListeners[i]->GetIcc(); |
michael@0 | 106 | if (icc) { |
michael@0 | 107 | aIccIds.AppendElement(icc->GetIccId()); |
michael@0 | 108 | } |
michael@0 | 109 | } |
michael@0 | 110 | } |
michael@0 | 111 | |
michael@0 | 112 | already_AddRefed<nsISupports> |
michael@0 | 113 | IccManager::GetIccById(const nsAString& aIccId) const |
michael@0 | 114 | { |
michael@0 | 115 | nsTArray<nsRefPtr<IccListener>>::size_type i; |
michael@0 | 116 | for (i = 0; i < mIccListeners.Length(); ++i) { |
michael@0 | 117 | nsRefPtr<Icc> icc = mIccListeners[i]->GetIcc(); |
michael@0 | 118 | if (icc && aIccId == icc->GetIccId()) { |
michael@0 | 119 | return icc.forget(); |
michael@0 | 120 | } |
michael@0 | 121 | } |
michael@0 | 122 | return nullptr; |
michael@0 | 123 | } |