From edf74f7438e74b98448e984f643610c02f477fa6 Mon Sep 17 00:00:00 2001 From: Blair McBride Date: Thu, 2 Sep 2010 11:40:20 +1200 Subject: [PATCH] Bug 566194 - safe mode / security & compatibility check status are not exposed in new addon manager UI. r=dtownsend, a=blocking-beta6 --- .../chrome/mozapps/extensions/extensions.dtd | 9 + .../mozapps/extensions/content/extensions.css | 7 + .../mozapps/extensions/content/extensions.js | 73 ++++ .../mozapps/extensions/content/extensions.xul | 367 +++++++++++------- .../extensions/test/browser/Makefile.in | 1 + .../test/browser/browser_globalwarnings.js | 65 ++++ .../mozapps/extensions/extensions.css | 70 ++-- .../mozapps/extensions/warning-stripes.png | Bin 0 -> 2177 bytes toolkit/themes/gnomestripe/mozapps/jar.mn | 1 + .../mozapps/extensions/extensions.css | 70 ++-- .../mozapps/extensions/warning-stripes.png | Bin 0 -> 2177 bytes toolkit/themes/pinstripe/mozapps/jar.mn | 1 + .../mozapps/extensions/extensions.css | 79 ++-- .../mozapps/extensions/warning-stripes.png | Bin 0 -> 2177 bytes toolkit/themes/winstripe/mozapps/jar.mn | 2 + 15 files changed, 523 insertions(+), 222 deletions(-) create mode 100644 toolkit/mozapps/extensions/test/browser/browser_globalwarnings.js create mode 100644 toolkit/themes/gnomestripe/mozapps/extensions/warning-stripes.png create mode 100644 toolkit/themes/pinstripe/mozapps/extensions/warning-stripes.png create mode 100644 toolkit/themes/winstripe/mozapps/extensions/warning-stripes.png diff --git a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd b/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd index 57da04ba4ba..2cf59992044 100644 --- a/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd +++ b/toolkit/locales/en-US/chrome/mozapps/extensions/extensions.dtd @@ -13,6 +13,15 @@ + + + + + + + + + diff --git a/toolkit/mozapps/extensions/content/extensions.css b/toolkit/mozapps/extensions/content/extensions.css index 29d4b9cdf2b..96080e00b28 100644 --- a/toolkit/mozapps/extensions/content/extensions.css +++ b/toolkit/mozapps/extensions/content/extensions.css @@ -123,3 +123,10 @@ xhtml|link { .view-pane:not(#updates-view) .addon .relnotes-toggle { display: none; } + +#addons-page:not([warning]) .global-warning, +#addons-page:not([warning="safemode"]) .global-warning-safemode, +#addons-page:not([warning="checkcompatibility"]) .global-warning-checkcompatibility, +#addons-page:not([warning="updatesecurity"]) .global-warning-updatesecurity { + display: none; +} diff --git a/toolkit/mozapps/extensions/content/extensions.js b/toolkit/mozapps/extensions/content/extensions.js index 5ecbe0ded0a..56af0db3028 100644 --- a/toolkit/mozapps/extensions/content/extensions.js +++ b/toolkit/mozapps/extensions/content/extensions.js @@ -51,6 +51,10 @@ Cu.import("resource://gre/modules/AddonRepository.jsm"); const PREF_DISCOVERURL = "extensions.webservice.discoverURL"; const PREF_MAXRESULTS = "extensions.getAddons.maxResults"; const PREF_BACKGROUND_UPDATE = "extensions.update.enabled"; +const PREF_CHECK_COMPATIBILITY = "extensions.checkCompatibility"; +const PREF_CHECK_UPDATE_SECURITY = "extensions.checkUpdateSecurity"; + +const BRANCH_REGEXP = /^([^\.]+\.[0-9]+[a-z]*).*/gi; const LOADING_MSG_DELAY = 100; @@ -142,6 +146,7 @@ function loadView(aViewId) { var gEventManager = { _listeners: {}, _installListeners: [], + checkCompatibilityPref: "", initialize: function() { var self = this; @@ -164,9 +169,20 @@ var gEventManager = { }); AddonManager.addInstallListener(this); AddonManager.addAddonListener(this); + + var version = Services.appinfo.version.replace(BRANCH_REGEXP, "$1"); + this.checkCompatibilityPref = PREF_CHECK_COMPATIBILITY + "." + version; + + Services.prefs.addObserver(this.checkCompatibilityPref, this, false); + Services.prefs.addObserver(PREF_CHECK_UPDATE_SECURITY, this, false); + + this.refreshGlobalWarning(); }, shutdown: function() { + Services.prefs.removeObserver(this.checkCompatibilityPref, this); + Services.prefs.removeObserver(PREF_CHECK_UPDATE_SECURITY, this); + AddonManager.removeInstallListener(this); AddonManager.removeAddonListener(this); }, @@ -244,6 +260,49 @@ var gEventManager = { Cu.reportError(e); } } + }, + + refreshGlobalWarning: function() { + var page = document.getElementById("addons-page"); + + if (Services.appinfo.inSafeMode) { + page.setAttribute("warning", "safemode"); + return; + } + + var checkUpdateSecurity = true; + var checkUpdateSecurityDefault = true; + try { + checkUpdateSecurity = Services.prefs.getBoolPref(PREF_CHECK_UPDATE_SECURITY); + } catch(e) { } + try { + var defaultBranch = Services.prefs.getDefaultBranch(""); + checkUpdateSecurityDefault = defaultBranch.getBoolPref(PREF_CHECK_UPDATE_SECURITY); + } catch(e) { } + if (checkUpdateSecurityDefault && !checkUpdateSecurity) { + page.setAttribute("warning", "updatesecurity"); + return; + } + + var checkCompatibility = true; + try { + checkCompatibility = Services.prefs.getBoolPref(this.checkCompatibilityPref); + } catch(e) { } + if (!checkCompatibility) { + page.setAttribute("warning", "checkcompatibility"); + return; + } + + page.removeAttribute("warning"); + }, + + observe: function(aSubject, aTopic, aData) { + switch (aData) { + case this.checkCompatibilityPref: + case PREF_CHECK_UPDATE_SECURITY: + this.refreshGlobalWarning(); + break; + } } }; @@ -440,6 +499,20 @@ var gViewController = { } }, + cmd_enableCheckCompatibility: { + isEnabled: function() true, + doCommand: function() { + Services.prefs.clearUserPref(gEventManager.checkCompatibilityPref); + } + }, + + cmd_enableUpdateSecurity: { + isEnabled: function() true, + doCommand: function() { + Services.prefs.clearUserPref(PREF_CHECK_UPDATE_SECURITY); + } + }, + cmd_goToDiscoverPane: { isEnabled: function() { return gDiscoverView.enabled; diff --git a/toolkit/mozapps/extensions/content/extensions.xul b/toolkit/mozapps/extensions/content/extensions.xul index 0734c5ea4e1..707df333b4c 100644 --- a/toolkit/mozapps/extensions/content/extensions.xul +++ b/toolkit/mozapps/extensions/content/extensions.xul @@ -98,6 +98,8 @@ + + @@ -234,7 +236,26 @@ tooltiptext="&search.filter2.available.tooltip;"/> - + + + + +