Bug 1397100 - Disable container about:preference checkbox if a container addon is enabled. r=bsilverberg,Felipe

MozReview-Commit-ID: DtJX3FiE0e0

--HG--
extra : rebase_source : 2374318065a63ea2c279d85591a7442e132422c0
This commit is contained in:
Jonathan Kingston 2017-09-18 08:11:31 +01:00
Родитель 979c34dc04
Коммит b194a2f906
6 изменённых файлов: 82 добавлений и 47 удалений

Просмотреть файл

@ -1538,6 +1538,7 @@ pref("privacy.usercontext.about_newtab_segregation.enabled", false);
// 0 disables long press, 1 when clicked, the menu is shown, 2 the menu is shown after X milliseconds.
pref("privacy.userContext.longPressBehavior", 0);
#endif
pref("privacy.userContext.extension", "");
// Start the browser in e10s mode
pref("browser.tabs.remote.autostart", false);

Просмотреть файл

@ -34,6 +34,9 @@ const TOPIC_PDFJS_HANDLER_CHANGED = "pdfjs:handlerChanged";
const PREF_DISABLED_PLUGIN_TYPES = "plugin.disable_full_page_plugin_for_types";
// Pref for when containers is being controlled
const PREF_CONTAINERS_EXTENSION = "privacy.userContext.extension";
// Preferences that affect which entries to show in the list.
const PREF_SHOW_PLUGINS_IN_LIST = "browser.download.show_plugins_in_list";
const PREF_HIDE_PLUGINS_WITHOUT_EXTENSIONS =
@ -243,6 +246,8 @@ var gMainPane = {
gMainPane.restoreDefaultHomePage);
setEventListener("disableHomePageExtension", "command",
gMainPane.makeDisableControllingExtension("homepage_override"));
setEventListener("disableContainersExtension", "command",
gMainPane.makeDisableControllingExtension("privacy.containers"));
setEventListener("chooseLanguage", "command",
gMainPane.showLanguages);
setEventListener("translationAttributionImage", "click",
@ -464,6 +469,32 @@ var gMainPane = {
.notifyObservers(window, "main-pane-loaded");
},
// CONTAINERS
/*
* preferences:
*
* privacy.userContext.enabled
* - true if containers is enabled
*/
/**
* Enables/disables the Settings button used to configure containers
*/
readBrowserContainersCheckbox() {
const pref = document.getElementById("privacy.userContext.enabled");
const settings = document.getElementById("browserContainersSettings");
settings.disabled = !pref.value;
const containersEnabled = Services.prefs.getBoolPref("privacy.userContext.enabled");
const containersCheckbox = document.getElementById("browserContainersCheckbox");
containersCheckbox.checked = containersEnabled;
handleControllingExtension("privacy.containers")
.then((isControlled) => {
containersCheckbox.disabled = isControlled;
});
},
/**
* Show the Containers UI depending on the privacy.userContext.ui.enabled pref.
*/
@ -475,14 +506,13 @@ var gMainPane = {
document.getElementById("browserContainersbox").setAttribute("data-hidden-from-search", "true");
return;
}
this._prefSvc.addObserver(PREF_CONTAINERS_EXTENSION, this);
let link = document.getElementById("browserContainersLearnMore");
const link = document.getElementById("browserContainersLearnMore");
link.href = Services.urlFormatter.formatURLPref("app.support.baseURL") + "containers";
document.getElementById("browserContainersbox").hidden = false;
document.getElementById("browserContainersCheckbox").checked =
Services.prefs.getBoolPref("privacy.userContext.enabled");
this.readBrowserContainersCheckbox();
},
isE10SEnabled() {
@ -1347,6 +1377,8 @@ var gMainPane = {
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_WEB, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_ACTION, this);
this._prefSvc.removeObserver(PREF_AUDIO_FEED_SELECTED_READER, this);
this._prefSvc.removeObserver(PREF_CONTAINERS_EXTENSION, this);
},
@ -1366,6 +1398,10 @@ var gMainPane = {
observe(aSubject, aTopic, aData) {
if (aTopic == "nsPref:changed") {
if (aData == PREF_CONTAINERS_EXTENSION) {
this.readBrowserContainersCheckbox();
return;
}
// Rebuild the list when there are changes to preferences that influence
// whether or not to show certain entries in the list.
if (!this._storingAction) {
@ -2604,6 +2640,7 @@ function getLocalHandlerApp(aFile) {
}
let extensionControlledContentIds = {
"privacy.containers": "browserContainersExtensionContent",
"homepage_override": "browserHomePageExtensionContent",
};
@ -2632,7 +2669,7 @@ async function handleControllingExtension(prefName) {
async function showControllingExtension(settingName, extensionId) {
let extensionControlledContent = getControllingExtensionEl(settingName);
// Tell the user what extension is controlling the homepage.
// Tell the user what extension is controlling the setting.
let addon = await AddonManager.getAddonByID(extensionId);
const defaultIcon = "chrome://mozapps/skin/extensions/extensionGeneric.svg";
let stringParts = document

Просмотреть файл

@ -424,27 +424,35 @@
preference="browser.taskbar.previews.enable"/>
#endif
<hbox id="browserContainersbox" hidden="true" align="center">
<checkbox id="browserContainersCheckbox"
label="&browserContainersEnabled.label;"
accesskey="&browserContainersEnabled.accesskey;"
preference="privacy.userContext.enabled"
onsyncfrompreference="return gPrivacyPane.readBrowserContainersCheckbox();"/>
<label id="browserContainersLearnMore" class="learnMore text-link">
&browserContainersLearnMore.label;
</label>
<spacer flex="1"/>
<!-- Please don't remove the wrapping hbox/vbox/box for these elements. It's used to properly compute the search tooltip position. -->
<hbox>
<button id="browserContainersSettings"
class="accessory-button"
label="&browserContainersSettings.label;"
accesskey="&browserContainersSettings.accesskey;"
searchkeywords="&addButton.label;
&preferencesButton.label;
&removeButton.label;"/>
<vbox id="browserContainersbox" hidden="true">
<hbox id="browserContainersExtensionContent" align="center">
<description control="disableContainersExtension" flex="1" />
<button id="disableContainersExtension"
class="extension-controlled-button accessory-button"
label="&disableExtension.label;" />
</hbox>
</hbox>
<hbox align="center">
<checkbox id="browserContainersCheckbox"
label="&browserContainersEnabled.label;"
accesskey="&browserContainersEnabled.accesskey;"
preference="privacy.userContext.enabled"
onsyncfrompreference="return gMainPane.readBrowserContainersCheckbox();"/>
<label id="browserContainersLearnMore" class="learnMore text-link">
&browserContainersLearnMore.label;
</label>
<spacer flex="1"/>
<!-- Please don't remove the wrapping hbox/vbox/box for these elements. It's used to properly compute the search tooltip position. -->
<hbox>
<button id="browserContainersSettings"
class="accessory-button"
label="&browserContainersSettings.label;"
accesskey="&browserContainersSettings.accesskey;"
searchkeywords="&addButton.label;
&preferencesButton.label;
&removeButton.label;"/>
</hbox>
</hbox>
</vbox>
</groupbox>
<hbox id="languageAndAppearanceCategory"

Просмотреть файл

@ -809,25 +809,6 @@ var gPrivacyPane = {
settingsButton.disabled = !sanitizeOnShutdownPref.value;
},
// CONTAINERS
/*
* preferences:
*
* privacy.userContext.enabled
* - true if containers is enabled
*/
/**
* Enables/disables the Settings button used to configure containers
*/
readBrowserContainersCheckbox() {
var pref = document.getElementById("privacy.userContext.enabled");
var settings = document.getElementById("browserContainersSettings");
settings.disabled = !pref.value;
},
toggleDoNotDisturbNotifications(event) {
AlertsServiceDND.manualDoNotDisturb = event.target.checked;
},

Просмотреть файл

@ -281,3 +281,8 @@ defaultContentProcessCount=%S (default)
# LOCALIZATION NOTE (extensionControlled.homepage_override):
# This string is shown to notify the user that their home page is being controlled by an extension.
extensionControlled.homepage_override = An extension, %S, controls your home page.
# LOCALIZATION NOTE (extensionControlled.privacy.containers):
# This string is shown to notify the user that Container Tabs are being enabled by an extension
# %S is the container addon controlling it
extensionControlled.privacy.containers = An extension, %S, requires Container Tabs.

Просмотреть файл

@ -19,6 +19,7 @@ const CONTAINER_PREF_INSTALL_DEFAULTS = {
"privacy.userContext.longPressBehavior": 2,
"privacy.userContext.ui.enabled": true,
"privacy.usercontext.about_newtab_segregation.enabled": true,
"privacy.userContext.extension": undefined,
};
const CONTAINERS_ENABLED_SETTING_NAME = "privacy.containers";
@ -108,8 +109,10 @@ ExtensionPreferencesManager.addSetting(CONTAINERS_ENABLED_SETTING_NAME, {
prefNames: Object.keys(CONTAINER_PREF_INSTALL_DEFAULTS),
setCallback(value) {
if (value === true) {
return CONTAINER_PREF_INSTALL_DEFAULTS;
if (value !== true) {
return Object.assign(CONTAINER_PREF_INSTALL_DEFAULTS, {
"privacy.userContext.extension": value,
});
}
let prefs = {};
@ -125,7 +128,7 @@ this.contextualIdentities = class extends ExtensionAPI {
let {extension} = this;
if (extension.hasPermission("contextualIdentities")) {
ExtensionPreferencesManager.setSetting(extension, CONTAINERS_ENABLED_SETTING_NAME, true);
ExtensionPreferencesManager.setSetting(extension, CONTAINERS_ENABLED_SETTING_NAME, extension.id);
}
}