diff --git a/browser/components/enterprisepolicies/Policies.jsm b/browser/components/enterprisepolicies/Policies.jsm index 53378c41171e..fc1f67666ed4 100644 --- a/browser/components/enterprisepolicies/Policies.jsm +++ b/browser/components/enterprisepolicies/Policies.jsm @@ -291,6 +291,15 @@ var Policies = { } }, + "DisableProfileImport": { + onBeforeUIStartup(manager, param) { + if (param) { + manager.disallowFeature("profileImport"); + setAndLockPref("browser.newtabpage.activity-stream.migrationExpired", true); + } + } + }, + "DisableProfileRefresh": { onBeforeUIStartup(manager, param) { if (param) { diff --git a/browser/components/enterprisepolicies/schemas/policies-schema.json b/browser/components/enterprisepolicies/schemas/policies-schema.json index a30062cad019..21f12b2faa69 100644 --- a/browser/components/enterprisepolicies/schemas/policies-schema.json +++ b/browser/components/enterprisepolicies/schemas/policies-schema.json @@ -234,6 +234,13 @@ "type": "boolean" }, + "DisableProfileImport": { + "description": "Disables the Firefox \"Import data from another browser\" button", + "first_available": "60.0", + + "type": "boolean" + }, + "DisableProfileRefresh": { "description": "Disables the \"Refresh Firefox\" button in about:support", "first_available": "60.0", diff --git a/browser/components/enterprisepolicies/tests/browser/browser.ini b/browser/components/enterprisepolicies/tests/browser/browser.ini index 46769f15cbd4..af7b343eb8a9 100644 --- a/browser/components/enterprisepolicies/tests/browser/browser.ini +++ b/browser/components/enterprisepolicies/tests/browser/browser.ini @@ -38,6 +38,7 @@ support-files = [browser_policy_disable_popup_blocker.js] [browser_policy_disable_privatebrowsing.js] [browser_policy_disable_profile_reset.js] +[browser_policy_disable_profile_import.js] [browser_policy_disable_safemode.js] [browser_policy_disable_shield.js] [browser_policy_disable_telemetry.js] diff --git a/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_profile_import.js b/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_profile_import.js new file mode 100644 index 000000000000..bd59bb492842 --- /dev/null +++ b/browser/components/enterprisepolicies/tests/browser/browser_policy_disable_profile_import.js @@ -0,0 +1,36 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ +"use strict"; + +async function openLibrary() { + return new Promise(resolve => { + let library = window.openDialog("chrome://browser/content/places/places.xul", "", + "chrome,toolbar=yes,dialog=no,resizable"); + waitForFocus(() => resolve(library), library); + }); +} + +add_task(async function test_disable_profile_import() { + await setupPolicyEngineWithJson({ + "policies": { + "DisableProfileImport": true + } + }); + let library = await openLibrary(); + + let menu = library.document.getElementById("maintenanceButtonPopup"); + let promisePopupShown = BrowserTestUtils.waitForEvent(menu, "popupshown"); + menu.openPopup(); + await promisePopupShown; + + let profileImportButton = library.document.getElementById("browserImport"); + is(profileImportButton.disabled, true, "Profile Import button should be disabled"); + + let promisePopupHidden = BrowserTestUtils.waitForEvent(menu, "popuphidden"); + menu.hidePopup(); + await promisePopupHidden; + + await BrowserTestUtils.closeWindow(library); + + checkLockedPref("browser.newtabpage.activity-stream.migrationExpired", true); +}); diff --git a/browser/components/places/content/places.js b/browser/components/places/content/places.js index 822e3006644d..160540e4d0c6 100644 --- a/browser/components/places/content/places.js +++ b/browser/components/places/content/places.js @@ -189,6 +189,10 @@ var PlacesOrganizer = { document.getElementById("placesContext") .removeChild(document.getElementById("placesContext_show:info")); + if (!Services.policies.isAllowed("profileImport")) { + document.getElementById("OrganizerCommand_browserImport").setAttribute("disabled", true); + } + ContentArea.focus(); },