Commit ceacf0fd authored by Kirk Steuber's avatar Kirk Steuber
Browse files

Bug 1429120 - Add enterprise policy to display the bookmarks toolbar by default r=Felipe,Gijs

MozReview-Commit-ID: EZTAXdd9rN1

--HG--
extra : rebase_source : 6ba88ff989f6188aec285b31704bad4cde59ec71
parent 43797dba
......@@ -18,6 +18,7 @@ XPCOMUtils.defineLazyServiceGetter(this, "gXulStore",
const PREF_LOGLEVEL = "browser.policies.loglevel";
const PREF_MENU_ALREADY_DISPLAYED = "browser.policies.menuBarWasDisplayed";
const BROWSER_DOCUMENT_URL = "chrome://browser/content/browser.xul";
const PREF_BOOKMARKS_ALREADY_DISPLAYED = "browser.policies.bookmarkBarWasDisplayed";
XPCOMUtils.defineLazyGetter(this, "log", () => {
let { ConsoleAPI } = Cu.import("resource://gre/modules/Console.jsm", {});
......@@ -58,6 +59,23 @@ this.Policies = {
}
},
"display_bookmarks_toolbar": {
onBeforeUIStartup(manager, param) {
if (param == true) {
// This policy is meant to change the default behavior, not to force it.
// If this policy was alreay applied and the user chose to re-hide the
// bookmarks toolbar, do not show it again.
if (!Services.prefs.getBoolPref(PREF_BOOKMARKS_ALREADY_DISPLAYED, false)) {
log.debug("Showing the bookmarks toolbar");
gXulStore.setValue(BROWSER_DOCUMENT_URL, "PersonalToolbar", "collapsed", "false");
Services.prefs.setBoolPref(PREF_BOOKMARKS_ALREADY_DISPLAYED, true);
} else {
log.debug("Not showing the bookmarks toolbar because it has already been shown.");
}
}
}
},
"dont_check_default_browser": {
onBeforeUIStartup(manager, param) {
setAndLockPref("browser.shell.checkDefaultBrowser", false);
......
......@@ -18,6 +18,14 @@
"enum": [true]
},
"display_bookmarks_toolbar": {
"description": "Causes the bookmarks toolbar to be displayed by default.",
"first_available": "60.0",
"type": "boolean",
"enum": [true]
},
"dont_check_default_browser": {
"description": "Don't check for the default browser on startup.",
"first_available": "60.0",
......
......@@ -9,6 +9,7 @@ support-files =
config_simple_policies.json
config_broken_json.json
config_display_menu.json
config_display_bookmarks.json
[browser_policies_broken_json.js]
[browser_policies_popups_cookies_addons_flash.js]
......@@ -17,3 +18,4 @@ support-files =
[browser_policies_validate_and_parse_API.js]
[browser_policy_default_browser_check.js]
[browser_policy_display_menu.js]
[browser_policy_display_bookmarks.js]
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function setup() {
await setupPolicyEngineWithJson("config_display_bookmarks.json");
});
add_task(async function test_menu_shown() {
// Since testing will apply the policy after the browser has already started,
// we will need to open a new window to actually see the toolbar
let newWin = await BrowserTestUtils.openNewBrowserWindow();
let menuBar = newWin.document.getElementById("PersonalToolbar");
is(menuBar.getAttribute("collapsed"), "false",
"The bookmarks toolbar should not be hidden");
await BrowserTestUtils.closeWindow(newWin);
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment