mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
[Pale-Moon] Issue #1737 - Part 7: Tidy components/*.js
This commit is contained in:
parent
94e0c368a5
commit
500d51dfc4
4 changed files with 467 additions and 401 deletions
|
|
@ -17,22 +17,23 @@ XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
|
|||
"resource://gre/modules/PlacesUtils.jsm");
|
||||
|
||||
this.DistributionCustomizer = function DistributionCustomizer() {
|
||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
|
||||
getService(Ci.nsIProperties);
|
||||
let dirSvc = Cc["@mozilla.org/file/directory_service;1"]
|
||||
.getService(Ci.nsIProperties);
|
||||
let iniFile = dirSvc.get("XREExeF", Ci.nsIFile);
|
||||
iniFile.leafName = "distribution";
|
||||
iniFile.append("distribution.ini");
|
||||
if (iniFile.exists())
|
||||
if (iniFile.exists()) {
|
||||
this._iniFile = iniFile;
|
||||
}
|
||||
}
|
||||
|
||||
DistributionCustomizer.prototype = {
|
||||
_iniFile: null,
|
||||
|
||||
get _ini() {
|
||||
let ini = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
|
||||
getService(Ci.nsIINIParserFactory).
|
||||
createINIParser(this._iniFile);
|
||||
let ini = Cc["@mozilla.org/xpcom/ini-parser-factory;1"]
|
||||
.getService(Ci.nsIINIParserFactory)
|
||||
.createINIParser(this._iniFile);
|
||||
this.__defineGetter__("_ini", function() ini);
|
||||
return this._ini;
|
||||
},
|
||||
|
|
@ -44,8 +45,8 @@ DistributionCustomizer.prototype = {
|
|||
},
|
||||
|
||||
get _prefSvc() {
|
||||
let svc = Cc["@mozilla.org/preferences-service;1"].
|
||||
getService(Ci.nsIPrefService);
|
||||
let svc = Cc["@mozilla.org/preferences-service;1"]
|
||||
.getService(Ci.nsIPrefService);
|
||||
this.__defineGetter__("_prefSvc", function() svc);
|
||||
return this._prefSvc;
|
||||
},
|
||||
|
|
@ -57,8 +58,8 @@ DistributionCustomizer.prototype = {
|
|||
},
|
||||
|
||||
get _ioSvc() {
|
||||
let svc = Cc["@mozilla.org/network/io-service;1"].
|
||||
getService(Ci.nsIIOService);
|
||||
let svc = Cc["@mozilla.org/network/io-service;1"]
|
||||
.getService(Ci.nsIIOService);
|
||||
this.__defineGetter__("_ioSvc", function() svc);
|
||||
return this._ioSvc;
|
||||
},
|
||||
|
|
@ -70,11 +71,12 @@ DistributionCustomizer.prototype = {
|
|||
_parseBookmarksSection:
|
||||
function(parentId, section) {
|
||||
let keys = [];
|
||||
for (let i in enumerate(this._ini.getKeys(section)))
|
||||
for (let i in enumerate(this._ini.getKeys(section))) {
|
||||
keys.push(i);
|
||||
}
|
||||
keys.sort();
|
||||
|
||||
let items = {};
|
||||
let items = { };
|
||||
let defaultItemId = -1;
|
||||
let maxItemId = -1;
|
||||
|
||||
|
|
@ -84,11 +86,13 @@ DistributionCustomizer.prototype = {
|
|||
let [foo, iid, iprop, ilocale] = m;
|
||||
iid = parseInt(iid);
|
||||
|
||||
if (ilocale)
|
||||
if (ilocale) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!items[iid])
|
||||
items[iid] = {};
|
||||
if (!items[iid]) {
|
||||
items[iid] = { };
|
||||
}
|
||||
if (keys.indexOf(keys[i] + "." + this._locale) >= 0) {
|
||||
items[iid][iprop] = this._ini.getString(section, keys[i] + "." +
|
||||
this._locale);
|
||||
|
|
@ -96,11 +100,13 @@ DistributionCustomizer.prototype = {
|
|||
items[iid][iprop] = this._ini.getString(section, keys[i]);
|
||||
}
|
||||
|
||||
if (iprop == "type" && items[iid]["type"] == "default")
|
||||
if (iprop == "type" && items[iid]["type"] == "default") {
|
||||
defaultItemId = iid;
|
||||
}
|
||||
|
||||
if (maxItemId < iid)
|
||||
if (maxItemId < iid) {
|
||||
maxItemId = iid;
|
||||
}
|
||||
} else {
|
||||
dump("Key did not match: " + keys[i] + "\n");
|
||||
}
|
||||
|
|
@ -108,70 +114,76 @@ DistributionCustomizer.prototype = {
|
|||
|
||||
let prependIndex = 0;
|
||||
for (let iid = 0; iid <= maxItemId; iid++) {
|
||||
if (!items[iid])
|
||||
if (!items[iid]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
let index = PlacesUtils.bookmarks.DEFAULT_INDEX;
|
||||
let newId;
|
||||
|
||||
switch (items[iid]["type"]) {
|
||||
case "default":
|
||||
break;
|
||||
case "default":
|
||||
break;
|
||||
|
||||
case "folder":
|
||||
if (iid < defaultItemId)
|
||||
index = prependIndex++;
|
||||
case "folder":
|
||||
if (iid < defaultItemId) {
|
||||
index = prependIndex++;
|
||||
}
|
||||
|
||||
newId = PlacesUtils.bookmarks.createFolder(parentId,
|
||||
items[iid]["title"],
|
||||
index);
|
||||
newId = PlacesUtils.bookmarks.createFolder(parentId,
|
||||
items[iid]["title"],
|
||||
index);
|
||||
|
||||
this._parseBookmarksSection(newId, "BookmarksFolder-" +
|
||||
items[iid]["folderId"]);
|
||||
this._parseBookmarksSection(newId, "BookmarksFolder-" +
|
||||
items[iid]["folderId"]);
|
||||
|
||||
if (items[iid]["description"])
|
||||
PlacesUtils.annotations.setItemAnnotation(newId,
|
||||
"bookmarkProperties/description",
|
||||
items[iid]["description"], 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
if (items[iid]["description"])
|
||||
PlacesUtils.annotations.setItemAnnotation(newId,
|
||||
"bookmarkProperties/description",
|
||||
items[iid]["description"], 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
|
||||
break;
|
||||
break;
|
||||
|
||||
case "separator":
|
||||
if (iid < defaultItemId)
|
||||
index = prependIndex++;
|
||||
PlacesUtils.bookmarks.insertSeparator(parentId, index);
|
||||
break;
|
||||
case "separator":
|
||||
if (iid < defaultItemId) {
|
||||
index = prependIndex++;
|
||||
}
|
||||
PlacesUtils.bookmarks.insertSeparator(parentId, index);
|
||||
break;
|
||||
|
||||
case "livemark":
|
||||
if (iid < defaultItemId)
|
||||
index = prependIndex++;
|
||||
case "livemark":
|
||||
if (iid < defaultItemId) {
|
||||
index = prependIndex++;
|
||||
}
|
||||
|
||||
// Don't bother updating the livemark contents on creation.
|
||||
PlacesUtils.livemarks.addLivemark({ title: items[iid]["title"]
|
||||
, parentId: parentId
|
||||
, index: index
|
||||
, feedURI: this._makeURI(items[iid]["feedLink"])
|
||||
, siteURI: this._makeURI(items[iid]["siteLink"])
|
||||
}).then(null, Cu.reportError);
|
||||
break;
|
||||
// Don't bother updating the livemark contents on creation.
|
||||
PlacesUtils.livemarks.addLivemark({ title: items[iid]["title"],
|
||||
parentId: parentId,
|
||||
index: index,
|
||||
feedURI: this._makeURI(items[iid]["feedLink"]),
|
||||
siteURI: this._makeURI(items[iid]["siteLink"])
|
||||
}).then(null, Cu.reportError);
|
||||
break;
|
||||
|
||||
case "bookmark":
|
||||
default:
|
||||
if (iid < defaultItemId)
|
||||
index = prependIndex++;
|
||||
case "bookmark":
|
||||
// Fallthrough
|
||||
default:
|
||||
if (iid < defaultItemId) {
|
||||
index = prependIndex++;
|
||||
}
|
||||
|
||||
newId = PlacesUtils.bookmarks.insertBookmark(parentId,
|
||||
this._makeURI(items[iid]["link"]),
|
||||
index, items[iid]["title"]);
|
||||
newId = PlacesUtils.bookmarks.insertBookmark(parentId,
|
||||
this._makeURI(items[iid]["link"]),
|
||||
index, items[iid]["title"]);
|
||||
|
||||
if (items[iid]["description"])
|
||||
PlacesUtils.annotations.setItemAnnotation(newId,
|
||||
"bookmarkProperties/description",
|
||||
items[iid]["description"], 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
if (items[iid]["description"]) {
|
||||
PlacesUtils.annotations.setItemAnnotation(newId, "bookmarkProperties/description",
|
||||
items[iid]["description"], 0,
|
||||
PlacesUtils.annotations.EXPIRE_NEVER);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
@ -179,8 +191,9 @@ DistributionCustomizer.prototype = {
|
|||
_customizationsApplied: false,
|
||||
applyCustomizations: function() {
|
||||
this._customizationsApplied = true;
|
||||
if (!this._iniFile)
|
||||
if (!this._iniFile) {
|
||||
return this._checkCustomizationComplete();
|
||||
}
|
||||
|
||||
// nsPrefService loads very early. Reload prefs so we can set
|
||||
// distribution defaults during the prefservice:after-app-defaults
|
||||
|
|
@ -192,25 +205,27 @@ DistributionCustomizer.prototype = {
|
|||
_bookmarksApplied: false,
|
||||
applyBookmarks: function() {
|
||||
this._bookmarksApplied = true;
|
||||
if (!this._iniFile)
|
||||
if (!this._iniFile) {
|
||||
return this._checkCustomizationComplete();
|
||||
}
|
||||
|
||||
let sections = enumToObject(this._ini.getSections());
|
||||
|
||||
// The global section, and several of its fields, is required
|
||||
// (we also check here to be consistent with applyPrefDefaults below)
|
||||
if (!sections["Global"])
|
||||
if (!sections["Global"]) {
|
||||
return this._checkCustomizationComplete();
|
||||
}
|
||||
let globalPrefs = enumToObject(this._ini.getKeys("Global"));
|
||||
if (!(globalPrefs["id"] && globalPrefs["version"] && globalPrefs["about"]))
|
||||
if (!(globalPrefs["id"] && globalPrefs["version"] && globalPrefs["about"])) {
|
||||
return this._checkCustomizationComplete();
|
||||
}
|
||||
|
||||
let bmProcessedPref;
|
||||
try {
|
||||
bmProcessedPref = this._ini.getString("Global",
|
||||
"bookmarks.initialized.pref");
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
bmProcessedPref = "distribution." +
|
||||
this._ini.getString("Global", "id") + ".bookmarksProcessed";
|
||||
}
|
||||
|
|
@ -218,12 +233,14 @@ DistributionCustomizer.prototype = {
|
|||
let bmProcessed = this._prefs.getBoolPref(bmProcessedPref, false);
|
||||
|
||||
if (!bmProcessed) {
|
||||
if (sections["BookmarksMenu"])
|
||||
if (sections["BookmarksMenu"]) {
|
||||
this._parseBookmarksSection(PlacesUtils.bookmarksMenuFolderId,
|
||||
"BookmarksMenu");
|
||||
if (sections["BookmarksToolbar"])
|
||||
}
|
||||
if (sections["BookmarksToolbar"]) {
|
||||
this._parseBookmarksSection(PlacesUtils.toolbarFolderId,
|
||||
"BookmarksToolbar");
|
||||
}
|
||||
this._prefs.setBoolPref(bmProcessedPref, true);
|
||||
}
|
||||
return this._checkCustomizationComplete();
|
||||
|
|
@ -232,17 +249,20 @@ DistributionCustomizer.prototype = {
|
|||
_prefDefaultsApplied: false,
|
||||
applyPrefDefaults: function() {
|
||||
this._prefDefaultsApplied = true;
|
||||
if (!this._iniFile)
|
||||
if (!this._iniFile) {
|
||||
return this._checkCustomizationComplete();
|
||||
}
|
||||
|
||||
let sections = enumToObject(this._ini.getSections());
|
||||
|
||||
// The global section, and several of its fields, is required
|
||||
if (!sections["Global"])
|
||||
if (!sections["Global"]) {
|
||||
return this._checkCustomizationComplete();
|
||||
}
|
||||
let globalPrefs = enumToObject(this._ini.getKeys("Global"));
|
||||
if (!(globalPrefs["id"] && globalPrefs["version"] && globalPrefs["about"]))
|
||||
if (!(globalPrefs["id"] && globalPrefs["version"] && globalPrefs["about"])) {
|
||||
return this._checkCustomizationComplete();
|
||||
}
|
||||
|
||||
let defaults = this._prefSvc.getDefaultBranch(null);
|
||||
|
||||
|
|
@ -253,8 +273,8 @@ DistributionCustomizer.prototype = {
|
|||
defaults.setCharPref("distribution.version",
|
||||
this._ini.getString("Global", "version"));
|
||||
|
||||
let partnerAbout = Cc["@mozilla.org/supports-string;1"].
|
||||
createInstance(Ci.nsISupportsString);
|
||||
let partnerAbout = Cc["@mozilla.org/supports-string;1"]
|
||||
.createInstance(Ci.nsISupportsString);
|
||||
try {
|
||||
if (globalPrefs["about." + this._locale]) {
|
||||
partnerAbout.data = this._ini.getString("Global", "about." + this._locale);
|
||||
|
|
@ -273,20 +293,22 @@ DistributionCustomizer.prototype = {
|
|||
try {
|
||||
let value = eval(this._ini.getString("Preferences", key));
|
||||
switch (typeof value) {
|
||||
case "boolean":
|
||||
defaults.setBoolPref(key, value);
|
||||
break;
|
||||
case "number":
|
||||
defaults.setIntPref(key, value);
|
||||
break;
|
||||
case "string":
|
||||
defaults.setCharPref(key, value);
|
||||
break;
|
||||
case "undefined":
|
||||
defaults.setCharPref(key, value);
|
||||
break;
|
||||
case "boolean":
|
||||
defaults.setBoolPref(key, value);
|
||||
break;
|
||||
case "number":
|
||||
defaults.setIntPref(key, value);
|
||||
break;
|
||||
case "string":
|
||||
defaults.setCharPref(key, value);
|
||||
break;
|
||||
case "undefined":
|
||||
defaults.setCharPref(key, value);
|
||||
break;
|
||||
}
|
||||
} catch (e) { /* ignore bad prefs and move on */ }
|
||||
} catch(e) {
|
||||
/* ignore bad prefs and move on */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -294,8 +316,8 @@ DistributionCustomizer.prototype = {
|
|||
// always get set as a string) to keep the INI format consistent:
|
||||
// string prefs always need to be in quotes
|
||||
|
||||
let localizedStr = Cc["@mozilla.org/pref-localizedstring;1"].
|
||||
createInstance(Ci.nsIPrefLocalizedString);
|
||||
let localizedStr = Cc["@mozilla.org/pref-localizedstring;1"]
|
||||
.createInstance(Ci.nsIPrefLocalizedString);
|
||||
|
||||
if (sections["LocalizablePreferences"]) {
|
||||
for (let key in enumerate(this._ini.getKeys("LocalizablePreferences"))) {
|
||||
|
|
@ -304,7 +326,9 @@ DistributionCustomizer.prototype = {
|
|||
value = value.replace("%LOCALE%", this._locale, "g");
|
||||
localizedStr.data = "data:text/plain," + key + "=" + value;
|
||||
defaults.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedStr);
|
||||
} catch (e) { /* ignore bad prefs and move on */ }
|
||||
} catch(e) {
|
||||
/* ignore bad prefs and move on */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -314,7 +338,9 @@ DistributionCustomizer.prototype = {
|
|||
let value = eval(this._ini.getString("LocalizablePreferences-" + this._locale, key));
|
||||
localizedStr.data = "data:text/plain," + key + "=" + value;
|
||||
defaults.setComplexValue(key, Ci.nsIPrefLocalizedString, localizedStr);
|
||||
} catch (e) { /* ignore bad prefs and move on */ }
|
||||
} catch(e) {
|
||||
/* ignore bad prefs and move on */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -325,21 +351,23 @@ DistributionCustomizer.prototype = {
|
|||
let prefDefaultsApplied = this._prefDefaultsApplied || !this._iniFile;
|
||||
if (this._customizationsApplied && this._bookmarksApplied &&
|
||||
prefDefaultsApplied) {
|
||||
let os = Cc["@mozilla.org/observer-service;1"].
|
||||
getService(Ci.nsIObserverService);
|
||||
let os = Cc["@mozilla.org/observer-service;1"]
|
||||
.getService(Ci.nsIObserverService);
|
||||
os.notifyObservers(null, DISTRIBUTION_CUSTOMIZATION_COMPLETE_TOPIC, null);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function enumerate(UTF8Enumerator) {
|
||||
while (UTF8Enumerator.hasMore())
|
||||
while (UTF8Enumerator.hasMore()) {
|
||||
yield UTF8Enumerator.getNext();
|
||||
}
|
||||
}
|
||||
|
||||
function enumToObject(UTF8Enumerator) {
|
||||
let ret = {};
|
||||
for (let i in enumerate(UTF8Enumerator))
|
||||
let ret = { };
|
||||
for (let i in enumerate(UTF8Enumerator)) {
|
||||
ret[i] = 1;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ const ALLOW_SCRIPT = Ci.nsIAboutModule.ALLOW_SCRIPT;
|
|||
const HIDE_FROM_ABOUTABOUT = Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT;
|
||||
const MAKE_LINKABLE = Ci.nsIAboutModule.MAKE_LINKABLE;
|
||||
|
||||
function AboutRedirector() {}
|
||||
function AboutRedirector() { }
|
||||
AboutRedirector.prototype = {
|
||||
classDescription: "Browser about: Redirector",
|
||||
classID: Components.ID("{8cc51368-6aa0-43e8-b762-bde9b9fd828c}"),
|
||||
|
|
@ -88,15 +88,17 @@ AboutRedirector.prototype = {
|
|||
|
||||
getURIFlags: function(aURI) {
|
||||
let name = this._getModuleName(aURI);
|
||||
if (!(name in this._redirMap))
|
||||
if (!(name in this._redirMap)) {
|
||||
throw Cr.NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
return this._redirMap[name].flags;
|
||||
},
|
||||
|
||||
newChannel: function(aURI, aLoadInfo) {
|
||||
let name = this._getModuleName(aURI);
|
||||
if (!(name in this._redirMap))
|
||||
if (!(name in this._redirMap)) {
|
||||
throw Cr.NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
|
||||
let newURI = Services.io.newURI(this._redirMap[name].url, null, null);
|
||||
let channel = Services.io.newChannelFromURIWithLoadInfo(newURI, aLoadInfo);
|
||||
|
|
|
|||
|
|
@ -41,11 +41,12 @@ const NS_ERROR_WONT_HANDLE_CONTENT = 0x805d0001;
|
|||
const NS_ERROR_ABORT = Components.results.NS_ERROR_ABORT;
|
||||
|
||||
const URI_INHERITS_SECURITY_CONTEXT = Components.interfaces.nsIHttpProtocolHandler
|
||||
.URI_INHERITS_SECURITY_CONTEXT;
|
||||
.URI_INHERITS_SECURITY_CONTEXT;
|
||||
|
||||
function shouldLoadURI(aURI) {
|
||||
if (aURI && !aURI.schemeIs("chrome"))
|
||||
if (aURI && !aURI.schemeIs("chrome")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
dump("*** Preventing external load of chrome: URI into browser window\n");
|
||||
dump(" Use -chrome <uri> instead\n");
|
||||
|
|
@ -63,10 +64,10 @@ function resolveURIInternal(aCmdLine, aArgument) {
|
|||
}
|
||||
|
||||
try {
|
||||
if (uri.file.exists())
|
||||
if (uri.file.exists()) {
|
||||
return uri;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
} catch(e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
|
||||
|
|
@ -75,8 +76,7 @@ function resolveURIInternal(aCmdLine, aArgument) {
|
|||
|
||||
try {
|
||||
uri = urifixup.createFixupURI(aArgument, 0);
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
|
||||
|
|
@ -102,8 +102,9 @@ const OVERRIDE_NEW_BUILD_ID = 3;
|
|||
function needHomepageOverride(prefb) {
|
||||
var savedmstone = prefb.getCharPref("browser.startup.homepage_override.mstone", "");
|
||||
|
||||
if (savedmstone == "ignore")
|
||||
if (savedmstone == "ignore") {
|
||||
return OVERRIDE_NONE;
|
||||
}
|
||||
|
||||
var mstone = Services.appinfo.platformVersion;
|
||||
|
||||
|
|
@ -116,8 +117,9 @@ function needHomepageOverride(prefb) {
|
|||
// agreement if the platform's installer had already shown one. Now with
|
||||
// about:rights we've removed the EULA stuff and default pref, but we need
|
||||
// a way to make existing profiles retain the default that we removed.
|
||||
if (savedmstone)
|
||||
if (savedmstone) {
|
||||
prefb.setBoolPref("browser.rights.3.shown", true);
|
||||
}
|
||||
|
||||
prefb.setCharPref("browser.startup.homepage_override.mstone", mstone);
|
||||
prefb.setCharPref("browser.startup.homepage_override.buildID", buildID);
|
||||
|
|
@ -146,7 +148,7 @@ function getPostUpdateOverridePage(defaultOverridePage) {
|
|||
// If the updates.xml file is deleted then getUpdateAt will throw.
|
||||
var update = um.getUpdateAt(0)
|
||||
.QueryInterface(Components.interfaces.nsIPropertyBag);
|
||||
} catch (e) {
|
||||
} catch(e) {
|
||||
// This should never happen.
|
||||
Components.utils.reportError("Unable to find update: " + e);
|
||||
return defaultOverridePage;
|
||||
|
|
@ -155,13 +157,15 @@ function getPostUpdateOverridePage(defaultOverridePage) {
|
|||
let actions = update.getProperty("actions");
|
||||
// When the update doesn't specify actions fallback to the original behavior
|
||||
// of displaying the default override page.
|
||||
if (!actions)
|
||||
if (!actions) {
|
||||
return defaultOverridePage;
|
||||
}
|
||||
|
||||
// The existence of silent or the non-existence of showURL in the actions both
|
||||
// mean that an override page should not be displayed.
|
||||
if (actions.indexOf("silent") != -1 || actions.indexOf("showURL") == -1)
|
||||
if (actions.indexOf("silent") != -1 || actions.indexOf("showURL") == -1) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return update.getProperty("openURL") || defaultOverridePage;
|
||||
}
|
||||
|
|
@ -187,19 +191,22 @@ function openWindow(parent, url, target, features, args, noExternalArgs) {
|
|||
|
||||
// Pass an array to avoid the browser "|"-splitting behavior.
|
||||
var argArray = Components.classes["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
|
||||
// add args to the arguments array
|
||||
var stringArgs = null;
|
||||
if (args instanceof Array) // array
|
||||
if (args instanceof Array) {
|
||||
// array
|
||||
stringArgs = args;
|
||||
else if (args) // string
|
||||
} else if (args) {
|
||||
// string
|
||||
stringArgs = [args];
|
||||
}
|
||||
|
||||
if (stringArgs) {
|
||||
// put the URIs into argArray
|
||||
var uriArray = Components.classes["@mozilla.org/supports-array;1"]
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
.createInstance(Components.interfaces.nsISupportsArray);
|
||||
stringArgs.forEach(function(uri) {
|
||||
var sstring = Components.classes["@mozilla.org/supports-string;1"]
|
||||
.createInstance(nsISupportsString);
|
||||
|
|
@ -272,22 +279,22 @@ function doSearch(searchTerm, cmdLine) {
|
|||
sa);
|
||||
}
|
||||
|
||||
function nsBrowserContentHandler() {
|
||||
}
|
||||
function nsBrowserContentHandler() { }
|
||||
nsBrowserContentHandler.prototype = {
|
||||
classID: Components.ID("{5d0ce354-df01-421a-83fb-7ead0990c24e}"),
|
||||
|
||||
_xpcom_factory: {
|
||||
createInstance: function(outer, iid) {
|
||||
if (outer)
|
||||
if (outer) {
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
return gBrowserContentHandler.QueryInterface(iid);
|
||||
}
|
||||
},
|
||||
|
||||
/* helper functions */
|
||||
|
||||
mChromeURL : null,
|
||||
mChromeURL: null,
|
||||
|
||||
get chromeURL() {
|
||||
if (this.mChromeURL) {
|
||||
|
|
@ -302,13 +309,13 @@ nsBrowserContentHandler.prototype = {
|
|||
},
|
||||
|
||||
/* nsISupports */
|
||||
QueryInterface : XPCOMUtils.generateQI([nsICommandLineHandler,
|
||||
QueryInterface: XPCOMUtils.generateQI([ nsICommandLineHandler,
|
||||
nsIBrowserHandler,
|
||||
nsIContentHandler,
|
||||
nsICommandLineValidator]),
|
||||
nsICommandLineValidator ]),
|
||||
|
||||
/* nsICommandLineHandler */
|
||||
handle : function(cmdLine) {
|
||||
handle: function(cmdLine) {
|
||||
if (cmdLine.handleFlag("browser", false)) {
|
||||
// Passing defaultArgs, so use NO_EXTERNAL_URIS
|
||||
openWindow(null, this.chromeURL, "_blank",
|
||||
|
|
@ -319,8 +326,7 @@ nsBrowserContentHandler.prototype = {
|
|||
|
||||
try {
|
||||
var remoteCommand = cmdLine.handleFlagWithParam("remote", true);
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
throw NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
|
|
@ -332,63 +338,63 @@ nsBrowserContentHandler.prototype = {
|
|||
remoteVerb = a[1].toLowerCase();
|
||||
var remoteParams = [];
|
||||
var sepIndex = a[2].lastIndexOf(",");
|
||||
if (sepIndex == -1)
|
||||
if (sepIndex == -1) {
|
||||
remoteParams[0] = a[2];
|
||||
else {
|
||||
} else {
|
||||
remoteParams[0] = a[2].substring(0, sepIndex);
|
||||
remoteParams[1] = a[2].substring(sepIndex + 1);
|
||||
}
|
||||
}
|
||||
|
||||
switch (remoteVerb) {
|
||||
case "openurl":
|
||||
case "openfile":
|
||||
// openURL(<url>)
|
||||
// openURL(<url>,new-window)
|
||||
// openURL(<url>,new-tab)
|
||||
|
||||
// First param is the URL, second param (if present) is the "target"
|
||||
// (tab, window)
|
||||
var url = remoteParams[0];
|
||||
var target = nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW;
|
||||
if (remoteParams[1]) {
|
||||
var targetParam = remoteParams[1].toLowerCase()
|
||||
.replace(/^\s*|\s*$/g, "");
|
||||
if (targetParam == "new-tab")
|
||||
target = nsIBrowserDOMWindow.OPEN_NEWTAB;
|
||||
else if (targetParam == "new-window")
|
||||
target = nsIBrowserDOMWindow.OPEN_NEWWINDOW;
|
||||
else {
|
||||
// The "target" param isn't one of our supported values, so
|
||||
// assume it's part of a URL that contains commas.
|
||||
url += "," + remoteParams[1];
|
||||
case "openurl":
|
||||
case "openfile":
|
||||
// openURL(<url>)
|
||||
// openURL(<url>,new-window)
|
||||
// openURL(<url>,new-tab)
|
||||
|
||||
// First param is the URL, second param (if present) is the "target"
|
||||
// (tab, window)
|
||||
var url = remoteParams[0];
|
||||
var target = nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW;
|
||||
if (remoteParams[1]) {
|
||||
var targetParam = remoteParams[1].toLowerCase()
|
||||
.replace(/^\s*|\s*$/g, "");
|
||||
if (targetParam == "new-tab") {
|
||||
target = nsIBrowserDOMWindow.OPEN_NEWTAB;
|
||||
} else if (targetParam == "new-window") {
|
||||
target = nsIBrowserDOMWindow.OPEN_NEWWINDOW;
|
||||
} else {
|
||||
// The "target" param isn't one of our supported values, so
|
||||
// assume it's part of a URL that contains commas.
|
||||
url += "," + remoteParams[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var uri = resolveURIInternal(cmdLine, url);
|
||||
handURIToExistingBrowser(uri, target, cmdLine);
|
||||
break;
|
||||
var uri = resolveURIInternal(cmdLine, url);
|
||||
handURIToExistingBrowser(uri, target, cmdLine);
|
||||
break;
|
||||
|
||||
case "xfedocommand":
|
||||
// xfeDoCommand(openBrowser)
|
||||
if (remoteParams[0].toLowerCase() != "openbrowser")
|
||||
throw NS_ERROR_ABORT;
|
||||
case "xfedocommand":
|
||||
// xfeDoCommand(openBrowser)
|
||||
if (remoteParams[0].toLowerCase() != "openbrowser") {
|
||||
throw NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
// Passing defaultArgs, so use NO_EXTERNAL_URIS
|
||||
openWindow(null, this.chromeURL, "_blank",
|
||||
"chrome,dialog=no,all" + this.getFeatures(cmdLine),
|
||||
this.defaultArgs, NO_EXTERNAL_URIS);
|
||||
break;
|
||||
// Passing defaultArgs, so use NO_EXTERNAL_URIS
|
||||
openWindow(null, this.chromeURL, "_blank",
|
||||
"chrome,dialog=no,all" + this.getFeatures(cmdLine),
|
||||
this.defaultArgs, NO_EXTERNAL_URIS);
|
||||
break;
|
||||
|
||||
default:
|
||||
// Somebody sent us a remote command we don't know how to process:
|
||||
// just abort.
|
||||
throw "Unknown remote command.";
|
||||
default:
|
||||
// Somebody sent us a remote command we don't know how to process:
|
||||
// just abort.
|
||||
throw "Unknown remote command.";
|
||||
}
|
||||
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
catch (e) {
|
||||
} catch (e) {
|
||||
Components.utils.reportError(e);
|
||||
// If we had a -remote flag but failed to process it, throw
|
||||
// NS_ERROR_ABORT so that the xremote code knows to return a failure
|
||||
|
|
@ -401,15 +407,15 @@ nsBrowserContentHandler.prototype = {
|
|||
try {
|
||||
while ((uriparam = cmdLine.handleFlagWithParam("new-window", false))) {
|
||||
var uri = resolveURIInternal(cmdLine, uriparam);
|
||||
if (!shouldLoadURI(uri))
|
||||
if (!shouldLoadURI(uri)) {
|
||||
continue;
|
||||
}
|
||||
openWindow(null, this.chromeURL, "_blank",
|
||||
"chrome,dialog=no,all" + this.getFeatures(cmdLine),
|
||||
uri.spec);
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
|
||||
|
|
@ -419,8 +425,7 @@ nsBrowserContentHandler.prototype = {
|
|||
handURIToExistingBrowser(uri, nsIBrowserDOMWindow.OPEN_NEWTAB, cmdLine);
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
|
||||
|
|
@ -431,27 +436,29 @@ nsBrowserContentHandler.prototype = {
|
|||
if (chromeParam == "chrome://browser/content/pref/pref.xul") {
|
||||
openPreferences();
|
||||
cmdLine.preventDefault = true;
|
||||
} else try {
|
||||
// only load URIs which do not inherit chrome privs
|
||||
var features = "chrome,dialog=no,all" + this.getFeatures(cmdLine);
|
||||
var uri = resolveURIInternal(cmdLine, chromeParam);
|
||||
var netutil = Components.classes["@mozilla.org/network/util;1"]
|
||||
.getService(nsINetUtil);
|
||||
if (!netutil.URIChainHasFlags(uri, URI_INHERITS_SECURITY_CONTEXT)) {
|
||||
openWindow(null, uri.spec, "_blank", features);
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
} else {
|
||||
try {
|
||||
// only load URIs which do not inherit chrome privs
|
||||
var features = "chrome,dialog=no,all" + this.getFeatures(cmdLine);
|
||||
var uri = resolveURIInternal(cmdLine, chromeParam);
|
||||
var netutil = Components.classes["@mozilla.org/network/util;1"]
|
||||
.getService(nsINetUtil);
|
||||
if (!netutil.URIChainHasFlags(uri, URI_INHERITS_SECURITY_CONTEXT)) {
|
||||
openWindow(null, uri.spec, "_blank", features);
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
} catch(e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cmdLine.handleFlag("preferences", false)) {
|
||||
openPreferences();
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
if (cmdLine.handleFlag("silent", false))
|
||||
if (cmdLine.handleFlag("silent", false)) {
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
|
||||
try {
|
||||
var privateWindowParam = cmdLine.handleFlagWithParam("private-window", false);
|
||||
|
|
@ -460,15 +467,15 @@ nsBrowserContentHandler.prototype = {
|
|||
handURIToExistingBrowser(resolvedURI, nsIBrowserDOMWindow.OPEN_NEWTAB, cmdLine, true);
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch(e) {
|
||||
if (e.result != Components.results.NS_ERROR_INVALID_ARG) {
|
||||
throw e;
|
||||
}
|
||||
// NS_ERROR_INVALID_ARG is thrown when flag exists, but has no param.
|
||||
if (cmdLine.handleFlag("private-window", false)) {
|
||||
openWindow(null, this.chromeURL, "_blank",
|
||||
"chrome,dialog=no,private,all" + this.getFeatures(cmdLine),
|
||||
"about:privatebrowsing");
|
||||
"chrome,dialog=no,private,all" + this.getFeatures(cmdLine),
|
||||
"about:privatebrowsing");
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
}
|
||||
|
|
@ -512,16 +519,12 @@ nsBrowserContentHandler.prototype = {
|
|||
#endif
|
||||
},
|
||||
|
||||
helpInfo : " --browser Open a browser window.\n" +
|
||||
" --new-window <url> Open <url> in a new window.\n" +
|
||||
" --new-tab <url> Open <url> in a new tab.\n" +
|
||||
" --private-window <url> Open <url> in a new private window.\n" +
|
||||
#ifdef XP_WIN
|
||||
" --preferences Open Options dialog.\n" +
|
||||
#else
|
||||
" --preferences Open Preferences dialog.\n" +
|
||||
#endif
|
||||
" --search <term> Search <term> with your default search engine.\n",
|
||||
helpInfo: " --browser Open a browser window.\n" +
|
||||
" --new-window <url> Open <url> in a new window.\n" +
|
||||
" --new-tab <url> Open <url> in a new tab.\n" +
|
||||
" --private-window <url> Open <url> in a new private window.\n" +
|
||||
" --preferences Open Preferences dialog.\n" +
|
||||
" --search <term> Search <term> with your default search engine.\n",
|
||||
|
||||
/* nsIBrowserHandler */
|
||||
|
||||
|
|
@ -559,31 +562,36 @@ nsBrowserContentHandler.prototype = {
|
|||
.getService(Components.interfaces.nsISessionStartup);
|
||||
haveUpdateSession = ss.doRestore();
|
||||
overridePage = Services.urlFormatter.formatURLPref("startup.homepage_override_url");
|
||||
if (prefb.prefHasUserValue("app.update.postupdate"))
|
||||
if (prefb.prefHasUserValue("app.update.postupdate")) {
|
||||
overridePage = getPostUpdateOverridePage(overridePage);
|
||||
}
|
||||
|
||||
overridePage = overridePage.replace("%OLD_VERSION%", old_mstone);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (ex) {}
|
||||
} catch(ex) {
|
||||
}
|
||||
|
||||
// formatURLPref might return "about:blank" if getting the pref fails
|
||||
if (overridePage == "about:blank")
|
||||
if (overridePage == "about:blank") {
|
||||
overridePage = "";
|
||||
}
|
||||
|
||||
var startPage = "";
|
||||
try {
|
||||
var choice = prefb.getIntPref("browser.startup.page");
|
||||
if (choice == 1 || choice == 3)
|
||||
if (choice == 1 || choice == 3) {
|
||||
startPage = this.startPage;
|
||||
} catch (e) {
|
||||
}
|
||||
} catch(e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
|
||||
// Only show the startPage if we're not restoring an update session.
|
||||
if (overridePage && startPage && !haveUpdateSession)
|
||||
if (overridePage && startPage && !haveUpdateSession) {
|
||||
return overridePage + "|" + startPage;
|
||||
}
|
||||
|
||||
return overridePage || startPage || "about:logopage";
|
||||
},
|
||||
|
|
@ -599,9 +607,9 @@ nsBrowserContentHandler.prototype = {
|
|||
return uri;
|
||||
},
|
||||
|
||||
mFeatures : null,
|
||||
mFeatures: null,
|
||||
|
||||
getFeatures : function(cmdLine) {
|
||||
getFeatures: function(cmdLine) {
|
||||
if (this.mFeatures === null) {
|
||||
this.mFeatures = "";
|
||||
|
||||
|
|
@ -609,12 +617,13 @@ nsBrowserContentHandler.prototype = {
|
|||
var width = cmdLine.handleFlagWithParam("width", false);
|
||||
var height = cmdLine.handleFlagWithParam("height", false);
|
||||
|
||||
if (width)
|
||||
if (width) {
|
||||
this.mFeatures += ",width=" + width;
|
||||
if (height)
|
||||
}
|
||||
if (height) {
|
||||
this.mFeatures += ",height=" + height;
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
// The global PB Service consumes this flag, so only eat it in per-window
|
||||
|
|
@ -629,25 +638,24 @@ nsBrowserContentHandler.prototype = {
|
|||
|
||||
/* nsIContentHandler */
|
||||
|
||||
handleContent : function(contentType, context, request) {
|
||||
handleContent: function(contentType, context, request) {
|
||||
try {
|
||||
var webNavInfo = Components.classes["@mozilla.org/webnavigation-info;1"]
|
||||
.getService(nsIWebNavigationInfo);
|
||||
if (!webNavInfo.isTypeSupported(contentType, null)) {
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
}
|
||||
} catch (e) {
|
||||
} catch(e) {
|
||||
throw NS_ERROR_WONT_HANDLE_CONTENT;
|
||||
}
|
||||
|
||||
request.QueryInterface(nsIChannel);
|
||||
handURIToExistingBrowser(request.URI,
|
||||
nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW, null);
|
||||
handURIToExistingBrowser(request.URI, nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW, null);
|
||||
request.cancel(NS_BINDING_ABORTED);
|
||||
},
|
||||
|
||||
/* nsICommandLineValidator */
|
||||
validate : function(cmdLine) {
|
||||
validate: function(cmdLine) {
|
||||
// Other handlers may use osint so only handle the osint flag if the url
|
||||
// flag is also present and the command line is valid.
|
||||
var osintFlagIdx = cmdLine.findFlag("osint", false);
|
||||
|
|
@ -655,18 +663,20 @@ nsBrowserContentHandler.prototype = {
|
|||
if (urlFlagIdx > -1 && (osintFlagIdx > -1 ||
|
||||
cmdLine.state == nsICommandLine.STATE_REMOTE_EXPLICIT)) {
|
||||
var urlParam = cmdLine.getArgument(urlFlagIdx + 1);
|
||||
if (cmdLine.length != urlFlagIdx + 2 || /firefoxurl:/.test(urlParam))
|
||||
if (cmdLine.length != urlFlagIdx + 2 || /firefoxurl:/.test(urlParam)) {
|
||||
throw NS_ERROR_ABORT;
|
||||
}
|
||||
cmdLine.handleFlag("osint", false)
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
var gBrowserContentHandler = new nsBrowserContentHandler();
|
||||
|
||||
function handURIToExistingBrowser(uri, location, cmdLine, forcePrivate)
|
||||
{
|
||||
if (!shouldLoadURI(uri))
|
||||
function handURIToExistingBrowser(uri, location, cmdLine, forcePrivate) {
|
||||
if (!shouldLoadURI(uri)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Unless using a private window is forced, open external links in private
|
||||
// windows only if we're in perma-private mode.
|
||||
|
|
@ -692,14 +702,12 @@ function handURIToExistingBrowser(uri, location, cmdLine, forcePrivate)
|
|||
nsIBrowserDOMWindow.OPEN_EXTERNAL);
|
||||
}
|
||||
|
||||
function nsDefaultCommandLineHandler() {
|
||||
}
|
||||
|
||||
function nsDefaultCommandLineHandler() { }
|
||||
nsDefaultCommandLineHandler.prototype = {
|
||||
classID: Components.ID("{47cd0651-b1be-4a0f-b5c4-10e5a573ef71}"),
|
||||
|
||||
/* nsISupports */
|
||||
QueryInterface : function(iid) {
|
||||
QueryInterface: function(iid) {
|
||||
if (!iid.equals(nsISupports) &&
|
||||
!iid.equals(nsICommandLineHandler))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
|
@ -712,7 +720,7 @@ nsDefaultCommandLineHandler.prototype = {
|
|||
#endif
|
||||
|
||||
/* nsICommandLineHandler */
|
||||
handle : function(cmdLine) {
|
||||
handle: function(cmdLine) {
|
||||
var urilist = [];
|
||||
|
||||
#ifdef XP_WIN
|
||||
|
|
@ -729,8 +737,7 @@ nsDefaultCommandLineHandler.prototype = {
|
|||
.getService(Components.interfaces.nsIProperties);
|
||||
var dir = fl.get("ProfD", Components.interfaces.nsILocalFile);
|
||||
this._haveProfile = true;
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
while ((ar = cmdLine.handleFlagWithParam("url", false))) { }
|
||||
cmdLine.preventDefault = true;
|
||||
}
|
||||
|
|
@ -743,8 +750,7 @@ nsDefaultCommandLineHandler.prototype = {
|
|||
var uri = resolveURIInternal(cmdLine, ar);
|
||||
urilist.push(uri);
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
Components.utils.reportError(e);
|
||||
}
|
||||
|
||||
|
|
@ -760,8 +766,7 @@ nsDefaultCommandLineHandler.prototype = {
|
|||
} else {
|
||||
try {
|
||||
urilist.push(resolveURIInternal(cmdLine, curarg));
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
Components.utils.reportError("Error opening URI '" + curarg + "' from the command line: " + e + "\n");
|
||||
}
|
||||
}
|
||||
|
|
@ -775,8 +780,7 @@ nsDefaultCommandLineHandler.prototype = {
|
|||
try {
|
||||
handURIToExistingBrowser(urilist[0], nsIBrowserDOMWindow.OPEN_DEFAULTWINDOW, cmdLine);
|
||||
return;
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -787,8 +791,7 @@ nsDefaultCommandLineHandler.prototype = {
|
|||
URLlist);
|
||||
}
|
||||
|
||||
}
|
||||
else if (!cmdLine.preventDefault) {
|
||||
} else if (!cmdLine.preventDefault) {
|
||||
// Passing defaultArgs, so use NO_EXTERNAL_URIS
|
||||
openWindow(null, gBrowserContentHandler.chromeURL, "_blank",
|
||||
"chrome,dialog=no,all" + gBrowserContentHandler.getFeatures(cmdLine),
|
||||
|
|
|
|||
|
|
@ -69,10 +69,12 @@ const BOOKMARKS_BACKUP_MAX_BACKUPS = 10;
|
|||
const BrowserGlueServiceFactory = {
|
||||
_instance: null,
|
||||
createInstance: function(outer, iid) {
|
||||
if (outer != null)
|
||||
if (outer != null) {
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
}
|
||||
return this._instance == null ?
|
||||
this._instance = new BrowserGlue() : this._instance;
|
||||
this._instance = new BrowserGlue() :
|
||||
this._instance;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -90,7 +92,7 @@ function BrowserGlue() {
|
|||
|
||||
XPCOMUtils.defineLazyGetter(this, "_sanitizer",
|
||||
function() {
|
||||
let sanitizerScope = {};
|
||||
let sanitizerScope = { };
|
||||
Services.scriptloader.loadSubScript("chrome://browser/content/sanitize.js", sanitizerScope);
|
||||
return sanitizerScope.Sanitizer;
|
||||
});
|
||||
|
|
@ -114,8 +116,9 @@ BrowserGlue.prototype = {
|
|||
_migrationImportsDefaultBookmarks: false,
|
||||
|
||||
_setPrefToSaveSession: function(aForce) {
|
||||
if (!this._saveSession && !aForce)
|
||||
if (!this._saveSession && !aForce) {
|
||||
return;
|
||||
}
|
||||
|
||||
Services.prefs.setBoolPref("browser.sessionstore.resume_session_once", true);
|
||||
|
||||
|
|
@ -131,8 +134,9 @@ BrowserGlue.prototype = {
|
|||
if (Services.prefs.prefHasUserValue("services.sync.autoconnectDelay")) {
|
||||
let prefDelay = Services.prefs.getIntPref("services.sync.autoconnectDelay");
|
||||
|
||||
if (prefDelay > 0)
|
||||
if (prefDelay > 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// delays are in seconds
|
||||
|
|
@ -184,7 +188,7 @@ BrowserGlue.prototype = {
|
|||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"].
|
||||
getService(Ci.nsIAppStartup);
|
||||
appStartup.trackStartupCrashEnd();
|
||||
} catch (e) {
|
||||
} catch(e) {
|
||||
Cu.reportError("Could not end startup crash tracking in quit-application-granted: " + e);
|
||||
}
|
||||
DateTimePickerHelper.uninit();
|
||||
|
|
@ -213,8 +217,9 @@ BrowserGlue.prototype = {
|
|||
subject.data = true;
|
||||
break;
|
||||
case "places-init-complete":
|
||||
if (!this._migrationImportsDefaultBookmarks)
|
||||
if (!this._migrationImportsDefaultBookmarks) {
|
||||
this._initPlaces(false);
|
||||
}
|
||||
|
||||
Services.obs.removeObserver(this, "places-init-complete");
|
||||
this._isPlacesInitObserver = false;
|
||||
|
|
@ -249,18 +254,16 @@ BrowserGlue.prototype = {
|
|||
break;
|
||||
case "browser-glue-test": // used by tests
|
||||
if (data == "post-update-notification") {
|
||||
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
|
||||
if (Services.prefs.prefHasUserValue("app.update.postupdate")) {
|
||||
this._showUpdateNotification();
|
||||
}
|
||||
else if (data == "force-ui-migration") {
|
||||
}
|
||||
} else if (data == "force-ui-migration") {
|
||||
this._migrateUI();
|
||||
}
|
||||
else if (data == "force-distribution-customization") {
|
||||
} else if (data == "force-distribution-customization") {
|
||||
this._distributionCustomizer.applyPrefDefaults();
|
||||
this._distributionCustomizer.applyCustomizations();
|
||||
// To apply distribution bookmarks use "places-init-complete".
|
||||
}
|
||||
else if (data == "force-places-init") {
|
||||
} else if (data == "force-places-init") {
|
||||
this._initPlaces(false);
|
||||
}
|
||||
break;
|
||||
|
|
@ -296,16 +299,19 @@ BrowserGlue.prototype = {
|
|||
// No need to initialize the search service, since it's guaranteed to be
|
||||
// initialized already when this notification fires.
|
||||
let ss = Services.search;
|
||||
if (ss.currentEngine.name == ss.defaultEngine.name)
|
||||
if (ss.currentEngine.name == ss.defaultEngine.name) {
|
||||
return;
|
||||
if (data == "engine-current")
|
||||
}
|
||||
if (data == "engine-current") {
|
||||
ss.defaultEngine = ss.currentEngine;
|
||||
else
|
||||
} else {
|
||||
ss.currentEngine = ss.defaultEngine;
|
||||
}
|
||||
break;
|
||||
case "browser-search-service":
|
||||
if (data != "init-complete")
|
||||
if (data != "init-complete") {
|
||||
return;
|
||||
}
|
||||
Services.obs.removeObserver(this, "browser-search-service");
|
||||
this._syncSearchEngines();
|
||||
break;
|
||||
|
|
@ -374,21 +380,26 @@ BrowserGlue.prototype = {
|
|||
os.removeObserver(this, "weave:engine:clients:display-uri");
|
||||
#endif
|
||||
os.removeObserver(this, "session-save");
|
||||
if (this._isIdleObserver)
|
||||
if (this._isIdleObserver) {
|
||||
this._idleService.removeIdleObserver(this, BOOKMARKS_BACKUP_IDLE_TIME);
|
||||
if (this._isPlacesInitObserver)
|
||||
}
|
||||
if (this._isPlacesInitObserver) {
|
||||
os.removeObserver(this, "places-init-complete");
|
||||
if (this._isPlacesLockedObserver)
|
||||
}
|
||||
if (this._isPlacesLockedObserver) {
|
||||
os.removeObserver(this, "places-database-locked");
|
||||
if (this._isPlacesShutdownObserver)
|
||||
}
|
||||
if (this._isPlacesShutdownObserver) {
|
||||
os.removeObserver(this, "places-shutdown");
|
||||
}
|
||||
os.removeObserver(this, "handle-xul-text-link");
|
||||
os.removeObserver(this, "profile-before-change");
|
||||
os.removeObserver(this, "browser-search-engine-modified");
|
||||
try {
|
||||
os.removeObserver(this, "browser-search-service");
|
||||
} catch(ex) {
|
||||
// may have already been removed by the observer
|
||||
} catch (ex) {}
|
||||
}
|
||||
},
|
||||
|
||||
_onAppDefaults: function() {
|
||||
|
|
@ -441,9 +452,12 @@ BrowserGlue.prototype = {
|
|||
let cookies;
|
||||
try {
|
||||
cookies = aHttpChannel.getRequestHeader("Cookie");
|
||||
} catch (e) { /* no cookie sent */ }
|
||||
if (cookies && cookies.indexOf("MoodleSession") > -1)
|
||||
} catch(e) {
|
||||
// no cookie sent
|
||||
}
|
||||
if (cookies && cookies.indexOf("MoodleSession") > -1) {
|
||||
return aOriginalUA.replace(/Goanna\/[^ ]*/, "Goanna/20100101");
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
|
@ -451,8 +465,9 @@ BrowserGlue.prototype = {
|
|||
|
||||
_trackSlowStartup: function() {
|
||||
if (Services.startup.interrupted ||
|
||||
Services.prefs.getBoolPref("browser.slowStartup.notificationDisabled"))
|
||||
Services.prefs.getBoolPref("browser.slowStartup.notificationDisabled")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let currentTime = Date.now() - Services.startup.getStartupInfo().process;
|
||||
let averageTime = 0;
|
||||
|
|
@ -460,13 +475,15 @@ BrowserGlue.prototype = {
|
|||
try {
|
||||
averageTime = Services.prefs.getIntPref("browser.slowStartup.averageTime");
|
||||
samples = Services.prefs.getIntPref("browser.slowStartup.samples");
|
||||
} catch (e) { }
|
||||
} catch(e) {
|
||||
}
|
||||
|
||||
averageTime = (averageTime * samples + currentTime) / ++samples;
|
||||
|
||||
if (samples >= Services.prefs.getIntPref("browser.slowStartup.maxSamples")) {
|
||||
if (averageTime > Services.prefs.getIntPref("browser.slowStartup.timeThreshold"))
|
||||
if (averageTime > Services.prefs.getIntPref("browser.slowStartup.timeThreshold")) {
|
||||
this._showSlowStartupNotification();
|
||||
}
|
||||
averageTime = 0;
|
||||
samples = 0;
|
||||
}
|
||||
|
|
@ -477,8 +494,9 @@ BrowserGlue.prototype = {
|
|||
|
||||
_showSlowStartupNotification: function() {
|
||||
let win = this.getMostRecentBrowserWindow();
|
||||
if (!win)
|
||||
if (!win) {
|
||||
return;
|
||||
}
|
||||
|
||||
let productName = gBrandBundle.GetStringFromName("brandFullName");
|
||||
let message = win.gNavigatorBundle.getFormattedString("slowStartup.message", [productName]);
|
||||
|
|
@ -509,7 +527,7 @@ BrowserGlue.prototype = {
|
|||
// the first browser window has finished initializing
|
||||
_onFirstWindowLoaded: function() {
|
||||
#ifdef XP_WIN
|
||||
// For windows seven, initialize the jump list module.
|
||||
// For Windows, initialize the jump list module.
|
||||
const WINTASKBAR_CONTRACTID = "@mozilla.org/windows-taskbar;1";
|
||||
if (WINTASKBAR_CONTRACTID in Cc &&
|
||||
Cc[WINTASKBAR_CONTRACTID].getService(Ci.nsIWinTaskbar).available) {
|
||||
|
|
@ -543,8 +561,9 @@ BrowserGlue.prototype = {
|
|||
// All initial windows have opened.
|
||||
_onWindowsRestored: function() {
|
||||
// Show update notification, if needed.
|
||||
if (Services.prefs.prefHasUserValue("app.update.postupdate"))
|
||||
if (Services.prefs.prefHasUserValue("app.update.postupdate")) {
|
||||
this._showUpdateNotification();
|
||||
}
|
||||
|
||||
// Load the "more info" page for a locked places.sqlite
|
||||
// This property is set earlier by places-database-locked topic.
|
||||
|
|
@ -560,8 +579,9 @@ BrowserGlue.prototype = {
|
|||
AddonManager.getAddonsByIDs(changedIDs, function(aAddons) {
|
||||
aAddons.forEach(function(aAddon) {
|
||||
// If the add-on isn't user disabled or can't be enabled then skip it.
|
||||
if (!aAddon.userDisabled || !(aAddon.permissions & AddonManager.PERM_CAN_ENABLE))
|
||||
if (!aAddon.userDisabled || !(aAddon.permissions & AddonManager.PERM_CAN_ENABLE)) {
|
||||
return;
|
||||
}
|
||||
|
||||
win.openUILinkIn("about:newaddon?id=" + aAddon.id, "tab");
|
||||
})
|
||||
|
|
@ -586,15 +606,16 @@ BrowserGlue.prototype = {
|
|||
getService(Ci.nsISessionStartup);
|
||||
willRecoverSession =
|
||||
(ss.sessionType == Ci.nsISessionStartup.RECOVER_SESSION);
|
||||
} catch(ex) {
|
||||
// never mind; suppose SessionStore is broken
|
||||
}
|
||||
catch (ex) { /* never mind; suppose SessionStore is broken */ }
|
||||
|
||||
// startup check, check all assoc
|
||||
let isDefault = false;
|
||||
let isDefaultError = false;
|
||||
try {
|
||||
isDefault = ShellService.isDefaultBrowser(true, false);
|
||||
} catch (ex) {
|
||||
} catch(ex) {
|
||||
isDefaultError = true;
|
||||
}
|
||||
|
||||
|
|
@ -634,7 +655,8 @@ BrowserGlue.prototype = {
|
|||
// Windows 8 is version 6.2.
|
||||
let version = Services.sysinfo.getProperty("version");
|
||||
claimAllTypes = (parseFloat(version) < 6.2);
|
||||
} catch (ex) { }
|
||||
} catch (ex) {
|
||||
}
|
||||
#endif
|
||||
ShellService.setDefaultBrowser(claimAllTypes, false);
|
||||
}
|
||||
|
|
@ -646,8 +668,9 @@ BrowserGlue.prototype = {
|
|||
|
||||
_onQuitRequest: function(aCancelQuit, aQuitType) {
|
||||
// If user has already dismissed quit request, then do nothing
|
||||
if ((aCancelQuit instanceof Ci.nsISupportsPRBool) && aCancelQuit.data)
|
||||
if ((aCancelQuit instanceof Ci.nsISupportsPRBool) && aCancelQuit.data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// There are several cases where we won't show a dialog here:
|
||||
// 1. There is only 1 tab open in 1 window
|
||||
|
|
@ -667,8 +690,9 @@ BrowserGlue.prototype = {
|
|||
// "the last window is closing but we're not quitting (a non-browser window is open)"
|
||||
// and also "we're quitting by closing the last window".
|
||||
|
||||
if (aQuitType == "restart")
|
||||
if (aQuitType == "restart") {
|
||||
return;
|
||||
}
|
||||
|
||||
var windowcount = 0;
|
||||
var pagecount = 0;
|
||||
|
|
@ -678,19 +702,23 @@ BrowserGlue.prototype = {
|
|||
windowcount++;
|
||||
|
||||
var browser = browserEnum.getNext();
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(browser))
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(browser)) {
|
||||
allWindowsPrivate = false;
|
||||
}
|
||||
var tabbrowser = browser.document.getElementById("content");
|
||||
if (tabbrowser)
|
||||
if (tabbrowser) {
|
||||
pagecount += tabbrowser.browsers.length - tabbrowser._numPinnedTabs;
|
||||
}
|
||||
}
|
||||
|
||||
this._saveSession = false;
|
||||
if (pagecount < 2)
|
||||
if (pagecount < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!aQuitType)
|
||||
if (!aQuitType) {
|
||||
aQuitType = "quit";
|
||||
}
|
||||
|
||||
// browser.warnOnQuit is a hidden global boolean to override all quit prompts
|
||||
// browser.showQuitWarning specifically covers quitting
|
||||
|
|
@ -698,8 +726,9 @@ BrowserGlue.prototype = {
|
|||
|
||||
var sessionWillBeRestored = Services.prefs.getIntPref("browser.startup.page") == 3 ||
|
||||
Services.prefs.getBoolPref("browser.sessionstore.resume_session_once");
|
||||
if (sessionWillBeRestored || !Services.prefs.getBoolPref("browser.warnOnQuit"))
|
||||
if (sessionWillBeRestored || !Services.prefs.getBoolPref("browser.warnOnQuit")) {
|
||||
return;
|
||||
}
|
||||
|
||||
let win = Services.wm.getMostRecentWindow("navigator:browser");
|
||||
|
||||
|
|
@ -758,21 +787,22 @@ BrowserGlue.prototype = {
|
|||
}
|
||||
|
||||
switch (choice) {
|
||||
case 2: // Quit
|
||||
if (neverAsk.value)
|
||||
Services.prefs.setBoolPref("browser.showQuitWarning", false);
|
||||
break;
|
||||
case 1: // Cancel
|
||||
aCancelQuit.QueryInterface(Ci.nsISupportsPRBool);
|
||||
aCancelQuit.data = true;
|
||||
break;
|
||||
case 0: // Save & Quit
|
||||
this._saveSession = true;
|
||||
if (neverAsk.value) {
|
||||
// always save state when shutting down
|
||||
Services.prefs.setIntPref("browser.startup.page", 3);
|
||||
}
|
||||
break;
|
||||
case 2: // Quit
|
||||
if (neverAsk.value) {
|
||||
Services.prefs.setBoolPref("browser.showQuitWarning", false);
|
||||
}
|
||||
break;
|
||||
case 1: // Cancel
|
||||
aCancelQuit.QueryInterface(Ci.nsISupportsPRBool);
|
||||
aCancelQuit.data = true;
|
||||
break;
|
||||
case 0: // Save & Quit
|
||||
this._saveSession = true;
|
||||
if (neverAsk.value) {
|
||||
// always save state when shutting down
|
||||
Services.prefs.setIntPref("browser.startup.page", 3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
@ -784,32 +814,33 @@ BrowserGlue.prototype = {
|
|||
try {
|
||||
// If the updates.xml file is deleted then getUpdateAt will throw.
|
||||
var update = um.getUpdateAt(0).QueryInterface(Ci.nsIPropertyBag);
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
// This should never happen.
|
||||
Cu.reportError("Unable to find update: " + e);
|
||||
return;
|
||||
}
|
||||
|
||||
var actions = update.getProperty("actions");
|
||||
if (!actions || actions.indexOf("silent") != -1)
|
||||
if (!actions || actions.indexOf("silent") != -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
|
||||
getService(Ci.nsIURLFormatter);
|
||||
var formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
|
||||
.getService(Ci.nsIURLFormatter);
|
||||
var appName = gBrandBundle.GetStringFromName("brandShortName");
|
||||
|
||||
function getNotifyString(aPropData) {
|
||||
var propValue = update.getProperty(aPropData.propName);
|
||||
if (!propValue) {
|
||||
if (aPropData.prefName)
|
||||
if (aPropData.prefName) {
|
||||
propValue = formatter.formatURLPref(aPropData.prefName);
|
||||
else if (aPropData.stringParams)
|
||||
} else if (aPropData.stringParams) {
|
||||
propValue = gBrowserBundle.formatStringFromName(aPropData.stringName,
|
||||
aPropData.stringParams,
|
||||
aPropData.stringParams.length);
|
||||
else
|
||||
} else {
|
||||
propValue = gBrowserBundle.GetStringFromName(aPropData.stringName);
|
||||
}
|
||||
}
|
||||
return propValue;
|
||||
}
|
||||
|
|
@ -845,23 +876,25 @@ BrowserGlue.prototype = {
|
|||
notification.persistence = -1; // Until user closes it
|
||||
}
|
||||
|
||||
if (actions.indexOf("showAlert") == -1)
|
||||
if (actions.indexOf("showAlert") == -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
let title = getNotifyString({propName: "alertTitle",
|
||||
stringName: "puAlertTitle",
|
||||
stringParams: [appName]});
|
||||
let text = getNotifyString({propName: "alertText",
|
||||
stringName: "puAlertText",
|
||||
stringParams: [appName]});
|
||||
let url = getNotifyString({propName: "alertURL",
|
||||
prefName: "startup.homepage_override_url"});
|
||||
let title = getNotifyString({ propName: "alertTitle",
|
||||
stringName: "puAlertTitle",
|
||||
stringParams: [appName] });
|
||||
let text = getNotifyString({ propName: "alertText",
|
||||
stringName: "puAlertText",
|
||||
stringParams: [appName] });
|
||||
let url = getNotifyString({ propName: "alertURL",
|
||||
prefName: "startup.homepage_override_url" });
|
||||
|
||||
var self = this;
|
||||
function clickCallback(subject, topic, data) {
|
||||
// This callback will be called twice but only once with this topic
|
||||
if (topic != "alertclickcallback")
|
||||
if (topic != "alertclickcallback") {
|
||||
return;
|
||||
}
|
||||
let win = self.getMostRecentBrowserWindow();
|
||||
win.openUILinkIn(data, "tab");
|
||||
}
|
||||
|
|
@ -871,8 +904,7 @@ BrowserGlue.prototype = {
|
|||
// be displayed per the idl.
|
||||
AlertsService.showAlertNotification(null, title, text,
|
||||
true, url, clickCallback);
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
},
|
||||
|
|
@ -930,7 +962,8 @@ BrowserGlue.prototype = {
|
|||
Services.prefs.getBoolPref("browser.places.importBookmarksHTML");
|
||||
if (importBookmarksHTML)
|
||||
importBookmarks = true;
|
||||
} catch(ex) {}
|
||||
} catch(ex) {
|
||||
}
|
||||
|
||||
Task.spawn(function() {
|
||||
// Check if Safe Mode or the user has required to restore bookmarks from
|
||||
|
|
@ -944,7 +977,8 @@ BrowserGlue.prototype = {
|
|||
yield this._backupBookmarks();
|
||||
importBookmarks = true;
|
||||
}
|
||||
} catch(ex) {}
|
||||
} catch(ex) {
|
||||
}
|
||||
|
||||
// If the user did not require to restore default bookmarks, or import
|
||||
// from bookmarks.html, we will try to restore from JSON/JSONLZ4
|
||||
|
|
@ -955,15 +989,13 @@ BrowserGlue.prototype = {
|
|||
// restore from JSON/JSONLZ4 backup
|
||||
yield BookmarkJSONUtils.importFromFile(bookmarksBackupFile, true);
|
||||
importBookmarks = false;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// We have created a new database but we don't have any backup available
|
||||
importBookmarks = true;
|
||||
if (yield OS.File.exists(BookmarkHTMLUtils.defaultPath)) {
|
||||
// If bookmarks.html is available in current profile import it...
|
||||
importBookmarksHTML = true;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// ...otherwise we will restore defaults
|
||||
restoreDefaultBookmarks = true;
|
||||
}
|
||||
|
|
@ -981,35 +1013,34 @@ BrowserGlue.prototype = {
|
|||
try {
|
||||
this._distributionCustomizer.applyBookmarks();
|
||||
this.ensurePlacesDefaultQueriesInitialized();
|
||||
} catch (e) {
|
||||
} catch(e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// An import operation is about to run.
|
||||
// Don't try to recreate smart bookmarks if autoExportHTML is true or
|
||||
// smart bookmarks are disabled.
|
||||
var autoExportHTML = Services.prefs.getBoolPref("browser.bookmarks.autoExportHTML", false);
|
||||
var smartBookmarksVersion = Services.prefs.getIntPref("browser.places.smartBookmarksVersion", 0);
|
||||
if (!autoExportHTML && smartBookmarksVersion != -1)
|
||||
if (!autoExportHTML && smartBookmarksVersion != -1) {
|
||||
Services.prefs.setIntPref("browser.places.smartBookmarksVersion", 0);
|
||||
}
|
||||
|
||||
var bookmarksUrl = null;
|
||||
if (restoreDefaultBookmarks) {
|
||||
// User wants to restore bookmarks.html file from default profile folder
|
||||
bookmarksUrl = "resource:///defaults/profile/bookmarks.html";
|
||||
}
|
||||
else if (yield OS.File.exists(BookmarkHTMLUtils.defaultPath)) {
|
||||
} else if (yield OS.File.exists(BookmarkHTMLUtils.defaultPath)) {
|
||||
bookmarksUrl = OS.Path.toFileURI(BookmarkHTMLUtils.defaultPath);
|
||||
}
|
||||
|
||||
if (bookmarksUrl) {
|
||||
// Import from bookmarks.html file.
|
||||
try {
|
||||
BookmarkHTMLUtils.importFromURL(bookmarksUrl, true).then(null,
|
||||
BookmarkHTMLUtils.importFromURL(bookmarksUrl, true).then(
|
||||
null,
|
||||
function onFailure() {
|
||||
Cu.reportError(
|
||||
new Error("Bookmarks.html file could be corrupt."));
|
||||
Cu.reportError(new Error("Bookmarks.html file could be corrupt."));
|
||||
}
|
||||
).then(
|
||||
function onComplete() {
|
||||
|
|
@ -1025,13 +1056,12 @@ BrowserGlue.prototype = {
|
|||
}
|
||||
}.bind(this)
|
||||
);
|
||||
} catch (e) {
|
||||
} catch(e) {
|
||||
Cu.reportError(
|
||||
new Error("Bookmarks.html file could be corrupt." + "\n" +
|
||||
e.message));
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
Cu.reportError(new Error("Unable to find bookmarks.html file."));
|
||||
}
|
||||
|
||||
|
|
@ -1142,9 +1172,12 @@ BrowserGlue.prototype = {
|
|||
try {
|
||||
maxBackups = Services.prefs.getIntPref("browser.bookmarks.max_backups");
|
||||
}
|
||||
catch(ex) { /* Use default. */ }
|
||||
catch(ex) {
|
||||
// Use default.
|
||||
}
|
||||
|
||||
yield PlacesBackups.create(maxBackups); // Don't force creation.
|
||||
// Don't force creation.
|
||||
yield PlacesBackups.create(maxBackups);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
|
@ -1161,9 +1194,9 @@ BrowserGlue.prototype = {
|
|||
var accessKey = placesBundle.GetStringFromName("lockPromptInfoButton.accessKey");
|
||||
|
||||
var helpTopic = "places-locked";
|
||||
var url = Cc["@mozilla.org/toolkit/URLFormatterService;1"].
|
||||
getService(Components.interfaces.nsIURLFormatter).
|
||||
formatURLPref("app.support.baseURL");
|
||||
var url = Cc["@mozilla.org/toolkit/URLFormatterService;1"]
|
||||
.getService(Components.interfaces.nsIURLFormatter)
|
||||
.formatURLPref("app.support.baseURL");
|
||||
url += helpTopic;
|
||||
|
||||
var win = this.getMostRecentBrowserWindow();
|
||||
|
|
@ -1192,9 +1225,11 @@ BrowserGlue.prototype = {
|
|||
let currentUIVersion = 0;
|
||||
try {
|
||||
currentUIVersion = Services.prefs.getIntPref("browser.migration.version");
|
||||
} catch(ex) {}
|
||||
if (currentUIVersion >= UI_VERSION)
|
||||
} catch(ex) {
|
||||
}
|
||||
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");
|
||||
|
|
@ -1397,7 +1432,8 @@ BrowserGlue.prototype = {
|
|||
Services.prefs.clearUserPref("privacy.donottrackheader.value");
|
||||
}
|
||||
}
|
||||
catch (ex) {}
|
||||
catch (ex) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef MOZ_JXR
|
||||
|
|
@ -1456,8 +1492,9 @@ BrowserGlue.prototype = {
|
|||
}
|
||||
|
||||
// Clear out dirty storage
|
||||
if (this._dirty)
|
||||
if (this._dirty) {
|
||||
this._dataSource.QueryInterface(Ci.nsIRDFRemoteDataSource).Flush();
|
||||
}
|
||||
|
||||
delete this._rdf;
|
||||
delete this._dataSource;
|
||||
|
|
@ -1482,8 +1519,9 @@ BrowserGlue.prototype = {
|
|||
return;
|
||||
}
|
||||
function clickCallback(subject, topic, data) {
|
||||
if (topic != "alertclickcallback")
|
||||
if (topic != "alertclickcallback") {
|
||||
return;
|
||||
}
|
||||
let win = RecentWindow.getMostRecentBrowserWindow();
|
||||
win.openUILinkIn(data, "tab");
|
||||
}
|
||||
|
|
@ -1498,8 +1536,7 @@ BrowserGlue.prototype = {
|
|||
try {
|
||||
AlertsService.showAlertNotification(imageURL, title, text,
|
||||
true, url, clickCallback);
|
||||
}
|
||||
catch (e) {
|
||||
} catch(e) {
|
||||
Cu.reportError(e);
|
||||
}
|
||||
},
|
||||
|
|
@ -1509,8 +1546,8 @@ BrowserGlue.prototype = {
|
|||
var url = "about:permissions";
|
||||
try {
|
||||
url = url + "?filter=" + aPrincipal.URI.host;
|
||||
} catch(e) {
|
||||
}
|
||||
catch (e) {}
|
||||
win.openUILinkIn(url, "tab");
|
||||
},
|
||||
|
||||
|
|
@ -1518,14 +1555,16 @@ BrowserGlue.prototype = {
|
|||
try {
|
||||
return !!Cc["@mozilla.org/system-alerts-service;1"].getService(
|
||||
Ci.nsIAlertsService);
|
||||
} catch (e) {}
|
||||
} catch(e) {
|
||||
}
|
||||
return false;
|
||||
},
|
||||
|
||||
_getPersist: function(aSource, aProperty) {
|
||||
var target = this._dataSource.GetTarget(aSource, aProperty, true);
|
||||
if (target instanceof Ci.nsIRDFLiteral)
|
||||
if (target instanceof Ci.nsIRDFLiteral) {
|
||||
return target.Value;
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
|
|
@ -1534,12 +1573,12 @@ BrowserGlue.prototype = {
|
|||
try {
|
||||
var oldTarget = this._dataSource.GetTarget(aSource, aProperty, true);
|
||||
if (oldTarget) {
|
||||
if (aTarget)
|
||||
if (aTarget) {
|
||||
this._dataSource.Change(aSource, aProperty, oldTarget, this._rdf.GetLiteral(aTarget));
|
||||
else
|
||||
} else {
|
||||
this._dataSource.Unassert(aSource, aProperty, oldTarget);
|
||||
}
|
||||
else {
|
||||
}
|
||||
} else {
|
||||
this._dataSource.Assert(aSource, aProperty, this._rdf.GetLiteral(aTarget), true);
|
||||
}
|
||||
|
||||
|
|
@ -1654,9 +1693,8 @@ BrowserGlue.prototype = {
|
|||
smartBookmark.itemId = itemId;
|
||||
smartBookmark.parent = PlacesUtils.bookmarks.getFolderIdForItem(itemId);
|
||||
smartBookmark.position = PlacesUtils.bookmarks.getItemIndex(itemId);
|
||||
}
|
||||
else {
|
||||
// We don't remove old Smart Bookmarks because user could still
|
||||
} else {
|
||||
// We don't remove old Smart Bookmarks because the user could still
|
||||
// find them useful, or could have personalized them.
|
||||
// Instead we remove the Smart Bookmark annotation.
|
||||
PlacesUtils.annotations.removeItemAnnotation(itemId, SMART_BOOKMARKS_ANNO);
|
||||
|
|
@ -1671,8 +1709,9 @@ BrowserGlue.prototype = {
|
|||
// bookmark if it has been removed.
|
||||
if (smartBookmarksCurrentVersion > 0 &&
|
||||
smartBookmark.newInVersion <= smartBookmarksCurrentVersion &&
|
||||
!smartBookmark.itemId)
|
||||
!smartBookmark.itemId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Remove old version of the smart bookmark if it exists, since it
|
||||
// will be replaced in place.
|
||||
|
|
@ -1710,11 +1749,9 @@ BrowserGlue.prototype = {
|
|||
|
||||
try {
|
||||
PlacesUtils.bookmarks.runInBatchMode(batch, null);
|
||||
}
|
||||
catch(ex) {
|
||||
} catch(ex) {
|
||||
Components.utils.reportError(ex);
|
||||
}
|
||||
finally {
|
||||
} finally {
|
||||
Services.prefs.setIntPref(SMART_BOOKMARKS_PREF, SMART_BOOKMARKS_VERSION);
|
||||
Services.prefs.savePrefFile(null);
|
||||
}
|
||||
|
|
@ -1743,7 +1780,7 @@ BrowserGlue.prototype = {
|
|||
|
||||
// The payload is wrapped weirdly because of how Sync does notifications.
|
||||
tabbrowser.addTab(data.wrappedJSObject.object.uri);
|
||||
} catch (ex) {
|
||||
} catch(ex) {
|
||||
Cu.reportError("Error displaying tab received by Sync: " + ex);
|
||||
}
|
||||
},
|
||||
|
|
@ -1760,8 +1797,7 @@ BrowserGlue.prototype = {
|
|||
_xpcom_factory: BrowserGlueServiceFactory,
|
||||
}
|
||||
|
||||
function ContentPermissionPrompt() {}
|
||||
|
||||
function ContentPermissionPrompt() { }
|
||||
ContentPermissionPrompt.prototype = {
|
||||
classID: Components.ID("{d8903bf6-68d5-4e97-bcd1-e4d3012f721a}"),
|
||||
|
||||
|
|
@ -1804,7 +1840,7 @@ ContentPermissionPrompt.prototype = {
|
|||
* @param aOptions Options for the PopupNotification
|
||||
*/
|
||||
_showPrompt: function(aRequest, aMessage, aPermission, aActions,
|
||||
aNotificationId, aAnchorId, aOptions) {
|
||||
aNotificationId, aAnchorId, aOptions) {
|
||||
function onFullScreen() {
|
||||
popup.remove();
|
||||
}
|
||||
|
|
@ -1867,8 +1903,9 @@ ContentPermissionPrompt.prototype = {
|
|||
// If there's no mainAction, this is the autoAllow warning prompt.
|
||||
let autoAllow = !mainAction;
|
||||
|
||||
if (!aOptions)
|
||||
aOptions = {};
|
||||
if (!aOptions) {
|
||||
aOptions = { };
|
||||
}
|
||||
|
||||
aOptions.removeOnDismissal = autoAllow;
|
||||
aOptions.eventCallback = type => {
|
||||
|
|
@ -1899,14 +1936,13 @@ ContentPermissionPrompt.prototype = {
|
|||
var message;
|
||||
|
||||
// Share location action.
|
||||
var actions = [{
|
||||
stringId: "geolocation.shareLocation",
|
||||
action: null,
|
||||
expireType: null,
|
||||
callback: function() {
|
||||
// Telemetry stub (left here for safety and compatibility reasons)
|
||||
},
|
||||
}];
|
||||
var actions = [{ stringId: "geolocation.shareLocation",
|
||||
action: null,
|
||||
expireType: null,
|
||||
callback: function() {
|
||||
// Telemetry stub (left here for safety and compatibility reasons)
|
||||
}
|
||||
}];
|
||||
|
||||
if (requestingURI.schemeIs("file")) {
|
||||
message = gBrowserBundle.formatStringFromName("geolocation.shareWithFile",
|
||||
|
|
@ -1921,7 +1957,7 @@ ContentPermissionPrompt.prototype = {
|
|||
expireType: null,
|
||||
callback: function() {
|
||||
// Telemetry stub (left here for safety and compatibility reasons)
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
// Never share location action.
|
||||
|
|
@ -1931,13 +1967,11 @@ ContentPermissionPrompt.prototype = {
|
|||
expireType: null,
|
||||
callback: function() {
|
||||
// Telemetry stub (left here for safety and compatibility reasons)
|
||||
},
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var options = {
|
||||
learnMoreURL: Services.urlFormatter.formatURLPref("browser.geolocation.warning.infoURL"),
|
||||
};
|
||||
var options = { learnMoreURL: Services.urlFormatter.formatURLPref("browser.geolocation.warning.infoURL") };
|
||||
|
||||
this._showPrompt(aRequest, message, "geo", actions, "geolocation",
|
||||
"geo-notification-icon", options);
|
||||
|
|
@ -1960,8 +1994,8 @@ ContentPermissionPrompt.prototype = {
|
|||
stringId: "webNotifications.showForSession",
|
||||
action: Ci.nsIPermissionManager.ALLOW_ACTION,
|
||||
expireType: Ci.nsIPermissionManager.EXPIRE_SESSION,
|
||||
callback: function() {},
|
||||
},
|
||||
callback: function() { },
|
||||
}
|
||||
];
|
||||
} else {
|
||||
actions = [
|
||||
|
|
@ -1969,20 +2003,20 @@ ContentPermissionPrompt.prototype = {
|
|||
stringId: "webNotifications.showForSession",
|
||||
action: Ci.nsIPermissionManager.ALLOW_ACTION,
|
||||
expireType: Ci.nsIPermissionManager.EXPIRE_SESSION,
|
||||
callback: function() {},
|
||||
callback: function() { },
|
||||
},
|
||||
{
|
||||
stringId: "webNotifications.alwaysShow",
|
||||
action: Ci.nsIPermissionManager.ALLOW_ACTION,
|
||||
expireType: null,
|
||||
callback: function() {},
|
||||
callback: function() { },
|
||||
},
|
||||
{
|
||||
stringId: "webNotifications.neverShow",
|
||||
action: Ci.nsIPermissionManager.DENY_ACTION,
|
||||
expireType: null,
|
||||
callback: function() {},
|
||||
},
|
||||
callback: function() { },
|
||||
}
|
||||
];
|
||||
}
|
||||
var options = {
|
||||
|
|
@ -2023,7 +2057,7 @@ ContentPermissionPrompt.prototype = {
|
|||
action: Ci.nsIPermissionManager.DENY_ACTION,
|
||||
expireType: null,
|
||||
callback: function() {},
|
||||
},
|
||||
}
|
||||
];
|
||||
}
|
||||
|
||||
|
|
@ -2087,9 +2121,8 @@ ContentPermissionPrompt.prototype = {
|
|||
this._promptPointerLock(request, autoAllow);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
}
|
||||
}; // ContentPermissionPrompt
|
||||
|
||||
var components = [BrowserGlue, ContentPermissionPrompt];
|
||||
this.NSGetFactory = XPCOMUtils.generateNSGetFactory(components);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue