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 "AlarmHalService.h" |
michael@0 | 6 | |
michael@0 | 7 | namespace mozilla { |
michael@0 | 8 | namespace dom { |
michael@0 | 9 | namespace alarm { |
michael@0 | 10 | |
michael@0 | 11 | using namespace hal; |
michael@0 | 12 | |
michael@0 | 13 | NS_IMPL_ISUPPORTS(AlarmHalService, nsIAlarmHalService) |
michael@0 | 14 | |
michael@0 | 15 | void |
michael@0 | 16 | AlarmHalService::Init() |
michael@0 | 17 | { |
michael@0 | 18 | mAlarmEnabled = RegisterTheOneAlarmObserver(this); |
michael@0 | 19 | if (!mAlarmEnabled) { |
michael@0 | 20 | return; |
michael@0 | 21 | } |
michael@0 | 22 | RegisterSystemTimezoneChangeObserver(this); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | /* virtual */ AlarmHalService::~AlarmHalService() |
michael@0 | 26 | { |
michael@0 | 27 | if (mAlarmEnabled) { |
michael@0 | 28 | UnregisterTheOneAlarmObserver(); |
michael@0 | 29 | UnregisterSystemTimezoneChangeObserver(this); |
michael@0 | 30 | } |
michael@0 | 31 | } |
michael@0 | 32 | |
michael@0 | 33 | /* static */ StaticRefPtr<AlarmHalService> AlarmHalService::sSingleton; |
michael@0 | 34 | |
michael@0 | 35 | /* static */ already_AddRefed<AlarmHalService> |
michael@0 | 36 | AlarmHalService::GetInstance() |
michael@0 | 37 | { |
michael@0 | 38 | if (!sSingleton) { |
michael@0 | 39 | sSingleton = new AlarmHalService(); |
michael@0 | 40 | sSingleton->Init(); |
michael@0 | 41 | ClearOnShutdown(&sSingleton); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | nsRefPtr<AlarmHalService> service = sSingleton.get(); |
michael@0 | 45 | return service.forget(); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | NS_IMETHODIMP |
michael@0 | 49 | AlarmHalService::SetAlarm(int32_t aSeconds, int32_t aNanoseconds, bool* aStatus) |
michael@0 | 50 | { |
michael@0 | 51 | if (!mAlarmEnabled) { |
michael@0 | 52 | return NS_ERROR_FAILURE; |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | bool status = hal::SetAlarm(aSeconds, aNanoseconds); |
michael@0 | 56 | if (status) { |
michael@0 | 57 | *aStatus = status; |
michael@0 | 58 | return NS_OK; |
michael@0 | 59 | } else { |
michael@0 | 60 | return NS_ERROR_FAILURE; |
michael@0 | 61 | } |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | NS_IMETHODIMP |
michael@0 | 65 | AlarmHalService::SetAlarmFiredCb(nsIAlarmFiredCb* aAlarmFiredCb) |
michael@0 | 66 | { |
michael@0 | 67 | mAlarmFiredCb = aAlarmFiredCb; |
michael@0 | 68 | return NS_OK; |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | NS_IMETHODIMP |
michael@0 | 72 | AlarmHalService::SetTimezoneChangedCb(nsITimezoneChangedCb* aTimeZoneChangedCb) |
michael@0 | 73 | { |
michael@0 | 74 | mTimezoneChangedCb = aTimeZoneChangedCb; |
michael@0 | 75 | return NS_OK; |
michael@0 | 76 | } |
michael@0 | 77 | |
michael@0 | 78 | void |
michael@0 | 79 | AlarmHalService::Notify(const void_t& aVoid) |
michael@0 | 80 | { |
michael@0 | 81 | if (!mAlarmFiredCb) { |
michael@0 | 82 | return; |
michael@0 | 83 | } |
michael@0 | 84 | mAlarmFiredCb->OnAlarmFired(); |
michael@0 | 85 | } |
michael@0 | 86 | |
michael@0 | 87 | void |
michael@0 | 88 | AlarmHalService::Notify( |
michael@0 | 89 | const SystemTimezoneChangeInformation& aSystemTimezoneChangeInfo) |
michael@0 | 90 | { |
michael@0 | 91 | if (!mTimezoneChangedCb) { |
michael@0 | 92 | return; |
michael@0 | 93 | } |
michael@0 | 94 | mTimezoneChangedCb->OnTimezoneChanged( |
michael@0 | 95 | aSystemTimezoneChangeInfo.newTimezoneOffsetMinutes()); |
michael@0 | 96 | } |
michael@0 | 97 | |
michael@0 | 98 | } // alarm |
michael@0 | 99 | } // dom |
michael@0 | 100 | } // mozilla |