From d0b4eb41bb6ac08171c164187bf33e03c58d4749 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Mon, 18 Mar 2019 18:27:45 -0400 Subject: Issue #756 - Remove contextual identity from BackgroundPageThumbs.jsm reverts m-c 1279568, 1309699, 1310112 --- .../components/thumbnails/BackgroundPageThumbs.jsm | 40 +--------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'toolkit') diff --git a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm index 3ba0c346c..3ed32665d 100644 --- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm +++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm @@ -15,8 +15,6 @@ const TELEMETRY_HISTOGRAM_ID_PREFIX = "FX_THUMBNAILS_BG_"; const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; const HTML_NS = "http://www.w3.org/1999/xhtml"; -const ABOUT_NEWTAB_SEGREGATION_PREF = "privacy.usercontext.about_newtab_segregation.enabled"; - const { classes: Cc, interfaces: Ci, utils: Cu } = Components; Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); @@ -37,8 +35,6 @@ XPCOMUtils.defineConstant(this, "TEL_CAPTURE_DONE_TIMEOUT", TEL_CAPTURE_DONE_TIM XPCOMUtils.defineConstant(this, "TEL_CAPTURE_DONE_CRASHED", TEL_CAPTURE_DONE_CRASHED); XPCOMUtils.defineConstant(this, "TEL_CAPTURE_DONE_BAD_URI", TEL_CAPTURE_DONE_BAD_URI); -XPCOMUtils.defineLazyModuleGetter(this, "ContextualIdentityService", - "resource://gre/modules/ContextualIdentityService.jsm"); const global = this; // contains base64 version of a placeholder thumbnail @@ -138,14 +134,6 @@ const BackgroundPageThumbs = { return url; }), - /** - * Tell the service that the thumbnail browser should be recreated at next - * call of _ensureBrowser(). - */ - renewThumbnailBrowser: function() { - this._renewThumbBrowser = true; - }, - /** * Ensures that initialization of the thumbnail browser's parent window has * begun. @@ -201,12 +189,9 @@ const BackgroundPageThumbs = { * Creates the thumbnail browser if it doesn't already exist. */ _ensureBrowser: function () { - if (this._thumbBrowser && !this._renewThumbBrowser) + if (this._thumbBrowser) return; - this._destroyBrowser(); - this._renewThumbBrowser = false; - let browser = this._parentWin.document.createElementNS(XUL_NS, "browser"); browser.setAttribute("type", "content"); browser.setAttribute("disableglobalhistory", "true"); @@ -216,13 +201,6 @@ const BackgroundPageThumbs = { browser.setAttribute("remote", "true"); } - if (Services.prefs.getBoolPref(ABOUT_NEWTAB_SEGREGATION_PREF)) { - // Use the private container for thumbnails. - let privateIdentity = - ContextualIdentityService.getPrivateIdentity("userContextIdInternal.thumbnail"); - browser.setAttribute("usercontextid", privateIdentity.userContextId); - } - // Size the browser. Make its aspect ratio the same as the canvases' that // the thumbnails are drawn into; the canvases' aspect ratio is the same as // the screen's, so use that. Aim for a size in the ballpark of 1024x768. @@ -325,14 +303,6 @@ const BackgroundPageThumbs = { _destroyBrowserTimeout: DESTROY_BROWSER_TIMEOUT, }; -Services.prefs.addObserver(ABOUT_NEWTAB_SEGREGATION_PREF, - function(aSubject, aTopic, aData) { - if (aTopic == "nsPref:changed" && aData == ABOUT_NEWTAB_SEGREGATION_PREF) { - BackgroundPageThumbs.renewThumbnailBrowser(); - } - }, - false); - Object.defineProperty(this, "BackgroundPageThumbs", { value: BackgroundPageThumbs, enumerable: true, @@ -467,14 +437,6 @@ Capture.prototype = { Cu.reportError(err); } } - - if (Services.prefs.getBoolPref(ABOUT_NEWTAB_SEGREGATION_PREF)) { - // Clear the data in the private container for thumbnails. - let privateIdentity = - ContextualIdentityService.getPrivateIdentity("userContextIdInternal.thumbnail"); - Services.obs.notifyObservers(null, "clear-origin-attributes-data", - JSON.stringify({ userContextId: privateIdentity.userContextId })); - } }; if (!data) { -- cgit v1.2.3 From 2d20c38f8395871facc2b23058770156c30611f5 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Mon, 18 Mar 2019 18:38:30 -0400 Subject: Issue #756 - Remove Contextual Identity from UnifiedComplete reverts m-c 1287866 --- toolkit/components/places/UnifiedComplete.js | 80 +++++++--------------- .../components/places/mozIPlacesAutoComplete.idl | 8 +-- toolkit/components/places/nsPlacesTables.h | 4 +- toolkit/components/places/nsPlacesTriggers.h | 3 +- .../tests/unifiedcomplete/head_autocomplete.js | 8 +-- .../tests/unifiedcomplete/test_tab_matches.js | 53 ++------------ 6 files changed, 40 insertions(+), 116 deletions(-) (limited to 'toolkit') diff --git a/toolkit/components/places/UnifiedComplete.js b/toolkit/components/places/UnifiedComplete.js index 2efae9cbe..ec5f91111 100644 --- a/toolkit/components/places/UnifiedComplete.js +++ b/toolkit/components/places/UnifiedComplete.js @@ -124,9 +124,7 @@ function defaultQuery(conditions = "") { h.visit_count, h.typed, h.id, t.open_count, h.frecency FROM moz_places h LEFT JOIN moz_favicons f ON f.id = h.favicon_id - LEFT JOIN moz_openpages_temp t - ON t.url = h.url - AND t.userContextId = :userContextId + LEFT JOIN moz_openpages_temp t ON t.url = h.url WHERE h.frecency <> 0 AND AUTOCOMPLETE_MATCH(:searchString, h.url, CASE WHEN bookmarked THEN @@ -150,7 +148,6 @@ const SQL_SWITCHTAB_QUERY = FROM moz_openpages_temp t LEFT JOIN moz_places h ON h.url_hash = hash(t.url) AND h.url = t.url WHERE h.id IS NULL - AND t.userContextId = :userContextId AND AUTOCOMPLETE_MATCH(:searchString, t.url, t.url, NULL, NULL, NULL, NULL, t.open_count, :matchBehavior, :searchBehavior) @@ -170,9 +167,7 @@ const SQL_ADAPTIVE_QUERY = ) AS i JOIN moz_places h ON h.id = i.place_id LEFT JOIN moz_favicons f ON f.id = h.favicon_id - LEFT JOIN moz_openpages_temp t - ON t.url = h.url - AND t.userContextId = :userContextId + LEFT JOIN moz_openpages_temp t ON t.url = h.url WHERE AUTOCOMPLETE_MATCH(NULL, h.url, IFNULL(btitle, h.title), tags, h.visit_count, h.typed, bookmarked, @@ -301,17 +296,15 @@ XPCOMUtils.defineLazyServiceGetter(this, "textURIService", XPCOMUtils.defineLazyGetter(this, "SwitchToTabStorage", () => Object.seal({ _conn: null, // Temporary queue used while the database connection is not available. - _queue: new Map(), + _queue: new Set(), initDatabase: Task.async(function* (conn) { // To reduce IO use an in-memory table for switch-to-tab tracking. // Note: this should be kept up-to-date with the definition in // nsPlacesTables.h. yield conn.execute( `CREATE TEMP TABLE moz_openpages_temp ( - url TEXT, - userContextId INTEGER, - open_count INTEGER, - PRIMARY KEY (url, userContextId) + url TEXT PRIMARY KEY, + open_count INTEGER )`); // Note: this should be kept up-to-date with the definition in @@ -322,64 +315,44 @@ XPCOMUtils.defineLazyGetter(this, "SwitchToTabStorage", () => Object.seal({ WHEN NEW.open_count = 0 BEGIN DELETE FROM moz_openpages_temp - WHERE url = NEW.url - AND userContextId = NEW.userContextId; + WHERE url = NEW.url; END`); this._conn = conn; // Populate the table with the current cache contents... - for (let [userContextId, uris] of this._queue) { - for (let uri of uris) { - this.add(uri, userContextId); - } - } + this._queue.forEach(this.add, this); // ...then clear it to avoid double additions. this._queue.clear(); }), - add(uri, userContextId) { + add: function (uri) { if (!this._conn) { - if (!this._queue.has(userContextId)) { - this._queue.set(userContextId, new Set()); - } - this._queue.get(userContextId).add(uri); + this._queue.add(uri); return; } this._conn.executeCached( - `INSERT OR REPLACE INTO moz_openpages_temp (url, userContextId, open_count) - VALUES ( :url, - :userContextId, - IFNULL( ( SELECT open_count + 1 - FROM moz_openpages_temp - WHERE url = :url - AND userContextId = :userContextId ), - 1 - ) + `INSERT OR REPLACE INTO moz_openpages_temp (url, open_count) + VALUES ( :url, IFNULL( (SELECT open_count + 1 + FROM moz_openpages_temp + WHERE url = :url), + 1 + ) )` - , { url: uri.spec, userContextId }); + , { url: uri.spec }); }, - delete(uri, userContextId) { + delete: function (uri) { if (!this._conn) { - // This should not happen. - if (!this._queue.has(userContextId)) { - throw new Error("Unknown userContextId!"); - } - - this._queue.get(userContextId).delete(uri); - if (this._queue.get(userContextId).size == 0) { - this._queue.delete(userContextId); - } + this._queue.delete(uri); return; } this._conn.executeCached( `UPDATE moz_openpages_temp SET open_count = open_count - 1 - WHERE url = :url - AND userContextId = :userContextId` - , { url: uri.spec, userContextId }); + WHERE url = :url` + , { url: uri.spec }); }, shutdown: function () { @@ -1781,7 +1754,6 @@ Search.prototype = { // We only want to search the tokens that we are left with - not the // original search string. searchString: this._searchTokens.join(" "), - userContextId: this._userContextId, // Limit the query to the the maximum number of desired results. // This way we can avoid doing more work than needed. maxResults: Prefs.maxRichResults @@ -1805,7 +1777,6 @@ Search.prototype = { // We only want to search the tokens that we are left with - not the // original search string. searchString: this._searchTokens.join(" "), - userContextId: this._userContextId, maxResults: Prefs.maxRichResults } ]; @@ -1825,8 +1796,7 @@ Search.prototype = { search_string: this._searchString, query_type: QUERYTYPE_FILTERED, matchBehavior: this._matchBehavior, - searchBehavior: this._behavior, - userContextId: this._userContextId, + searchBehavior: this._behavior } ]; }, @@ -2010,12 +1980,12 @@ UnifiedComplete.prototype = { // mozIPlacesAutoComplete - registerOpenPage(uri, userContextId) { - SwitchToTabStorage.add(uri, userContextId); + registerOpenPage: function PAC_registerOpenPage(uri) { + SwitchToTabStorage.add(uri); }, - unregisterOpenPage(uri, userContextId) { - SwitchToTabStorage.delete(uri, userContextId); + unregisterOpenPage: function PAC_unregisterOpenPage(uri) { + SwitchToTabStorage.delete(uri); }, // nsIAutoCompleteSearch diff --git a/toolkit/components/places/mozIPlacesAutoComplete.idl b/toolkit/components/places/mozIPlacesAutoComplete.idl index 7f3247fdc..6ff82e667 100644 --- a/toolkit/components/places/mozIPlacesAutoComplete.idl +++ b/toolkit/components/places/mozIPlacesAutoComplete.idl @@ -116,10 +116,8 @@ interface mozIPlacesAutoComplete : nsISupports * * @param aURI * The URI to register as an open page. - * @param aUserContextId - * The Container Id of the tab. */ - void registerOpenPage(in nsIURI aURI, in uint32_t aUserContextId); + void registerOpenPage(in nsIURI aURI); /** * Mark a page as no longer being open (either by closing the window or tab, @@ -131,8 +129,6 @@ interface mozIPlacesAutoComplete : nsISupports * * @param aURI * The URI to unregister as an open page. - * @param aUserContextId - * The Container Id of the tab. */ - void unregisterOpenPage(in nsIURI aURI, in uint32_t aUserContextId); + void unregisterOpenPage(in nsIURI aURI); }; diff --git a/toolkit/components/places/nsPlacesTables.h b/toolkit/components/places/nsPlacesTables.h index aca92735e..0b6e414fb 100644 --- a/toolkit/components/places/nsPlacesTables.h +++ b/toolkit/components/places/nsPlacesTables.h @@ -133,10 +133,8 @@ // nsPlacesAutoComplete.js. #define CREATE_MOZ_OPENPAGES_TEMP NS_LITERAL_CSTRING( \ "CREATE TEMP TABLE moz_openpages_temp (" \ - " url TEXT" \ - ", userContextId INTEGER" \ + " url TEXT PRIMARY KEY" \ ", open_count INTEGER" \ - ", PRIMARY KEY (url, userContextId)" \ ")" \ ) diff --git a/toolkit/components/places/nsPlacesTriggers.h b/toolkit/components/places/nsPlacesTriggers.h index d5b45ff5e..37871a3eb 100644 --- a/toolkit/components/places/nsPlacesTriggers.h +++ b/toolkit/components/places/nsPlacesTriggers.h @@ -192,8 +192,7 @@ "WHEN NEW.open_count = 0 " \ "BEGIN " \ "DELETE FROM moz_openpages_temp " \ - "WHERE url = NEW.url " \ - "AND userContextId = NEW.userContextId;" \ + "WHERE url = NEW.url;" \ "END" \ ) diff --git a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js index 11e917e18..bc252efe0 100644 --- a/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js +++ b/toolkit/components/places/tests/unifiedcomplete/head_autocomplete.js @@ -286,19 +286,19 @@ var addBookmark = Task.async(function* (aBookmarkObj) { } }); -function addOpenPages(aUri, aCount=1, aUserContextId=0) { +function addOpenPages(aUri, aCount=1) { let ac = Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"] .getService(Ci.mozIPlacesAutoComplete); for (let i = 0; i < aCount; i++) { - ac.registerOpenPage(aUri, aUserContextId); + ac.registerOpenPage(aUri); } } -function removeOpenPages(aUri, aCount=1, aUserContextId=0) { +function removeOpenPages(aUri, aCount=1) { let ac = Cc["@mozilla.org/autocomplete/search;1?name=unifiedcomplete"] .getService(Ci.mozIPlacesAutoComplete); for (let i = 0; i < aCount; i++) { - ac.unregisterOpenPage(aUri, aUserContextId); + ac.unregisterOpenPage(aUri); } } diff --git a/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js b/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js index 740b8d8ed..646519c32 100644 --- a/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js +++ b/toolkit/components/places/tests/unifiedcomplete/test_tab_matches.js @@ -11,11 +11,9 @@ add_task(function* test_tab_matches() { let uri2 = NetUtil.newURI("http://xyz.net/"); let uri3 = NetUtil.newURI("about:mozilla"); let uri4 = NetUtil.newURI("data:text/html,test"); - let uri5 = NetUtil.newURI("http://foobar.org"); yield PlacesTestUtils.addVisits([ { uri: uri1, title: "ABC rocks" }, - { uri: uri2, title: "xyz.net - we're better than ABC" }, - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ" } + { uri: uri2, title: "xyz.net - we're better than ABC" } ]); addOpenPages(uri1, 1); // Pages that cannot be registered in history. @@ -37,8 +35,7 @@ add_task(function* test_tab_matches() { searchParam: "enable-actions", matches: [ makeSearchMatch("abc", { heuristic: true }), makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }), - { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] }, - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ] + { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ] }); do_print("three results, both normal results are tab matches"); @@ -48,39 +45,7 @@ add_task(function* test_tab_matches() { searchParam: "enable-actions", matches: [ makeSearchMatch("abc", { heuristic: true }), makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }), - makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }), - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ] - }); - - do_print("a container tab is not visible in 'switch to tab'"); - addOpenPages(uri5, 1, /* userContextId: */ 3); - yield check_autocomplete({ - search: "abc", - searchParam: "enable-actions", - matches: [ makeSearchMatch("abc", { heuristic: true }), - makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }), - makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }), - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ] - }); - - do_print("a container tab should not see 'switch to tab' for other container tabs"); - yield check_autocomplete({ - search: "abc", - searchParam: "enable-actions user-context-id:3", - matches: [ makeSearchMatch("abc", { heuristic: true }), - makeSwitchToTabMatch("http://foobar.org/", { title: "foobar.org - much better than ABC, definitely better than XYZ" }), - { uri: uri1, title: "ABC rocks", style: [ "favicon" ] }, - { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ] - }); - - do_print("a different container tab should not see any 'switch to tab'"); - yield check_autocomplete({ - search: "abc", - searchParam: "enable-actions user-context-id:2", - matches: [ makeSearchMatch("abc", { heuristic: true }), - { uri: uri1, title: "ABC rocks", style: [ "favicon" ] }, - { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] }, - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ] + makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }) ] }); do_print("three results, both normal results are tab matches, one has multiple tabs"); @@ -90,8 +55,7 @@ add_task(function* test_tab_matches() { searchParam: "enable-actions", matches: [ makeSearchMatch("abc", { heuristic: true }), makeSwitchToTabMatch("http://abc.com/", { title: "ABC rocks" }), - makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }), - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ] + makeSwitchToTabMatch("http://xyz.net/", { title: "xyz.net - we're better than ABC" }) ] }); do_print("three results, no tab matches (disable-private-actions)"); @@ -100,8 +64,7 @@ add_task(function* test_tab_matches() { searchParam: "enable-actions disable-private-actions", matches: [ makeSearchMatch("abc", { heuristic: true }), { uri: uri1, title: "ABC rocks", style: [ "favicon" ] }, - { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] }, - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ] + { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ] }); do_print("two results (actions disabled)"); @@ -109,8 +72,7 @@ add_task(function* test_tab_matches() { search: "abc", searchParam: "", matches: [ { uri: uri1, title: "ABC rocks", style: [ "favicon" ] }, - { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] }, - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ] + { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ] }); do_print("three results, no tab matches"); @@ -121,8 +83,7 @@ add_task(function* test_tab_matches() { searchParam: "enable-actions", matches: [ makeSearchMatch("abc", { heuristic: true }), { uri: uri1, title: "ABC rocks", style: [ "favicon" ] }, - { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] }, - { uri: uri5, title: "foobar.org - much better than ABC, definitely better than XYZ", style: [ "favicon" ] } ] + { uri: uri2, title: "xyz.net - we're better than ABC", style: [ "favicon" ] } ] }); do_print("tab match search with restriction character"); -- cgit v1.2.3 From 10982181db01134d2369aa000b3adde69e1e495d Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 23 Mar 2019 11:10:28 +0100 Subject: Check for osint argument when checking for greomni and appomni arguments. Specifying both is invalid and unsupported. --- toolkit/xre/nsAppRunner.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'toolkit') diff --git a/toolkit/xre/nsAppRunner.cpp b/toolkit/xre/nsAppRunner.cpp index 59a72c432..26e432b3c 100644 --- a/toolkit/xre/nsAppRunner.cpp +++ b/toolkit/xre/nsAppRunner.cpp @@ -4130,9 +4130,12 @@ XRE_InitCommandLine(int aArgc, char* aArgv[]) #endif const char *path = nullptr; - ArgResult ar = CheckArg("greomni", false, &path); + ArgResult ar = CheckArg("greomni", true, &path); if (ar == ARG_BAD) { - PR_fprintf(PR_STDERR, "Error: argument --greomni requires a path argument\n"); + PR_fprintf(PR_STDERR, + "Error: argument --greomni requires a path argument or the " + "--osint argument was specified with the --greomni argument " + "which is invalid.\n"); return NS_ERROR_FAILURE; } @@ -4146,9 +4149,12 @@ XRE_InitCommandLine(int aArgc, char* aArgv[]) return rv; } - ar = CheckArg("appomni", false, &path); + ar = CheckArg("appomni", true, &path); if (ar == ARG_BAD) { - PR_fprintf(PR_STDERR, "Error: argument --appomni requires a path argument\n"); + PR_fprintf(PR_STDERR, + "Error: argument --appomni requires a path argument or the " + "--osint argument was specified with the --appomni argument " + "which is invalid.\n"); return NS_ERROR_FAILURE; } -- cgit v1.2.3 From c9d2e9bcfb77657b3be7d368e57f43747c23ddc4 Mon Sep 17 00:00:00 2001 From: Ascrod <32915892+Ascrod@users.noreply.github.com> Date: Sun, 24 Mar 2019 20:22:03 -0400 Subject: Remove obsolete getPref helpers. --- toolkit/components/blocklist/nsBlocklistService.js | 43 +++-------- .../components/search/current/nsSearchService.js | 26 ++----- .../components/search/orginal/nsSearchService.js | 26 ++----- .../timermanager/nsUpdateTimerManager.js | 32 ++------ toolkit/mozapps/update/content/updates.js | 28 +------ toolkit/mozapps/update/nsUpdateService.js | 89 ++++++++-------------- 6 files changed, 66 insertions(+), 178 deletions(-) (limited to 'toolkit') diff --git a/toolkit/components/blocklist/nsBlocklistService.js b/toolkit/components/blocklist/nsBlocklistService.js index 1cd2ed806..49033fc8f 100644 --- a/toolkit/components/blocklist/nsBlocklistService.js +++ b/toolkit/components/blocklist/nsBlocklistService.js @@ -168,27 +168,6 @@ function LOG(string) { } } -/** - * Gets a preference value, handling the case where there is no default. - * @param func - * The name of the preference function to call, on nsIPrefBranch - * @param preference - * The name of the preference - * @param defaultValue - * The default value to return in the event the preference has - * no setting - * @returns The value of the preference, or undefined if there was no - * user or default value. - */ -function getPref(func, preference, defaultValue) { - try { - return gPref[func](preference); - } - catch (e) { - } - return defaultValue; -} - /** * Constructs a URI to a spec. * @param spec @@ -297,9 +276,9 @@ function parseRegExp(aStr) { function Blocklist() { Services.obs.addObserver(this, "xpcom-shutdown", false); Services.obs.addObserver(this, "sessionstore-windows-restored", false); - gLoggingEnabled = getPref("getBoolPref", PREF_EM_LOGGING_ENABLED, false); - gBlocklistEnabled = getPref("getBoolPref", PREF_BLOCKLIST_ENABLED, true); - gBlocklistLevel = Math.min(getPref("getIntPref", PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL), + gLoggingEnabled = Services.prefs.getBoolPref(PREF_EM_LOGGING_ENABLED, false); + gBlocklistEnabled = Services.prefs.getBoolPref(PREF_BLOCKLIST_ENABLED, true); + gBlocklistLevel = Math.min(Services.prefs.getIntPref(PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL), MAX_BLOCK_LEVEL); gPref.addObserver("extensions.blocklist.", this, false); gPref.addObserver(PREF_EM_LOGGING_ENABLED, this, false); @@ -345,15 +324,15 @@ Blocklist.prototype = { case "nsPref:changed": switch (aData) { case PREF_EM_LOGGING_ENABLED: - gLoggingEnabled = getPref("getBoolPref", PREF_EM_LOGGING_ENABLED, false); + gLoggingEnabled = Services.prefs.getBoolPref(PREF_EM_LOGGING_ENABLED, false); break; case PREF_BLOCKLIST_ENABLED: - gBlocklistEnabled = getPref("getBoolPref", PREF_BLOCKLIST_ENABLED, true); + gBlocklistEnabled = Services.prefs.getBoolPref(PREF_BLOCKLIST_ENABLED, true); this._loadBlocklist(); this._blocklistUpdated(null, null); break; case PREF_BLOCKLIST_LEVEL: - gBlocklistLevel = Math.min(getPref("getIntPref", PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL), + gBlocklistLevel = Math.min(Services.prefs.getIntPref(PREF_BLOCKLIST_LEVEL, DEFAULT_LEVEL), MAX_BLOCK_LEVEL); this._blocklistUpdated(null, null); break; @@ -525,8 +504,8 @@ Blocklist.prototype = { return; } - var pingCountVersion = getPref("getIntPref", PREF_BLOCKLIST_PINGCOUNTVERSION, 0); - var pingCountTotal = getPref("getIntPref", PREF_BLOCKLIST_PINGCOUNTTOTAL, 1); + var pingCountVersion = Services.prefs.getIntPref(PREF_BLOCKLIST_PINGCOUNTVERSION, 0); + var pingCountTotal = Services.prefs.getIntPref(PREF_BLOCKLIST_PINGCOUNTTOTAL, 1); var daysSinceLastPing = 0; if (pingCountVersion == 0) { daysSinceLastPing = "new"; @@ -535,7 +514,7 @@ Blocklist.prototype = { // Seconds in one day is used because nsIUpdateTimerManager stores the // last update time in seconds. let secondsInDay = 60 * 60 * 24; - let lastUpdateTime = getPref("getIntPref", PREF_BLOCKLIST_LASTUPDATETIME, 0); + let lastUpdateTime = Services.prefs.getIntPref(PREF_BLOCKLIST_LASTUPDATETIME, 0); if (lastUpdateTime == 0) { daysSinceLastPing = "invalid"; } @@ -894,7 +873,7 @@ Blocklist.prototype = { return; } - var populateCertBlocklist = getPref("getBoolPref", PREF_ONECRL_VIA_AMO, true); + var populateCertBlocklist = Services.prefs.getBoolPref(PREF_ONECRL_VIA_AMO, true); var childNodes = doc.documentElement.childNodes; for (let element of childNodes) { @@ -1466,7 +1445,7 @@ Blocklist.prototype = { Services.obs.addObserver(applyBlocklistChanges, "addon-blocklist-closed", false); - if (getPref("getBoolPref", PREF_BLOCKLIST_SUPPRESSUI, false)) { + if (Services.prefs.getBoolPref(PREF_BLOCKLIST_SUPPRESSUI, false)) { applyBlocklistChanges(); return; } diff --git a/toolkit/components/search/current/nsSearchService.js b/toolkit/components/search/current/nsSearchService.js index 6e8f6da43..2a8601078 100644 --- a/toolkit/components/search/current/nsSearchService.js +++ b/toolkit/components/search/current/nsSearchService.js @@ -234,7 +234,7 @@ var LOG = function() {}; if (AppConstants.DEBUG) { LOG = function (aText) { - if (getBoolPref(BROWSER_SEARCH_PREF + "log", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "log", false)) { DO_LOG(aText); } }; @@ -907,18 +907,6 @@ function getLocalizedPref(aPrefName, aDefault) { return aDefault; } -/** - * Wrapper for nsIPrefBranch::getBoolPref. - * @param aPrefName - * The name of the pref to get. - * @returns aDefault if the requested pref doesn't exist. - */ -function getBoolPref(aName, aDefault) { - if (Services.prefs.getPrefType(aName) != Ci.nsIPrefBranch.PREF_BOOL) - return aDefault; - return Services.prefs.getBoolPref(aName); -} - /** * @return a sanitized name to be used as a filename, or a random name * if a sanitized name cannot be obtained (if aName contains @@ -1534,7 +1522,7 @@ Engine.prototype = { stringBundle.formatStringFromName("addEngineConfirmation", [this._name, this._uri.host], 2); var checkboxMessage = null; - if (!getBoolPref(BROWSER_SEARCH_PREF + "noCurrentEngine", false)) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "noCurrentEngine", false)) checkboxMessage = stringBundle.GetStringFromName("addEngineAsCurrentText"); var addButtonLabel = @@ -2658,7 +2646,7 @@ function checkForSyncCompletion(aPromise) { // nsIBrowserSearchService function SearchService() { // Replace empty LOG function with the useful one if the log pref is set. - if (getBoolPref(BROWSER_SEARCH_PREF + "log", false)) + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "log", false)) LOG = DO_LOG; this._initObservers = Promise.defer(); @@ -3770,7 +3758,7 @@ SearchService.prototype = { // If the user has specified a custom engine order, read the order // information from the metadata instead of the default prefs. - if (getBoolPref(BROWSER_SEARCH_PREF + "useDBForOrder", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "useDBForOrder", false)) { LOG("_buildSortedEngineList: using db for order"); // Flag to keep track of whether or not we need to call _saveSortedEngineList. @@ -4624,7 +4612,7 @@ SearchService.prototype = { notify: function SRCH_SVC_notify(aTimer) { LOG("_notify: checking for updates"); - if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true)) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update", true)) return; // Our timer has expired, but unfortunately, we can't get any data from it. @@ -4735,7 +4723,7 @@ const SEARCH_UPDATE_LOG_PREFIX = "*** Search update: "; * logging pref (browser.search.update.log) is set to true. */ function ULOG(aText) { - if (getBoolPref(BROWSER_SEARCH_PREF + "update.log", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update.log", false)) { dump(SEARCH_UPDATE_LOG_PREFIX + aText + "\n"); Services.console.logStringMessage(aText); } @@ -4751,7 +4739,7 @@ var engineUpdateService = { update: function eus_Update(aEngine) { let engine = aEngine.wrappedJSObject; ULOG("update called for " + aEngine._name); - if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates) return; let testEngine = null; diff --git a/toolkit/components/search/orginal/nsSearchService.js b/toolkit/components/search/orginal/nsSearchService.js index 6b23724a7..5b5ce7a57 100644 --- a/toolkit/components/search/orginal/nsSearchService.js +++ b/toolkit/components/search/orginal/nsSearchService.js @@ -248,7 +248,7 @@ function DO_LOG(aText) { * to allow enabling/disabling without a restart. */ function PREF_LOG(aText) { - if (getBoolPref(BROWSER_SEARCH_PREF + "log", false)) + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "log", false)) DO_LOG(aText); } var LOG = PREF_LOG; @@ -933,18 +933,6 @@ function setLocalizedPref(aPrefName, aValue) { } catch (ex) {} } -/** - * Wrapper for nsIPrefBranch::getBoolPref. - * @param aPrefName - * The name of the pref to get. - * @returns aDefault if the requested pref doesn't exist. - */ -function getBoolPref(aName, aDefault) { - if (Services.prefs.getPrefType(aName) != Ci.nsIPrefBranch.PREF_BOOL) - return aDefault; - return Services.prefs.getBoolPref(aName); -} - /** * Get a unique nsIFile object with a sanitized name, based on the engine name. * @param aName @@ -1591,7 +1579,7 @@ Engine.prototype = { stringBundle.formatStringFromName("addEngineConfirmation", [this._name, this._uri.host], 2); var checkboxMessage = null; - if (!getBoolPref(BROWSER_SEARCH_PREF + "noCurrentEngine", false)) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "noCurrentEngine", false)) checkboxMessage = stringBundle.GetStringFromName("addEngineAsCurrentText"); var addButtonLabel = @@ -2889,7 +2877,7 @@ function checkForSyncCompletion(aPromise) { // nsIBrowserSearchService function SearchService() { // Replace empty LOG function with the useful one if the log pref is set. - if (getBoolPref(BROWSER_SEARCH_PREF + "log", false)) + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "log", false)) LOG = DO_LOG; this._initObservers = Promise.defer(); @@ -3814,7 +3802,7 @@ SearchService.prototype = { // If the user has specified a custom engine order, read the order // information from the engineMetadataService instead of the default // prefs. - if (getBoolPref(BROWSER_SEARCH_PREF + "useDBForOrder", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "useDBForOrder", false)) { LOG("_buildSortedEngineList: using db for order"); // Flag to keep track of whether or not we need to call _saveSortedEngineList. @@ -4595,7 +4583,7 @@ SearchService.prototype = { notify: function SRCH_SVC_notify(aTimer) { LOG("_notify: checking for updates"); - if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true)) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update", true)) return; // Our timer has expired, but unfortunately, we can't get any data from it. @@ -4938,7 +4926,7 @@ const SEARCH_UPDATE_LOG_PREFIX = "*** Search update: "; * logging pref (browser.search.update.log) is set to true. */ function ULOG(aText) { - if (getBoolPref(BROWSER_SEARCH_PREF + "update.log", false)) { + if (Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update.log", false)) { dump(SEARCH_UPDATE_LOG_PREFIX + aText + "\n"); Services.console.logStringMessage(aText); } @@ -4955,7 +4943,7 @@ var engineUpdateService = { update: function eus_Update(aEngine) { let engine = aEngine.wrappedJSObject; ULOG("update called for " + aEngine._name); - if (!getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates) + if (!Services.prefs.getBoolPref(BROWSER_SEARCH_PREF + "update", true) || !engine._hasUpdates) return; let testEngine = null; diff --git a/toolkit/components/timermanager/nsUpdateTimerManager.js b/toolkit/components/timermanager/nsUpdateTimerManager.js index d7fc15960..3ba82f8c0 100644 --- a/toolkit/components/timermanager/nsUpdateTimerManager.js +++ b/toolkit/components/timermanager/nsUpdateTimerManager.js @@ -16,29 +16,9 @@ const PREF_APP_UPDATE_LOG = "app.update.log"; const CATEGORY_UPDATE_TIMER = "update-timer"; XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function tm_gLogEnabled() { - return getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); + return Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); }); -/** - * Gets a preference value, handling the case where there is no default. - * @param func - * The name of the preference function to call, on nsIPrefBranch - * @param preference - * The name of the preference - * @param defaultValue - * The default value to return in the event the preference has - * no setting - * @returns The value of the preference, or undefined if there was no - * user or default value. - */ -function getPref(func, preference, defaultValue) { - try { - return Services.prefs[func](preference); - } catch (e) { - } - return defaultValue; -} - /** * Logs a string to the error console. * @param string @@ -93,13 +73,13 @@ TimerManager.prototype = { minInterval = 500; minFirstInterval = 500; case "profile-after-change": - this._timerMinimumDelay = Math.max(1000 * getPref("getIntPref", PREF_APP_UPDATE_TIMERMINIMUMDELAY, 120), + this._timerMinimumDelay = Math.max(1000 * Services.prefs.getIntPref(PREF_APP_UPDATE_TIMERMINIMUMDELAY, 120), minInterval); // Prevent the timer delay between notifications to other consumers from // being greater than 5 minutes which is 300000 milliseconds. this._timerMinimumDelay = Math.min(this._timerMinimumDelay, 300000); // Prevent the first interval from being less than the value of minFirstInterval - let firstInterval = Math.max(getPref("getIntPref", PREF_APP_UPDATE_TIMERFIRSTINTERVAL, + let firstInterval = Math.max(Services.prefs.getIntPref(PREF_APP_UPDATE_TIMERFIRSTINTERVAL, 30000), minFirstInterval); // Prevent the first interval from being greater than 2 minutes which is // 120000 milliseconds. @@ -189,7 +169,7 @@ TimerManager.prototype = { continue; } - let interval = getPref("getIntPref", prefInterval, defaultInterval); + let interval = Services.prefs.getIntPref(prefInterval, defaultInterval); // Allow the update-timer category to specify a maximum value to prevent // values larger than desired. maxInterval = parseInt(maxInterval); @@ -200,7 +180,7 @@ TimerManager.prototype = { timerID); // Initialize the last update time to 0 when the preference isn't set so // the timer will be notified soon after a new profile's first use. - lastUpdateTime = getPref("getIntPref", prefLastUpdate, 0); + lastUpdateTime = Services.prefs.getIntPref(prefLastUpdate, 0); // If the last update time is greater than the current time then reset // it to 0 and the timer manager will correct the value when it fires @@ -315,7 +295,7 @@ TimerManager.prototype = { let prefLastUpdate = PREF_APP_UPDATE_LASTUPDATETIME_FMT.replace(/%ID%/, id); // Initialize the last update time to 0 when the preference isn't set so // the timer will be notified soon after a new profile's first use. - let lastUpdateTime = getPref("getIntPref", prefLastUpdate, 0); + let lastUpdateTime = Services.prefs.getIntPref(prefLastUpdate, 0); let now = Math.round(Date.now() / 1000); if (lastUpdateTime > now) { lastUpdateTime = 0; diff --git a/toolkit/mozapps/update/content/updates.js b/toolkit/mozapps/update/content/updates.js index 6e8de7275..9996014b5 100644 --- a/toolkit/mozapps/update/content/updates.js +++ b/toolkit/mozapps/update/content/updates.js @@ -84,28 +84,6 @@ function openUpdateURL(event) { openURL(event.target.getAttribute("url")); } -/** - * Gets a preference value, handling the case where there is no default. - * @param func - * The name of the preference function to call, on nsIPrefBranch - * @param preference - * The name of the preference - * @param defaultValue - * The default value to return in the event the preference has - * no setting - * @returns The value of the preference, or undefined if there was no - * user or default value. - */ -function getPref(func, preference, defaultValue) { - try { - return Services.prefs[func](preference); - } - catch (e) { - LOG("General", "getPref - failed to get preference: " + preference); - } - return defaultValue; -} - /** * A set of shared data and control functions for the wizard as a whole. */ @@ -320,7 +298,7 @@ var gUpdates = { onLoad: function() { this.wiz = document.documentElement; - gLogEnabled = getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); + gLogEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); this.strings = document.getElementById("updateStrings"); var brandStrings = document.getElementById("brandStrings"); @@ -601,7 +579,7 @@ var gNoUpdatesPage = { LOG("gNoUpdatesPage", "onPageShow - could not select an appropriate " + "update. Either there were no updates or |selectUpdate| failed"); - if (getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true)) + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true)) document.getElementById("noUpdatesAutoEnabled").hidden = false; else document.getElementById("noUpdatesAutoDisabled").hidden = false; @@ -1309,7 +1287,7 @@ var gFinishedPage = { moreElevatedLinkLabel.setAttribute("hidden", "false"); } - if (getPref("getBoolPref", PREF_APP_UPDATE_TEST_LOOP, false)) { + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_TEST_LOOP, false)) { setTimeout(function () { gUpdates.wiz.getButton("finish").click(); }, UPDATE_TEST_LOOP_INTERVAL); } diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index 4e2d66a5c..8b0167de6 100644 --- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -164,7 +164,7 @@ XPCOMUtils.defineLazyModuleGetter(this, "UpdateUtils", "resource://gre/modules/UpdateUtils.jsm"); XPCOMUtils.defineLazyGetter(this, "gLogEnabled", function aus_gLogEnabled() { - return getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); + return Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); }); XPCOMUtils.defineLazyGetter(this, "gUpdateBundle", function aus_gUpdateBundle() { @@ -494,7 +494,7 @@ XPCOMUtils.defineLazyGetter(this, "gCanStageUpdatesSession", function aus_gCSUS( */ function getCanStageUpdates() { // If staging updates are disabled, then just bail out! - if (!getPref("getBoolPref", PREF_APP_UPDATE_STAGING_ENABLED, false)) { + if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, false)) { LOG("getCanStageUpdates - staging updates is disabled by preference " + PREF_APP_UPDATE_STAGING_ENABLED); return false; @@ -514,7 +514,7 @@ XPCOMUtils.defineLazyGetter(this, "gCanCheckForUpdates", function aus_gCanCheckF // If the administrator has disabled app update and locked the preference so // users can't check for updates. This preference check is ok in this lazy // getter since locked prefs don't change until the application is restarted. - var enabled = getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true); + var enabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true); if (!enabled && Services.prefs.prefIsLocked(PREF_APP_UPDATE_ENABLED)) { LOG("gCanCheckForUpdates - unable to automatically check for updates, " + "the preference is disabled and admistratively locked."); @@ -550,27 +550,6 @@ function LOG(string) { } } -/** - * Gets a preference value, handling the case where there is no default. - * @param func - * The name of the preference function to call, on nsIPrefBranch - * @param preference - * The name of the preference - * @param defaultValue - * The default value to return in the event the preference has - * no setting - * @return The value of the preference, or undefined if there was no - * user or default value. - */ -function getPref(func, preference, defaultValue) { - try { - return Services.prefs[func](preference); - } - catch (e) { - } - return defaultValue; -} - /** * Convert a string containing binary values to hex. */ @@ -898,16 +877,15 @@ function handleUpdateFailure(update, errorCode) { } if (update.errorCode == ELEVATION_CANCELED) { - let cancelations = getPref("getIntPref", PREF_APP_UPDATE_CANCELATIONS, 0); + let cancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS, 0); cancelations++; Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS, cancelations); if (AppConstants.platform == "macosx") { - let osxCancelations = getPref("getIntPref", - PREF_APP_UPDATE_CANCELATIONS_OSX, 0); + let osxCancelations = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, 0); osxCancelations++; Services.prefs.setIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, osxCancelations); - let maxCancels = getPref("getIntPref", + let maxCancels = Services.prefs.getIntPref( PREF_APP_UPDATE_CANCELATIONS_OSX_MAX, DEFAULT_CANCELATIONS_OSX_MAX); // Prevent the preference from setting a value greater than 5. @@ -1177,8 +1155,8 @@ function Update(update) { this.showNeverForVersion = false; this.unsupported = false; this.channel = "default"; - this.promptWaitTime = getPref("getIntPref", PREF_APP_UPDATE_PROMPTWAITTIME, 43200); - this.backgroundInterval = getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDINTERVAL, + this.promptWaitTime = Services.prefs.getIntPref(PREF_APP_UPDATE_PROMPTWAITTIME, 43200); + this.backgroundInterval = Services.prefs.getIntPref(PREF_APP_UPDATE_BACKGROUNDINTERVAL, DOWNLOAD_BACKGROUND_INTERVAL); // Null , assume this is a message container and do no @@ -1558,7 +1536,7 @@ UpdateService.prototype = { break; case "nsPref:changed": if (data == PREF_APP_UPDATE_LOG) { - gLogEnabled = getPref("getBoolPref", PREF_APP_UPDATE_LOG, false); + gLogEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_LOG, false); } break; case "profile-change-net-teardown": // fall thru @@ -1795,11 +1773,11 @@ UpdateService.prototype = { // Send the error code to telemetry AUSTLMY.pingCheckExError(this._pingSuffix, update.errorCode); update.errorCode = BACKGROUNDCHECK_MULTIPLE_FAILURES; - let errCount = getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDERRORS, 0); + let errCount = Services.prefs.getIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, 0); errCount++; Services.prefs.setIntPref(PREF_APP_UPDATE_BACKGROUNDERRORS, errCount); // Don't allow the preference to set a value greater than 20 for max errors. - let maxErrors = Math.min(getPref("getIntPref", PREF_APP_UPDATE_BACKGROUNDMAXERRORS, 10), 20); + let maxErrors = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_BACKGROUNDMAXERRORS, 10), 20); if (errCount >= maxErrors) { let prompter = Cc["@mozilla.org/updates/update-prompt;1"]. @@ -1969,7 +1947,7 @@ UpdateService.prototype = { AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_INVALID_DEFAULT_URL); } - } else if (!getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true)) { + } else if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true)) { AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED); } else if (!hasUpdateMutex()) { AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_NO_MUTEX); @@ -2027,7 +2005,7 @@ UpdateService.prototype = { // (see bug 350636). let neverPrefName = PREFBRANCH_APP_UPDATE_NEVER + aUpdate.appVersion; if (aUpdate.showNeverForVersion && - getPref("getBoolPref", neverPrefName, false)) { + Services.prefs.getBoolPref(neverPrefName, false)) { LOG("UpdateService:selectUpdate - skipping update because the " + "preference " + neverPrefName + " is true"); lastCheckCode = AUSTLMY.CHK_UPDATE_NEVER_PREF; @@ -2058,7 +2036,7 @@ UpdateService.prototype = { let update = minorUpdate || majorUpdate; if (AppConstants.platform == "macosx" && update) { if (getElevationRequired()) { - let installAttemptVersion = getPref("getCharPref", + let installAttemptVersion = Services.prefs.getCharPref( PREF_APP_UPDATE_ELEVATE_VERSION, null); if (vc.compare(installAttemptVersion, update.appVersion) != 0) { @@ -2072,12 +2050,9 @@ UpdateService.prototype = { Services.prefs.clearUserPref(PREF_APP_UPDATE_ELEVATE_NEVER); } } else { - let numCancels = getPref("getIntPref", - PREF_APP_UPDATE_CANCELATIONS_OSX, 0); - let rejectedVersion = getPref("getCharPref", - PREF_APP_UPDATE_ELEVATE_NEVER, ""); - let maxCancels = getPref("getIntPref", - PREF_APP_UPDATE_CANCELATIONS_OSX_MAX, + let numCancels = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX, 0); + let rejectedVersion = Services.prefs.getCharPref(PREF_APP_UPDATE_ELEVATE_NEVER, ""); + let maxCancels = Services.prefs.getIntPref(PREF_APP_UPDATE_CANCELATIONS_OSX_MAX, DEFAULT_CANCELATIONS_OSX_MAX); if (numCancels >= maxCancels) { LOG("UpdateService:selectUpdate - the user requires elevation to " + @@ -2136,7 +2111,7 @@ UpdateService.prototype = { return; } - var updateEnabled = getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true); + var updateEnabled = Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true); if (!updateEnabled) { AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_PREF_DISABLED); LOG("UpdateService:_selectAndInstallUpdate - not prompting because " + @@ -2152,7 +2127,7 @@ UpdateService.prototype = { if (update.unsupported) { LOG("UpdateService:_selectAndInstallUpdate - update not supported for " + "this system"); - if (!getPref("getBoolPref", PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, false)) { + if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_NOTIFIEDUNSUPPORTED, false)) { LOG("UpdateService:_selectAndInstallUpdate - notifying that the " + "update is not supported for this system"); this._showPrompt(update); @@ -2193,7 +2168,7 @@ UpdateService.prototype = { return; } - if (!getPref("getBoolPref", PREF_APP_UPDATE_AUTO, true)) { + if (!Services.prefs.getBoolPref(PREF_APP_UPDATE_AUTO, true)) { LOG("UpdateService:_selectAndInstallUpdate - prompting because silent " + "install is disabled"); AUSTLMY.pingCheckCode(this._pingSuffix, AUSTLMY.CHK_SHOWPROMPT_PREF); @@ -2733,7 +2708,7 @@ UpdateManager.prototype = { Services.obs.notifyObservers(null, "update-staged", update.state); // Only prompt when the UI isn't already open. - let windowType = getPref("getCharPref", PREF_APP_UPDATE_ALTWINDOWTYPE, null); + let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, null); if (Services.wm.getMostRecentWindow(UPDATE_WINDOW_NAME) || windowType && Services.wm.getMostRecentWindow(windowType)) { return; @@ -2813,7 +2788,7 @@ Checker.prototype = { this._forced = force; // Use the override URL if specified. - let url = getPref("getCharPref", PREF_APP_UPDATE_URL_OVERRIDE, null); + let url = Services.prefs.getCharPref(PREF_APP_UPDATE_URL_OVERRIDE, null); // Otherwise, construct the update URL from component parts. if (!url) { @@ -3016,7 +2991,7 @@ Checker.prototype = { */ _enabled: true, get enabled() { - return getPref("getBoolPref", PREF_APP_UPDATE_ENABLED, true) && + return Services.prefs.getBoolPref(PREF_APP_UPDATE_ENABLED, true) && gCanCheckForUpdates && hasUpdateMutex() && this._enabled; }, @@ -3502,11 +3477,11 @@ Downloader.prototype = { var shouldRegisterOnlineObserver = false; var shouldRetrySoon = false; var deleteActiveUpdate = false; - var retryTimeout = getPref("getIntPref", PREF_APP_UPDATE_SOCKET_RETRYTIMEOUT, + var retryTimeout = Services.prefs.getIntPref(PREF_APP_UPDATE_SOCKET_RETRYTIMEOUT, DEFAULT_SOCKET_RETRYTIMEOUT); // Prevent the preference from setting a value greater than 10000. retryTimeout = Math.min(retryTimeout, 10000); - var maxFail = getPref("getIntPref", PREF_APP_UPDATE_SOCKET_MAXERRORS, + var maxFail = Services.prefs.getIntPref(PREF_APP_UPDATE_SOCKET_MAXERRORS, DEFAULT_SOCKET_MAX_ERRORS); // Prevent the preference from setting a value greater than 20. maxFail = Math.min(maxFail, 20); @@ -3762,7 +3737,7 @@ UpdatePrompt.prototype = { * See nsIUpdateService.idl */ showUpdateAvailable: function UP_showUpdateAvailable(update) { - if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) || + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) || this._getUpdateWindow() || this._getAltUpdateWindow()) { return; } @@ -3775,7 +3750,7 @@ UpdatePrompt.prototype = { * See nsIUpdateService.idl */ showUpdateDownloaded: function UP_showUpdateDownloaded(update, background) { - if (background && getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false)) { + if (background && Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false)) { return; } // Trigger the display of the hamburger menu badge. @@ -3797,7 +3772,7 @@ UpdatePrompt.prototype = { * See nsIUpdateService.idl */ showUpdateError: function UP_showUpdateError(update) { - if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) || + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) || this._getAltUpdateWindow()) return; @@ -3840,7 +3815,7 @@ UpdatePrompt.prototype = { * See nsIUpdateService.idl */ showUpdateElevationRequired: function UP_showUpdateElevationRequired() { - if (getPref("getBoolPref", PREF_APP_UPDATE_SILENT, false) || + if (Services.prefs.getBoolPref(PREF_APP_UPDATE_SILENT, false) || this._getAltUpdateWindow()) { return; } @@ -3864,7 +3839,7 @@ UpdatePrompt.prototype = { * application update user interface window. */ _getAltUpdateWindow: function UP__getAltUpdateWindow() { - let windowType = getPref("getCharPref", PREF_APP_UPDATE_ALTWINDOWTYPE, null); + let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, null); if (!windowType) return null; return Services.wm.getMostRecentWindow(windowType); @@ -3916,7 +3891,7 @@ UpdatePrompt.prototype = { var idleService = Cc["@mozilla.org/widget/idleservice;1"]. getService(Ci.nsIIdleService); // Don't allow the preference to set a value greater than 600 seconds for the idle time. - const IDLE_TIME = Math.min(getPref("getIntPref", PREF_APP_UPDATE_IDLETIME, 60), 600); + const IDLE_TIME = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_IDLETIME, 60), 600); if (idleService.idleTime / 1000 >= IDLE_TIME) { this._showUI(parent, uri, features, name, page, update); return; @@ -3961,7 +3936,7 @@ UpdatePrompt.prototype = { getService(Ci.nsIIdleService); // Don't allow the preference to set a value greater than 600 seconds for the idle time. - const IDLE_TIME = Math.min(getPref("getIntPref", PREF_APP_UPDATE_IDLETIME, 60), 600); + const IDLE_TIME = Math.min(Services.prefs.getIntPref(PREF_APP_UPDATE_IDLETIME, 60), 600); if (idleService.idleTime / 1000 >= IDLE_TIME) { this._showUI(parent, uri, features, name, page, update); } else { -- cgit v1.2.3 From 843e4ceffd6ce21a6e6db37419335eafdc543e18 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 28 Mar 2019 02:44:38 +0100 Subject: Replace unsupported `null` default values with an empty string. Fixes #1028 --- toolkit/mozapps/update/nsUpdateService.js | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'toolkit') diff --git a/toolkit/mozapps/update/nsUpdateService.js b/toolkit/mozapps/update/nsUpdateService.js index 8b0167de6..d9d09ba46 100644 --- a/toolkit/mozapps/update/nsUpdateService.js +++ b/toolkit/mozapps/update/nsUpdateService.js @@ -2038,7 +2038,7 @@ UpdateService.prototype = { if (getElevationRequired()) { let installAttemptVersion = Services.prefs.getCharPref( PREF_APP_UPDATE_ELEVATE_VERSION, - null); + ""); if (vc.compare(installAttemptVersion, update.appVersion) != 0) { Services.prefs.setCharPref(PREF_APP_UPDATE_ELEVATE_VERSION, update.appVersion); @@ -2708,7 +2708,7 @@ UpdateManager.prototype = { Services.obs.notifyObservers(null, "update-staged", update.state); // Only prompt when the UI isn't already open. - let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, null); + let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, ""); if (Services.wm.getMostRecentWindow(UPDATE_WINDOW_NAME) || windowType && Services.wm.getMostRecentWindow(windowType)) { return; @@ -2788,15 +2788,12 @@ Checker.prototype = { this._forced = force; // Use the override URL if specified. - let url = Services.prefs.getCharPref(PREF_APP_UPDATE_URL_OVERRIDE, null); + let url = Services.prefs.getCharPref(PREF_APP_UPDATE_URL_OVERRIDE, ""); // Otherwise, construct the update URL from component parts. if (!url) { - try { - url = Services.prefs.getDefaultBranch(null). - getCharPref(PREF_APP_UPDATE_URL); - } catch (e) { - } + url = Services.prefs.getDefaultBranch(null). + getCharPref(PREF_APP_UPDATE_URL, ""); } if (!url || url == "") { @@ -3839,7 +3836,7 @@ UpdatePrompt.prototype = { * application update user interface window. */ _getAltUpdateWindow: function UP__getAltUpdateWindow() { - let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, null); + let windowType = Services.prefs.getCharPref(PREF_APP_UPDATE_ALTWINDOWTYPE, ""); if (!windowType) return null; return Services.wm.getMostRecentWindow(windowType); -- cgit v1.2.3