Bug 1373853 - Show extension that is controlling the new tab in preferences r?jaws
MozReview-Commit-ID: GycnWgmr9kJ
--- a/browser/components/preferences/in-content/main.js
+++ b/browser/components/preferences/in-content/main.js
@@ -1,18 +1,18 @@
/* 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/. */
/* import-globals-from preferences.js */
/* import-globals-from ../../../../toolkit/mozapps/preferences/fontbuilder.js */
/* import-globals-from ../../../base/content/aboutDialog-appUpdater.js */
-XPCOMUtils.defineLazyModuleGetter(this, "ExtensionPreferencesManager",
- "resource://gre/modules/ExtensionPreferencesManager.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "ExtensionSettingsStore",
+ "resource://gre/modules/ExtensionSettingsStore.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
"resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/Downloads.jsm");
Components.utils.import("resource://gre/modules/FileUtils.jsm");
Components.utils.import("resource:///modules/ShellService.jsm");
Components.utils.import("resource:///modules/TransientPrefs.jsm");
@@ -207,16 +207,27 @@ var gMainPane = {
this.updatePerformanceSettingsBox({ duringChangeEvent: false });
// set up the "use current page" label-changing listener
this._updateUseCurrentButton();
window.addEventListener("focus", this._updateUseCurrentButton.bind(this));
this.updateBrowserStartupLastSession();
+ handleControllingExtension("url_overrides", "newTabURL");
+ let newTabObserver = {
+ observe(subject, topic, data) {
+ handleControllingExtension("url_overrides", "newTabURL");
+ },
+ };
+ Services.obs.addObserver(newTabObserver, "newtab-url-changed");
+ window.addEventListener("unload", () => {
+ Services.obs.removeObserver(newTabObserver, "newtab-url-changed");
+ });
+
if (AppConstants.platform == "win") {
// Functionality for "Show tabs in taskbar" on Windows 7 and up.
try {
let sysInfo = Cc["@mozilla.org/system-info;1"].
getService(Ci.nsIPropertyBag2);
let ver = parseFloat(sysInfo.getProperty("version"));
let showTabsInTaskbar = document.getElementById("showTabsInTaskbar");
showTabsInTaskbar.hidden = ver < 6.1;
@@ -240,19 +251,21 @@ var gMainPane = {
}
setEventListener("useCurrent", "command",
gMainPane.setHomePageToCurrent);
setEventListener("useBookmark", "command",
gMainPane.setHomePageToBookmark);
setEventListener("restoreDefaultHomePage", "command",
gMainPane.restoreDefaultHomePage);
setEventListener("disableHomePageExtension", "command",
- gMainPane.makeDisableControllingExtension("homepage_override"));
+ gMainPane.makeDisableControllingExtension("prefs", "homepage_override"));
setEventListener("disableContainersExtension", "command",
- gMainPane.makeDisableControllingExtension("privacy.containers"));
+ gMainPane.makeDisableControllingExtension("prefs", "privacy.containers"));
+ setEventListener("disableNewTabExtension", "command",
+ gMainPane.makeDisableControllingExtension("url_overrides", "newTabURL"));
setEventListener("chooseLanguage", "command",
gMainPane.showLanguages);
setEventListener("translationAttributionImage", "click",
gMainPane.openTranslationProviderAttribution);
setEventListener("translateButton", "command",
gMainPane.showTranslationExceptions);
setEventListener("font.language.group", "change",
gMainPane._rebuildFonts);
@@ -484,17 +497,17 @@ var gMainPane = {
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")
+ handleControllingExtension("prefs", "privacy.containers")
.then((isControlled) => {
containersCheckbox.disabled = isControlled;
});
},
/**
* Show the Containers UI depending on the privacy.userContext.ui.enabled pref.
*/
@@ -656,17 +669,17 @@ var gMainPane = {
syncFromHomePref() {
let homePref = document.getElementById("browser.startup.homepage");
// Set the "Use Current Page(s)" button's text and enabled state.
this._updateUseCurrentButton();
// This is an async task.
- handleControllingExtension("homepage_override")
+ handleControllingExtension("prefs", "homepage_override")
.then((isControlled) => {
// Disable or enable the inputs based on if this is controlled by an extension.
document.querySelectorAll("#browserHomePage, .homepage-button")
.forEach((button) => {
button.disabled = isControlled;
});
});
@@ -750,17 +763,17 @@ var gMainPane = {
let tabs = this._getTabsForHomePage();
if (tabs.length > 1)
useCurrent.label = useCurrent.getAttribute("label2");
else
useCurrent.label = useCurrent.getAttribute("label1");
// If the homepage is controlled by an extension then you can't use this.
- if (await getControllingExtensionId("homepage_override")) {
+ if (await getControllingExtensionId("prefs", "homepage_override")) {
useCurrent.disabled = true;
return;
}
// In this case, the button's disabled state is set by preferences.xml.
let prefName = "pref.browser.homepage.disable_button.current_page";
if (document.getElementById(prefName).locked)
return;
@@ -798,19 +811,19 @@ var gMainPane = {
/**
* Restores the default home page as the user's home page.
*/
restoreDefaultHomePage() {
var homePage = document.getElementById("browser.startup.homepage");
homePage.value = homePage.defaultValue;
},
- makeDisableControllingExtension(pref) {
+ makeDisableControllingExtension(type, settingName) {
return async function disableExtension() {
- let id = await getControllingExtensionId(pref);
+ let id = await getControllingExtensionId(type, settingName);
let addon = await AddonManager.getAddonByID(id);
addon.userDisabled = true;
};
},
/**
* Utility function to enable/disable the button specified by aButtonID based
* on the value of the Boolean preference specified by aPreferenceID.
@@ -2637,36 +2650,38 @@ function getLocalHandlerApp(aFile) {
localHandlerApp.executable = aFile;
return localHandlerApp;
}
let extensionControlledContentIds = {
"privacy.containers": "browserContainersExtensionContent",
"homepage_override": "browserHomePageExtensionContent",
+ "newTabURL": "browserNewTabExtensionContent",
};
/**
* Check if a pref is being managed by an extension.
*/
-function getControllingExtensionId(settingName) {
- return ExtensionPreferencesManager.getControllingExtensionId(settingName);
+async function getControllingExtensionId(type, settingName) {
+ await ExtensionSettingsStore.initialize();
+ return ExtensionSettingsStore.getTopExtensionId(type, settingName);
}
function getControllingExtensionEl(settingName) {
return document.getElementById(extensionControlledContentIds[settingName]);
}
-async function handleControllingExtension(prefName) {
- let controllingExtensionId = await getControllingExtensionId(prefName);
+async function handleControllingExtension(type, settingName) {
+ let controllingExtensionId = await getControllingExtensionId(type, settingName);
if (controllingExtensionId) {
- showControllingExtension(prefName, controllingExtensionId);
+ showControllingExtension(settingName, controllingExtensionId);
} else {
- hideControllingExtension(prefName);
+ hideControllingExtension(settingName);
}
return !!controllingExtensionId;
}
async function showControllingExtension(settingName, extensionId) {
let extensionControlledContent = getControllingExtensionEl(settingName);
// Tell the user what extension is controlling the setting.
--- a/browser/components/preferences/in-content/main.xul
+++ b/browser/components/preferences/in-content/main.xul
@@ -334,26 +334,32 @@
id="browserStartupHomePage"/>
<radio label="&startupBlankPage.label;"
value="0"
id="browserStartupBlank"/>
<radio label="&startupPrevSession.label;"
value="3"
id="browserStartupLastSession"/>
</radiogroup>
+ <hbox id="browserNewTabExtensionContent" align="center" hidden="true">
+ <description control="disableNewTabExtension" flex="1" />
+ <button id="disableNewTabExtension"
+ class="extension-controlled-button accessory-button"
+ label="&disableExtension.label;" />
+ </hbox>
</vbox>
</groupbox>
<!-- Home Page -->
<groupbox id="homepageGroup"
data-category="paneGeneral"
hidden="true">
<caption><label>&homepage2.label;</label></caption>
- <hbox id="browserHomePageExtensionContent" align="center">
+ <hbox id="browserHomePageExtensionContent" align="center" hidden="true">
<description control="disableHomePageExtension" flex="1" />
<button id="disableHomePageExtension"
class="extension-controlled-button accessory-button"
label="&disableExtension.label;" />
</hbox>
<vbox>
<textbox id="browserHomePage"
new file mode 100644
index 0000000000000000000000000000000000000000..f11db0b6a8625b2587eb33bd272f35180690a771
GIT binary patch
literal 5210
zc$|ee1yodR(|74k3CX2PknYq)VqsZaP(Vav=|;L6mIe_i2}N3v5D}?GML>j=?h>S1
zI{)Q;&wsx6^*`VFpL?D=cjlRyJ9pxqGXsa>;*kIVKm>pSaG?nlK@|#=03c0yMF9Xi
zq>HnNtFsMAnzCy<1`g98Ct<qcCfCx0+{HrGt4&0Jy_ea!O=AI`jhe0+08}TDo;}9L
z;$WoaU0ne1;{||_2mm<2l0udNz*7_eR?PuGJ_7(4Twi?DSHvC=SU@!(z~$AI-&~xE
zr4V{(>8caX;W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|6M<mcf+H1x$NSto2K_hycfLE$rpxGQ}(T=)2BfN
z>o`^~CQ)AlNK+n{?UDM2=Ei<7Vq{rQ6~b)e9_A&5MRL)(P9w&ar-o==f%hs|SRS>h
z(wW&-!d*d%FeBtwPSx->>2>7wHabc=cg6SNc#h@uUo#F`f9$p~hJeL)66%DgT_nyE
z1sa5h`YcvjRE(1dbzb8+CLC+IrvkSJ=}ro9hi`we!mUp_oGo1<k9Xhe6!Oh4q_u!^
zJyKDcG~LY^X;JfC3oN!+x1w>3H-SMgvzAh|vuv1pR<?(^Pj?gb2lpTedm`EyhqERh
z-q`JzfGY0V4D-%P?rD#Gpm6g4CVgr#Q*_LXPneZTkdmP)bS=GKD~l6fIjDh<Lz@|{
zKi*KZj{_Qz{7%AMQtOrd>R`D4r!4)v*`bQTw>9mwRA$Y-qhPghg=>8b)re-pA6xWN
zO{aVfP9lh?wSyK@;Vn$dM`{sKzUWmzo<Kp4_+Dpjfp{?RpImju=IXU7y*&*q1_S=i
zRg1?+2b(7@p3auoZ2c=&ffr52SNo4#g$jPVc@rkwFQg?b(kBG#f$r!Ei@<dBhTz|z
z!jxJ%B;>pL{rZ|=WrBh|LS5f=hoE}GAnlN$XWYCiR?ij|`R(jY+(E#<^C(r>nNJ#v
zNn-aE73t#aVdZ>PIM7~<P%lPnsJlyV1TF{@j=^+dbcHo_^bCI(YGTi{dW7`(VItpd
z@auPW>FH?c>i54Rz-kBKTm%05=<DC>e+OY#Qf#>Yt)3bG;>A7!uR|YW_54xY_<vXT
zAKv=YkUtCNKMO(ikMjAaCI2^C|Fndh2KX~}_<zUl|FPsxm;YyF)BH04a47!O2oS)>
NUQn#EW11`Me*k&^|EvH2
--- a/browser/components/preferences/in-content/tests/browser.ini
+++ b/browser/components/preferences/in-content/tests/browser.ini
@@ -1,14 +1,15 @@
[DEFAULT]
support-files =
head.js
privacypane_tests_perwindow.js
site_data_test.html
addons/set_homepage.xpi
+ addons/set_newtab.xpi
offline/offline.html
offline/manifest.appcache
[browser_applications_selection.js]
skip-if = os == 'linux' # bug 1382057
[browser_advanced_update.js]
skip-if = !updater
[browser_basic_rebuild_fonts_test.js]
@@ -40,16 +41,17 @@ skip-if = os != "win" || (os == "win" &&
[browser_checkspelling.js]
[browser_connection.js]
[browser_connection_bug388287.js]
[browser_cookies_exceptions.js]
[browser_defaultbrowser_alwayscheck.js]
[browser_healthreport.js]
skip-if = true || !healthreport # Bug 1185403 for the "true"
[browser_homepages_filter_aboutpreferences.js]
+[browser_extension_controlled.js]
[browser_layersacceleration.js]
[browser_masterpassword.js]
[browser_notifications_do_not_disturb.js]
[browser_password_management.js]
[browser_performance.js]
skip-if = !e10s
[browser_performance_e10srollout.js]
skip-if = !e10s
new file mode 100644
--- /dev/null
+++ b/browser/components/preferences/in-content/tests/browser_extension_controlled.js
@@ -0,0 +1,131 @@
+XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
+ "@mozilla.org/browser/aboutnewtab-service;1",
+ "nsIAboutNewTabService");
+
+const TEST_DIR = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
+const CHROME_URL_ROOT = TEST_DIR + "/";
+
+function getSupportsFile(path) {
+ let cr = Cc["@mozilla.org/chrome/chrome-registry;1"]
+ .getService(Ci.nsIChromeRegistry);
+ let uri = Services.io.newURI(CHROME_URL_ROOT + path);
+ let fileurl = cr.convertChromeURL(uri);
+ return fileurl.QueryInterface(Ci.nsIFileURL);
+}
+
+function installAddon(xpiName) {
+ let filePath = getSupportsFile(`addons/${xpiName}`).file;
+ return new Promise((resolve, reject) => {
+ AddonManager.getInstallForFile(filePath, install => {
+ if (!install) {
+ throw new Error(`An install was not created for ${filePath}`);
+ }
+ install.addListener({
+ onDownloadFailed: reject,
+ onDownloadCancelled: reject,
+ onInstallFailed: reject,
+ onInstallCancelled: reject,
+ onInstallEnded: resolve
+ });
+ install.install();
+ });
+ });
+}
+
+function waitForMessageChange(messageId, cb) {
+ return new Promise((resolve) => {
+ let target = gBrowser.contentDocument.getElementById(messageId);
+ let observer = new MutationObserver(() => {
+ if (cb(target)) {
+ observer.disconnect();
+ resolve();
+ }
+ });
+ observer.observe(target, { attributes: true, attributeFilter: ["hidden"] });
+ });
+}
+
+function waitForMessageHidden(messageId) {
+ return waitForMessageChange(messageId, target => target.hidden);
+}
+
+function waitForMessageShown(messageId) {
+ return waitForMessageChange(messageId, target => !target.hidden);
+}
+
+add_task(async function testExtensionControlledHomepage() {
+ await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
+ let doc = gBrowser.contentDocument;
+ is(gBrowser.currentURI.spec, "about:preferences#general",
+ "#general should be in the URI for about:preferences");
+ let homepagePref = () => Services.prefs.getCharPref("browser.startup.homepage");
+ let originalHomepagePref = homepagePref();
+ let extensionHomepage = "https://developer.mozilla.org/";
+ let controlledContent = doc.getElementById("browserHomePageExtensionContent");
+
+ // The homepage is set to the default and editable.
+ ok(originalHomepagePref != extensionHomepage, "homepage is empty by default");
+ is(doc.getElementById("browserHomePage").disabled, false, "The homepage input is enabled");
+ is(controlledContent.hidden, true, "The extension controlled row is hidden");
+
+ // Install an extension that will set the homepage.
+ await installAddon("set_homepage.xpi");
+ await waitForMessageShown("browserHomePageExtensionContent");
+
+ // The homepage has been set by the extension, the user is notified and it isn't editable.
+ let controlledLabel = controlledContent.querySelector("description");
+ is(homepagePref(), extensionHomepage, "homepage is set by extension");
+ // There are two spaces before "set_homepage" because it's " <image /> set_homepage".
+ is(controlledLabel.textContent, "An extension, set_homepage, controls your home page.",
+ "The user is notified that an extension is controlling the homepage");
+ is(controlledContent.hidden, false, "The extension controlled row is hidden");
+ is(doc.getElementById("browserHomePage").disabled, true, "The homepage input is disabled");
+
+ // Disable the extension.
+ doc.getElementById("disableHomePageExtension").click();
+
+ await waitForMessageHidden("browserHomePageExtensionContent");
+
+ is(homepagePref(), originalHomepagePref, "homepage is set back to default");
+ is(doc.getElementById("browserHomePage").disabled, false, "The homepage input is enabled");
+ is(controlledContent.hidden, true, "The extension controlled row is hidden");
+
+ await BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
+
+add_task(async function testExtensionControlledNewTab() {
+ await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
+ let doc = gBrowser.contentDocument;
+ is(gBrowser.currentURI.spec, "about:preferences#general",
+ "#general should be in the URI for about:preferences");
+
+ let controlledContent = doc.getElementById("browserNewTabExtensionContent");
+
+ // The new tab is set to the default and message is hidden.
+ ok(!aboutNewTabService.newTabURL.startsWith("moz-extension:"), "new tab is not set");
+ is(controlledContent.hidden, true, "The extension controlled row is hidden");
+
+ // Install an extension that will set the new tab page.
+ await installAddon("set_newtab.xpi");
+
+ await waitForMessageShown("browserNewTabExtensionContent");
+
+ // The new tab page has been set by the extension and the user is notified.
+ let controlledLabel = controlledContent.querySelector("description");
+ ok(aboutNewTabService.newTabURL.startsWith("moz-extension:"), "new tab url is set by extension");
+ // There are two spaces before "set_newtab" because it's " <image /> set_newtab".
+ is(controlledLabel.textContent, "An extension, set_newtab, controls your New Tab page.",
+ "The user is notified that an extension is controlling the new tab page");
+ is(controlledContent.hidden, false, "The extension controlled row is hidden");
+
+ // Disable the extension.
+ doc.getElementById("disableNewTabExtension").click();
+
+ await waitForMessageHidden("browserNewTabExtensionContent");
+
+ ok(!aboutNewTabService.newTabURL.startsWith("moz-extension:"), "new tab page is set back to default");
+ is(controlledContent.hidden, true, "The extension controlled row is hidden");
+
+ await BrowserTestUtils.removeTab(gBrowser.selectedTab);
+});
+
--- a/browser/components/preferences/in-content/tests/browser_homepages_filter_aboutpreferences.js
+++ b/browser/components/preferences/in-content/tests/browser_homepages_filter_aboutpreferences.js
@@ -13,99 +13,8 @@ add_task(async function testSetHomepageU
is(gBrowser.tabs.length, 3, "Three tabs should be open");
is(Services.prefs.getCharPref("browser.startup.homepage"), "about:blank|about:home",
"about:blank and about:home should be the only homepages set");
Services.prefs.setCharPref("browser.startup.homepage", oldHomepagePref);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
await BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
-
-const TEST_DIR = gTestPath.substr(0, gTestPath.lastIndexOf("/"));
-const CHROME_URL_ROOT = TEST_DIR + "/";
-
-function getSupportsFile(path) {
- let cr = Cc["@mozilla.org/chrome/chrome-registry;1"]
- .getService(Ci.nsIChromeRegistry);
- let uri = Services.io.newURI(CHROME_URL_ROOT + path);
- let fileurl = cr.convertChromeURL(uri);
- return fileurl.QueryInterface(Ci.nsIFileURL);
-}
-
-function installAddon() {
- let filePath = getSupportsFile("addons/set_homepage.xpi").file;
- return new Promise((resolve, reject) => {
- AddonManager.getInstallForFile(filePath, install => {
- if (!install) {
- throw new Error(`An install was not created for ${filePath}`);
- }
- install.addListener({
- onDownloadFailed: reject,
- onDownloadCancelled: reject,
- onInstallFailed: reject,
- onInstallCancelled: reject,
- onInstallEnded: resolve
- });
- install.install();
- });
- });
-}
-
-function waitForMessageChange(cb) {
- return new Promise((resolve) => {
- let target = gBrowser.contentDocument.getElementById("browserHomePageExtensionContent");
- let observer = new MutationObserver(() => {
- if (cb(target)) {
- observer.disconnect();
- resolve();
- }
- });
- observer.observe(target, { attributes: true, attributeFilter: ["hidden"] });
- });
-}
-
-function waitForMessageHidden() {
- return waitForMessageChange(target => target.hidden);
-}
-
-function waitForMessageShown() {
- return waitForMessageChange(target => !target.hidden);
-}
-
-add_task(async function testExtensionControlledHomepage() {
- await openPreferencesViaOpenPreferencesAPI("paneGeneral", {leaveOpen: true});
- let doc = gBrowser.contentDocument;
- is(gBrowser.currentURI.spec, "about:preferences#general",
- "#general should be in the URI for about:preferences");
- let homepagePref = () => Services.prefs.getCharPref("browser.startup.homepage");
- let originalHomepagePref = homepagePref();
- let extensionHomepage = "https://developer.mozilla.org/";
- let controlledContent = doc.getElementById("browserHomePageExtensionContent");
-
- // The homepage is set to the default and editable.
- ok(originalHomepagePref != extensionHomepage, "homepage is empty by default");
- is(doc.getElementById("browserHomePage").disabled, false, "The homepage input is enabled");
- is(controlledContent.hidden, true, "The extension controlled row is hidden");
-
- // Install an extension that will set the homepage.
- await installAddon();
- await waitForMessageShown();
-
- // The homepage has been set by the extension, the user is notified and it isn't editable.
- let controlledLabel = controlledContent.querySelector("description");
- is(homepagePref(), extensionHomepage, "homepage is set by extension");
- // There are two spaces before "set_homepage" because it's " <image /> set_homepage".
- is(controlledLabel.textContent, "An extension, set_homepage, controls your home page.",
- "The user is notified that an extension is controlling the homepage");
- is(controlledContent.hidden, false, "The extension controlled row is hidden");
- is(doc.getElementById("browserHomePage").disabled, true, "The homepage input is disabled");
-
- // Disable the extension.
- doc.getElementById("disableHomePageExtension").click();
-
- await waitForMessageHidden();
-
- is(homepagePref(), originalHomepagePref, "homepage is set back to default");
- is(doc.getElementById("browserHomePage").disabled, false, "The homepage input is enabled");
- is(controlledContent.hidden, true, "The extension controlled row is hidden");
-
- await BrowserTestUtils.removeTab(gBrowser.selectedTab);
-});
--- a/browser/locales/en-US/chrome/browser/preferences/preferences.properties
+++ b/browser/locales/en-US/chrome/browser/preferences/preferences.properties
@@ -277,12 +277,16 @@ searchResults.needHelp2=Need help? Visit
# LOCALIZATION NOTE %S is the default value of the `dom.ipc.processCount` pref.
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.newTabURL):
+# This string is shown to notify the user that their new tab page is being controlled by an extension.
+extensionControlled.newTabURL = An extension, %S, controls your New Tab 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.
\ No newline at end of file
+extensionControlled.privacy.containers = An extension, %S, requires Container Tabs.