Bug 1086936 part 1 - Add a UI switch to disable custom profile selection process in Aurora. r=bsmedberg,jaws f=matej,shorlander

--HG--
extra : rebase_source : ca599ad502e6975ae02ce9884cc207bf1ac62168
This commit is contained in:
Panos Astithas 2014-10-27 20:52:20 +02:00
parent dd7303f291
commit 3ac61e6080
11 changed files with 230 additions and 10 deletions

View File

@ -97,6 +97,19 @@ var gMainPane = {
e10sCheckbox.checked = e10sPref.value || e10sTempPref.value;
#endif
#ifdef MOZ_DEV_EDITION
Cu.import("resource://gre/modules/osfile.jsm");
let uAppData = OS.Constants.Path.userApplicationDataDir;
let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
setEventListener("separateProfileMode", "command", gMainPane.separateProfileModeChange);
let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
setEventListener("getStarted", "click", gMainPane.onGetStarted);
OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false,
() => separateProfileModeCheckbox.checked = true);
#endif
// Notify observers that the UI is now ready
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
@ -154,6 +167,66 @@ var gMainPane = {
},
#endif
#ifdef MOZ_DEV_EDITION
separateProfileModeChange: function ()
{
function quitApp() {
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
}
function revertCheckbox(error) {
separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;
if (error) {
Cu.reportError("Failed to toggle separate profile mode: " + error);
}
}
const Cc = Components.classes, Ci = Components.interfaces;
let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
let brandName = document.getElementById("bundleBrand").getString("brandShortName");
let bundle = document.getElementById("bundlePreferences");
let msg = bundle.getFormattedString(separateProfileModeCheckbox.checked ?
"featureEnableRequiresRestart" : "featureDisableRequiresRestart",
[brandName]);
let title = bundle.getFormattedString("shouldRestartTitle", [brandName]);
let shouldProceed = Services.prompt.confirm(window, title, msg)
if (shouldProceed) {
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
.createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
"restart");
shouldProceed = !cancelQuit.data;
if (shouldProceed) {
Cu.import("resource://gre/modules/osfile.jsm");
let uAppData = OS.Constants.Path.userApplicationDataDir;
let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
if (separateProfileModeCheckbox.checked) {
OS.File.remove(ignoreSeparateProfile).then(quitApp, revertCheckbox);
} else {
OS.File.writeAtomic(ignoreSeparateProfile, new Uint8Array()).then(quitApp, revertCheckbox);
}
return;
}
}
// Revert the checkbox in case we didn't quit
revertCheckbox();
},
onGetStarted: function (aEvent) {
const Cc = Components.classes, Ci = Components.interfaces;
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let win = wm.getMostRecentWindow("navigator:browser");
if (win) {
let accountsTab = win.gBrowser.addTab("about:accounts?action=migrateToDevEdition");
win.gBrowser.selectedTab = accountsTab;
}
},
#endif
// HOME PAGE
/*

View File

@ -117,6 +117,17 @@
hidden="true">
<caption><label>&startup.label;</label></caption>
#ifdef MOZ_DEV_EDITION
<vbox id="separateProfileBox">
<checkbox id="separateProfileMode"
label="&separateProfileMode.label;"/>
<hbox align="center" class="indent">
<label id="useFirefoxSync">&useFirefoxSync.label;</label>
<label id="getStarted" class="text-link">&getStarted.label;</label>
</hbox>
</vbox>
#endif
#ifdef E10S_TESTING_ONLY
<checkbox id="e10sAutoStart"
label="Enable E10S (multi-process)"/>
@ -126,13 +137,13 @@
<vbox id="defaultBrowserBox">
<hbox align="center">
<checkbox id="alwaysCheckDefault" preference="browser.shell.checkDefaultBrowser"
label="&alwaysCheckDefault.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>
label="&alwaysCheckDefault2.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>
</hbox>
<deck id="setDefaultPane">
<hbox align="center" class="indent">
<label id="isNotDefaultLabel" flex="1">&isNotDefault.label;</label>
<button id="setDefaultButton"
label="&setAsMyDefaultBrowser.label;" accesskey="&setAsMyDefaultBrowser.accesskey;"
label="&setAsMyDefaultBrowser2.label;" accesskey="&setAsMyDefaultBrowser2.accesskey;"
preference="pref.general.disable_button.default_browser"/>
</hbox>
<hbox align="center" class="indent">

View File

@ -60,12 +60,87 @@ var gMainPane = {
this.updateBrowserStartupLastSession();
#ifdef MOZ_DEV_EDITION
let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
let listener = gMainPane.separateProfileModeChange.bind(gMainPane);
separateProfileModeCheckbox.addEventListener("command", listener);
let getStartedLink = document.getElementById("getStarted");
let syncListener = gMainPane.onGetStarted.bind(gMainPane);
getStartedLink.addEventListener("click", syncListener);
Cu.import("resource://gre/modules/osfile.jsm");
let uAppData = OS.Constants.Path.userApplicationDataDir;
let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
OS.File.stat(ignoreSeparateProfile).then(() => separateProfileModeCheckbox.checked = false,
() => separateProfileModeCheckbox.checked = true);
#endif
// Notify observers that the UI is now ready
Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService)
.notifyObservers(window, "main-pane-loaded", null);
},
#ifdef MOZ_DEV_EDITION
separateProfileModeChange: function ()
{
function quitApp() {
Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
}
function revertCheckbox(error) {
separateProfileModeCheckbox.checked = !separateProfileModeCheckbox.checked;
if (error) {
Cu.reportError("Failed to toggle separate profile mode: " + error);
}
}
let separateProfileModeCheckbox = document.getElementById("separateProfileMode");
let brandName = document.getElementById("bundleBrand").getString("brandShortName");
let bundle = document.getElementById("bundlePreferences");
let msg = bundle.getFormattedString(separateProfileModeCheckbox.checked ?
"featureEnableRequiresRestart" : "featureDisableRequiresRestart",
[brandName]);
let title = bundle.getFormattedString("shouldRestartTitle", [brandName]);
let shouldProceed = Services.prompt.confirm(window, title, msg)
if (shouldProceed) {
let cancelQuit = Cc["@mozilla.org/supports-PRBool;1"]
.createInstance(Ci.nsISupportsPRBool);
Services.obs.notifyObservers(cancelQuit, "quit-application-requested",
"restart");
shouldProceed = !cancelQuit.data;
if (shouldProceed) {
Cu.import("resource://gre/modules/osfile.jsm");
let uAppData = OS.Constants.Path.userApplicationDataDir;
let ignoreSeparateProfile = OS.Path.join(uAppData, "ignore-dev-edition-profile");
if (separateProfileModeCheckbox.checked) {
OS.File.remove(ignoreSeparateProfile).then(quitApp, revertCheckbox);
} else {
OS.File.writeAtomic(ignoreSeparateProfile, new Uint8Array()).then(quitApp, revertCheckbox);
}
}
}
// Revert the checkbox in case we didn't quit
revertCheckbox();
},
onGetStarted: function (aEvent) {
const Cc = Components.classes, Ci = Components.interfaces;
let wm = Cc["@mozilla.org/appshell/window-mediator;1"]
.getService(Ci.nsIWindowMediator);
let win = wm.getMostRecentWindow("navigator:browser");
if (win) {
let accountsTab = win.gBrowser.addTab("about:accounts?action=migrateToDevEdition");
win.gBrowser.selectedTab = accountsTab;
}
},
#endif
// HOME PAGE
/*

View File

@ -77,17 +77,28 @@
<groupbox id="startupGroup">
<caption label="&startup.label;"/>
#ifdef MOZ_DEV_EDITION
<vbox id="separateProfileBox">
<checkbox id="separateProfileMode"
label="&separateProfileMode.label;"/>
<hbox align="center" class="indent">
<label id="useFirefoxSync">&useFirefoxSync.label;</label>
<label id="getStarted" class="text-link">&getStarted.label;</label>
</hbox>
</vbox>
#endif
#ifdef HAVE_SHELL_SERVICE
<vbox id="defaultBrowserBox">
<hbox align="center">
<checkbox id="alwaysCheckDefault" preference="browser.shell.checkDefaultBrowser"
label="&alwaysCheckDefault.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>
label="&alwaysCheckDefault2.label;" accesskey="&alwaysCheckDefault2.accesskey;"/>
</hbox>
<deck id="setDefaultPane">
<hbox align="center" class="indent">
<label id="isNotDefaultLabel" flex="1">&isNotDefault.label;</label>
<button id="setDefaultButton"
label="&setAsMyDefaultBrowser.label;" accesskey="&setAsMyDefaultBrowser.accesskey;"
label="&setAsMyDefaultBrowser2.label;" accesskey="&setAsMyDefaultBrowser2.accesskey;"
oncommand="gMainPane.setDefaultBrowser();"
preference="pref.general.disable_button.default_browser"/>
</hbox>

View File

@ -31,10 +31,13 @@
<!ENTITY alwaysAsk.label "Always ask me where to save files">
<!ENTITY alwaysAsk.accesskey "A">
<!ENTITY alwaysCheckDefault.label "Always check to see if &brandShortName; is the default browser on startup">
<!ENTITY alwaysCheckDefault2.label "Always check if &brandShortName; is your default browser">
<!ENTITY alwaysCheckDefault2.accesskey "w">
<!ENTITY setAsMyDefaultBrowser.label "Make &brandShortName; My Default Browser">
<!ENTITY setAsMyDefaultBrowser.accesskey "D">
<!ENTITY setAsMyDefaultBrowser2.label "Make Default">
<!ENTITY setAsMyDefaultBrowser2.accesskey "D">
<!ENTITY isDefault.label "&brandShortName; is currently your default browser">
<!ENTITY isNotDefault.label "&brandShortName; is not your default browser">
<!ENTITY separateProfileMode.label "Allow &brandShortName; and Firefox to run at the same time">
<!ENTITY useFirefoxSync.label "Tip: This uses separate profiles. Use Sync to share data between them.">
<!ENTITY getStarted.label "Start using Sync…">

View File

@ -55,6 +55,11 @@ label.small {
}
/* General Pane */
#useFirefoxSync,
#getStarted {
font-size: 90%;
}
#isNotDefaultLabel {
font-weight: bold;
}

