Merge mozilla-central and ux
This commit is contained in:
@@ -1285,49 +1285,17 @@ BrowserGlue.prototype = {
|
||||
},
|
||||
|
||||
_migrateUI: function BG__migrateUI() {
|
||||
const UI_VERSION = 14;
|
||||
const UI_VERSION = 17;
|
||||
const BROWSER_DOCURL = "chrome://browser/content/browser.xul#";
|
||||
|
||||
let wasCustomizedAndOnAustralis = Services.prefs.prefHasUserValue("browser.uiCustomization.state");
|
||||
let currentUIVersion = 0;
|
||||
try {
|
||||
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
|
||||
} catch(ex) {}
|
||||
if (!wasCustomizedAndOnAustralis && currentUIVersion >= UI_VERSION)
|
||||
if (currentUIVersion >= UI_VERSION)
|
||||
return;
|
||||
|
||||
this._rdf = Cc["@mozilla.org/rdf/rdf-service;1"].getService(Ci.nsIRDFService);
|
||||
this._dataSource = this._rdf.GetDataSource("rdf:local-store");
|
||||
|
||||
// No version check for this as this code should run until we have Australis everywhere:
|
||||
if (wasCustomizedAndOnAustralis) {
|
||||
// This profile's been on australis! If it's missing the back/fwd button
|
||||
// or go/stop/reload button, then put them back:
|
||||
let currentsetResource = this._rdf.GetResource("currentset");
|
||||
let toolbarResource = this._rdf.GetResource(BROWSER_DOCURL + "nav-bar");
|
||||
let currentset = this._getPersist(toolbarResource, currentsetResource);
|
||||
if (currentset.indexOf("unified-back-forward-button") == -1) {
|
||||
currentset = currentset.replace("urlbar-container",
|
||||
"unified-back-forward-button,urlbar-container");
|
||||
}
|
||||
if (currentset.indexOf("reload-button") == -1) {
|
||||
currentset = currentset.replace("urlbar-container", "urlbar-container,reload-button");
|
||||
}
|
||||
if (currentset.indexOf("stop-button") == -1) {
|
||||
currentset = currentset.replace("reload-button", "reload-button,stop-button");
|
||||
}
|
||||
this._setPersist(toolbarResource, currentsetResource, currentset);
|
||||
Services.prefs.clearUserPref("browser.uiCustomization.state");
|
||||
|
||||
// If we don't have anything else to do, we can bail here:
|
||||
if (currentUIVersion >= UI_VERSION) {
|
||||
delete this._rdf;
|
||||
delete this._dataSource;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this._dirty = false;
|
||||
|
||||
if (currentUIVersion < 2) {
|
||||
@@ -1511,6 +1479,60 @@ BrowserGlue.prototype = {
|
||||
OS.File.remove(path);
|
||||
}
|
||||
|
||||
if (currentUIVersion < 15) {
|
||||
// Migrate users from text or text&icons mode to icons mode.
|
||||
let updateToolbars = function (aToolbarIds, aResourceName, aResourceValue) {
|
||||
let resource = this._rdf.GetResource(aResourceName);
|
||||
for (toolbarId of aToolbarIds) {
|
||||
let toolbar = this._rdf.GetResource(BROWSER_DOCURL + toolbarId);
|
||||
let oldValue = this._getPersist(toolbar, resource);
|
||||
if (oldValue && oldValue != aResourceValue) {
|
||||
this._setPersist(toolbar, resource, aResourceValue);
|
||||
}
|
||||
}
|
||||
}.bind(this);
|
||||
|
||||
updateToolbars(["navigator-toolbox", "nav-bar", "PersonalToolbar", "addon-bar"], "mode", "icons");
|
||||
// Exclude PersonalToolbar and addon-bar since they have lockiconsize="true".
|
||||
updateToolbars(["navigator-toolbox", "nav-bar"], "iconsize", "large");
|
||||
}
|
||||
|
||||
if (currentUIVersion < 16) {
|
||||
let toolbarResource = this._rdf.GetResource(BROWSER_DOCURL + "nav-bar");
|
||||
let collapsedResource = this._rdf.GetResource("collapsed");
|
||||
let isCollapsed = this._getPersist(toolbarResource, collapsedResource);
|
||||
if (isCollapsed == "true") {
|
||||
this._setPersist(toolbarResource, collapsedResource, "false");
|
||||
}
|
||||
}
|
||||
|
||||
// Insert the bookmarks-menu-button into the nav-bar if it isn't already
|
||||
// there.
|
||||
if (currentUIVersion < 17) {
|
||||
let currentsetResource = this._rdf.GetResource("currentset");
|
||||
let toolbarResource = this._rdf.GetResource(BROWSER_DOCURL + "nav-bar");
|
||||
let currentset = this._getPersist(toolbarResource, currentsetResource);
|
||||
// Need to migrate only if toolbar is customized.
|
||||
if (currentset) {
|
||||
if (!currentset.contains("bookmarks-menu-button")) {
|
||||
// The button isn't in the nav-bar, so let's look for an appropriate
|
||||
// place to put it.
|
||||
if (currentset.contains("downloads-button")) {
|
||||
currentset = currentset.replace(/(^|,)downloads-button($|,)/,
|
||||
"$1bookmarks-menu-button,downloads-button$2");
|
||||
} else if (currentset.contains("home-button")) {
|
||||
currentset = currentset.replace(/(^|,)home-button($|,)/,
|
||||
"$1bookmarks-menu-button,home-button$2");
|
||||
} else {
|
||||
// Just append.
|
||||
currentset = currentset.replace(/(^|,)window-controls($|,)/,
|
||||
"$1bookmarks-menu-button,window-controls$2")
|
||||
}
|
||||
this._setPersist(toolbarResource, currentsetResource, currentset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (this._dirty)
|
||||
this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user