toolkit/xre/nsNativeAppSupportQt.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

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: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* vim: set ts=8 et sw=2 tw=80: */
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 #include <stdlib.h>
michael@0 8 #include <QTimer>
michael@0 9 #include "mozilla/ipc/GeckoChildProcessHost.h"
michael@0 10 #include "nsNativeAppSupportQt.h"
michael@0 11 #include "nsCOMPtr.h"
michael@0 12 #include "nsIObserverService.h"
michael@0 13 #include "mozilla/Services.h"
michael@0 14
michael@0 15 #ifdef MOZ_ENABLE_QMSYSTEM2
michael@0 16 void
michael@0 17 nsNativeAppSupportQt::activityChanged(MeeGo::QmActivity::Activity activity)
michael@0 18 {
michael@0 19 nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
michael@0 20 if (!os)
michael@0 21 return;
michael@0 22
michael@0 23 if (MeeGo::QmActivity::Inactive == activity) {
michael@0 24 os->NotifyObservers(nullptr, "system-idle", nullptr);
michael@0 25 } else {
michael@0 26 os->NotifyObservers(nullptr, "system-active", nullptr);
michael@0 27 }
michael@0 28 }
michael@0 29
michael@0 30 void
michael@0 31 nsNativeAppSupportQt::displayStateChanged(MeeGo::QmDisplayState::DisplayState state)
michael@0 32 {
michael@0 33 nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
michael@0 34 if (!os)
michael@0 35 return;
michael@0 36
michael@0 37 switch (state) {
michael@0 38 case MeeGo::QmDisplayState::On:
michael@0 39 os->NotifyObservers(nullptr, "system-display-on", nullptr);
michael@0 40 break;
michael@0 41 case MeeGo::QmDisplayState::Off:
michael@0 42 os->NotifyObservers(nullptr, "system-display-off", nullptr);
michael@0 43 break;
michael@0 44 case MeeGo::QmDisplayState::Dimmed:
michael@0 45 os->NotifyObservers(nullptr, "system-display-dimmed", nullptr);
michael@0 46 break;
michael@0 47 default:
michael@0 48 NS_WARNING("Unknown display state");
michael@0 49 break;
michael@0 50 }
michael@0 51 }
michael@0 52
michael@0 53 void nsNativeAppSupportQt::deviceModeChanged(MeeGo::QmDeviceMode::DeviceMode mode)
michael@0 54 {
michael@0 55 nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
michael@0 56 if (!os)
michael@0 57 return;
michael@0 58
michael@0 59 switch (mode) {
michael@0 60 case MeeGo::QmDeviceMode::DeviceMode::Normal:
michael@0 61 os->NotifyObservers(nullptr, "profile-change-net-restore", nullptr);
michael@0 62 break;
michael@0 63 case MeeGo::QmDeviceMode::DeviceMode::Flight:
michael@0 64 os->NotifyObservers(nullptr, "profile-change-net-teardown", nullptr);
michael@0 65 break;
michael@0 66 case MeeGo::QmDeviceMode::DeviceMode::Error:
michael@0 67 default:
michael@0 68 NS_WARNING("Unknown DeviceMode");
michael@0 69 break;
michael@0 70 }
michael@0 71 }
michael@0 72
michael@0 73 void nsNativeAppSupportQt::RefreshStates()
michael@0 74 {
michael@0 75 activityChanged(mActivity.get());
michael@0 76 displayStateChanged(mDisplayState.get());
michael@0 77 deviceModeChanged(mDeviceMode.getMode());
michael@0 78 }
michael@0 79 #endif
michael@0 80
michael@0 81 NS_IMETHODIMP
michael@0 82 nsNativeAppSupportQt::Start(bool* aRetVal)
michael@0 83 {
michael@0 84 NS_ASSERTION(gAppData, "gAppData must not be null.");
michael@0 85
michael@0 86 #ifdef MOZ_ENABLE_QMSYSTEM2
michael@0 87 connect(&mActivity, SIGNAL(activityChanged(MeeGo::QmActivity::Activity)), this, SLOT(activityChanged(MeeGo::QmActivity::Activity)));
michael@0 88 connect(&mDeviceMode, SIGNAL(deviceModeChanged(MeeGo::QmDeviceMode::DeviceMode)), this, SLOT(deviceModeChanged(MeeGo::QmDeviceMode::DeviceMode)));
michael@0 89 connect(&mDisplayState, SIGNAL(displayStateChanged(MeeGo::QmDisplayState::DisplayState)), this, SLOT(displayStateChanged(MeeGo::QmDisplayState::DisplayState)));
michael@0 90 // Init states withing next event loop iteration
michael@0 91 QTimer::singleShot(0, this, SLOT(RefreshStates()));
michael@0 92 #endif
michael@0 93
michael@0 94 *aRetVal = true;
michael@0 95 return NS_OK;
michael@0 96 }
michael@0 97
michael@0 98 NS_IMETHODIMP
michael@0 99 nsNativeAppSupportQt::Stop(bool* aResult)
michael@0 100 {
michael@0 101 NS_ENSURE_ARG(aResult);
michael@0 102 *aResult = true;
michael@0 103
michael@0 104 return NS_OK;
michael@0 105 }
michael@0 106
michael@0 107 nsresult
michael@0 108 NS_CreateNativeAppSupport(nsINativeAppSupport** aResult)
michael@0 109 {
michael@0 110 nsNativeAppSupportBase* native = new nsNativeAppSupportQt();
michael@0 111 if (!native)
michael@0 112 return NS_ERROR_OUT_OF_MEMORY;
michael@0 113
michael@0 114 *aResult = native;
michael@0 115 NS_ADDREF(*aResult);
michael@0 116
michael@0 117 return NS_OK;
michael@0 118 }

mercurial