View File

@ -169,6 +169,11 @@ caption {
/* General Pane */
#useFirefoxSync,
#getStarted {
font-size: 90%;
}
#isNotDefaultLabel {
font-weight: bold;
}

View File

@ -110,6 +110,15 @@ treecol {
/* General Pane */
#useFirefoxSync {
font-size: 90%;
-moz-margin-end: 8px !important;
}
#getStarted {
font-size: 90%;
}
#isNotDefaultLabel {
font-weight: bold;
}

View File

@ -55,6 +55,11 @@ label.small {
/* General Pane */
#useFirefoxSync,
#getStarted {
font-size: 90%;
}
#isNotDefaultLabel {
font-weight: bold;
}

View File

@ -29,6 +29,12 @@ interface nsIToolkitProfileService : nsISupports
* browser if no other profile is specified at runtime). This is the profile
* marked with Default=1 in profiles.ini and is usually the same as
* selectedProfile, except on Developer Edition.
*
* Developer Edition uses a profile named "dev-edition-default" as the
* default profile (which it creates if it doesn't exist), unless a special
* empty file named "ignore-dev-edition-profile" is present next to
* profiles.ini. In that case Developer Edition behaves the same as any
* other build of Firefox.
*/
attribute nsIToolkitProfile defaultProfile;

View File

@ -424,6 +424,22 @@ nsToolkitProfileService::Init()
nsToolkitProfile* currentProfile = nullptr;
#ifdef MOZ_DEV_EDITION
nsCOMPtr<nsIFile> ignoreSeparateProfile;
rv = mAppData->Clone(getter_AddRefs(ignoreSeparateProfile));
if (NS_FAILED(rv))
return rv;
rv = ignoreSeparateProfile->AppendNative(NS_LITERAL_CSTRING("ignore-dev-edition-profile"));
if (NS_FAILED(rv))
return rv;
bool shouldIgnoreSeparateProfile;
rv = ignoreSeparateProfile->Exists(&shouldIgnoreSeparateProfile);
if (NS_FAILED(rv))
return rv;
#endif
unsigned int c = 0;
bool foundAuroraDefault = false;
for (c = 0; true; ++c) {
@ -485,8 +501,9 @@ nsToolkitProfileService::Init()
this->SetDefaultProfile(currentProfile);
}
#ifdef MOZ_DEV_EDITION
// Use the dev-edition-default profile if this is an Aurora build.
if (name.EqualsLiteral("dev-edition-default")) {
// Use the dev-edition-default profile if this is an Aurora build and
// ignore-dev-edition-profile is not present.
if (name.EqualsLiteral("dev-edition-default") && !shouldIgnoreSeparateProfile) {
mChosen = currentProfile;
foundAuroraDefault = true;
}
@ -498,7 +515,7 @@ nsToolkitProfileService::Init()
// on webapprt.
bool isFirefox = strcmp(gAppData->ID,
"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}") == 0;
if (!foundAuroraDefault && isFirefox) {
if (!foundAuroraDefault && isFirefox && !shouldIgnoreSeparateProfile) {
// If a single profile exists, it may not be already marked as default.
// Do it now to avoid problems when we create the dev-edition-default profile.
if (!mChosen && mFirst && !mFirst->mNext)