mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
3571e0740d
--HG-- rename : browser/components/sessionstore/src/ContentRestore.jsm => browser/components/sessionstore/ContentRestore.jsm rename : browser/components/sessionstore/src/DocShellCapabilities.jsm => browser/components/sessionstore/DocShellCapabilities.jsm rename : browser/components/sessionstore/src/FrameTree.jsm => browser/components/sessionstore/FrameTree.jsm rename : browser/components/sessionstore/src/GlobalState.jsm => browser/components/sessionstore/GlobalState.jsm rename : browser/components/sessionstore/src/PageStyle.jsm => browser/components/sessionstore/PageStyle.jsm rename : browser/components/sessionstore/src/PrivacyFilter.jsm => browser/components/sessionstore/PrivacyFilter.jsm rename : browser/components/sessionstore/src/PrivacyLevel.jsm => browser/components/sessionstore/PrivacyLevel.jsm rename : browser/components/sessionstore/src/RecentlyClosedTabsAndWindowsMenuUtils.jsm => browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm rename : browser/components/sessionstore/src/SessionCookies.jsm => browser/components/sessionstore/SessionCookies.jsm rename : browser/components/sessionstore/src/SessionFile.jsm => browser/components/sessionstore/SessionFile.jsm rename : browser/components/sessionstore/src/SessionHistory.jsm => browser/components/sessionstore/SessionHistory.jsm rename : browser/components/sessionstore/src/SessionMigration.jsm => browser/components/sessionstore/SessionMigration.jsm rename : browser/components/sessionstore/src/SessionSaver.jsm => browser/components/sessionstore/SessionSaver.jsm rename : browser/components/sessionstore/src/SessionStorage.jsm => browser/components/sessionstore/SessionStorage.jsm rename : browser/components/sessionstore/src/SessionStore.jsm => browser/components/sessionstore/SessionStore.jsm rename : browser/components/sessionstore/src/SessionWorker.js => browser/components/sessionstore/SessionWorker.js rename : browser/components/sessionstore/src/SessionWorker.jsm => browser/components/sessionstore/SessionWorker.jsm rename : browser/components/sessionstore/src/TabAttributes.jsm => browser/components/sessionstore/TabAttributes.jsm rename : browser/components/sessionstore/src/TabState.jsm => browser/components/sessionstore/TabState.jsm rename : browser/components/sessionstore/src/TabStateCache.jsm => browser/components/sessionstore/TabStateCache.jsm rename : browser/components/sessionstore/src/Utils.jsm => browser/components/sessionstore/Utils.jsm rename : browser/components/sessionstore/src/nsSessionStartup.js => browser/components/sessionstore/nsSessionStartup.js rename : browser/components/sessionstore/src/nsSessionStore.js => browser/components/sessionstore/nsSessionStore.js rename : browser/components/sessionstore/src/nsSessionStore.manifest => browser/components/sessionstore/nsSessionStore.manifest
79 lines
2.5 KiB
JavaScript
79 lines
2.5 KiB
JavaScript
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
"use strict";
|
|
|
|
this.EXPORTED_SYMBOLS = ["PrivacyLevel"];
|
|
|
|
const Cu = Components.utils;
|
|
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
|
|
XPCOMUtils.defineLazyServiceGetter(this, "gSessionStartup",
|
|
"@mozilla.org/browser/sessionstartup;1", "nsISessionStartup");
|
|
|
|
const PREF_NORMAL = "browser.sessionstore.privacy_level";
|
|
const PREF_DEFERRED = "browser.sessionstore.privacy_level_deferred";
|
|
|
|
// The following constants represent the different possible privacy levels that
|
|
// can be set by the user and that we need to consider when collecting text
|
|
// data, and cookies.
|
|
//
|
|
// Collect data from all sites (http and https).
|
|
const PRIVACY_NONE = 0;
|
|
// Collect data from unencrypted sites (http), only.
|
|
const PRIVACY_ENCRYPTED = 1;
|
|
// Collect no data.
|
|
const PRIVACY_FULL = 2;
|
|
|
|
/**
|
|
* Determines the current privacy level as set by the user.
|
|
*
|
|
* @param isPinned
|
|
* Whether to return the privacy level for pinned tabs.
|
|
* @return {int} The privacy level as read from the user's preferences.
|
|
*/
|
|
function getCurrentLevel(isPinned) {
|
|
let pref = PREF_NORMAL;
|
|
|
|
// If we're in the process of quitting and we're not autoresuming the session
|
|
// then we will use the deferred privacy level for non-pinned tabs.
|
|
if (!isPinned && Services.startup.shuttingDown && !gSessionStartup.isAutomaticRestoreEnabled()) {
|
|
pref = PREF_DEFERRED;
|
|
}
|
|
|
|
return Services.prefs.getIntPref(pref);
|
|
}
|
|
|
|
/**
|
|
* The external API as exposed by this module.
|
|
*/
|
|
let PrivacyLevel = Object.freeze({
|
|
/**
|
|
* Checks whether we're allowed to save data for a specific site.
|
|
*
|
|
* @param {isHttps: boolean, isPinned: boolean}
|
|
* An object that must have two properties: 'isHttps' and 'isPinned'.
|
|
* 'isHttps' tells whether the site us secure communication (HTTPS).
|
|
* 'isPinned' tells whether the site is loaded in a pinned tab.
|
|
* @return {bool} Whether we can save data for the specified site.
|
|
*/
|
|
canSave: function ({isHttps, isPinned}) {
|
|
let level = getCurrentLevel(isPinned);
|
|
|
|
// Never save any data when full privacy is requested.
|
|
if (level == PRIVACY_FULL) {
|
|
return false;
|
|
}
|
|
|
|
// Don't save data for encrypted sites when requested.
|
|
if (isHttps && level == PRIVACY_ENCRYPTED) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
});
|