Create a default profile for other channels, if Aurora is the first channel installed on a system (bug 1090967). r=bsmedberg,felipe

--HG--
extra : rebase_source : 3d4ed008171a3dd156d691d235d4b03b2c98d931
This commit is contained in:
Panos Astithas 2014-11-05 20:21:42 +02:00
parent d5e20d5c1a
commit 3ca75d4403

View File

@ -856,6 +856,10 @@ BrowserGlue.prototype = {
// All initial windows have opened. // All initial windows have opened.
_onWindowsRestored: function BG__onWindowsRestored() { _onWindowsRestored: function BG__onWindowsRestored() {
#ifdef MOZ_DEV_EDITION
this._createExtraDefaultProfile();
#endif
this._initServiceDiscovery(); this._initServiceDiscovery();
// Show update notification, if needed. // Show update notification, if needed.
@ -927,6 +931,39 @@ BrowserGlue.prototype = {
#endif #endif
}, },
#ifdef MOZ_DEV_EDITION
_createExtraDefaultProfile: function () {
// If Developer Edition is the only installed Firefox version and no other
// profiles are present, create a second one for use by other versions.
// This helps Firefox versions earlier than 35 avoid accidentally using the
// unsuitable Developer Edition profile.
let profileService = Cc["@mozilla.org/toolkit/profile-service;1"]
.getService(Ci.nsIToolkitProfileService);
let profileCount = profileService.profileCount;
if (profileCount == 1 && profileService.selectedProfile.name != "default") {
let newProfile;
try {
newProfile = profileService.createProfile(null, "default");
profileService.defaultProfile = newProfile;
profileService.flush();
} catch (e) {
Cu.reportError("Could not create profile 'default': " + e);
}
if (newProfile) {
// We don't want a default profile with Developer Edition settings, an
// empty profile directory will do. The profile service of the other
// Firefox will populate it with its own stuff.
let newProfilePath = newProfile.rootDir.path;
OS.File.removeDir(newProfilePath).then(() => {
return OS.File.makeDir(newProfilePath);
}).then(null, e => {
Cu.reportError("Could not empty profile 'default': " + e);
});
}
}
},
#endif
_onQuitRequest: function BG__onQuitRequest(aCancelQuit, aQuitType) { _onQuitRequest: function BG__onQuitRequest(aCancelQuit, aQuitType) {
// If user has already dismissed quit request, then do nothing // If user has already dismissed quit request, then do nothing
if ((aCancelQuit instanceof Ci.nsISupportsPRBool) && aCancelQuit.data) if ((aCancelQuit instanceof Ci.nsISupportsPRBool) && aCancelQuit.data)