From 9718200146a68e79c80fadce168bcd2f19b83e0f Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Mon, 24 Sep 2012 14:57:12 -0700 Subject: [PATCH] Bug 786095 - Initially disable Social API when in safe mode. r=felipe --- browser/base/content/browser-social.js | 2 +- browser/modules/Social.jsm | 6 +++++- toolkit/components/social/SocialService.jsm | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index fb12fbef1254..0c62080d8343 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -91,7 +91,7 @@ let SocialUI = { updateToggleCommand: function SocialUI_updateToggleCommand() { let toggleCommand = this.toggleCommand; - toggleCommand.setAttribute("checked", Social.enabled); + toggleCommand.setAttribute("checked", Services.prefs.getBoolPref("social.enabled")); // FIXME: bug 772808: menu items don't inherit the "hidden" state properly, // need to update them manually. diff --git a/browser/modules/Social.jsm b/browser/modules/Social.jsm index 1869fa119bdd..ffec034e60e0 100644 --- a/browser/modules/Social.jsm +++ b/browser/modules/Social.jsm @@ -19,7 +19,10 @@ XPCOMUtils.defineLazyModuleGetter(this, "SocialService", let Social = { lastEventReceived: 0, provider: null, + _disabledForSafeMode: false, init: function Social_init(callback) { + this._disabledForSafeMode = Services.appinfo.inSafeMode && this.enabled; + if (this.provider) { schedule(callback); return; @@ -54,7 +57,8 @@ let Social = { }, toggle: function Social_toggle() { - this.enabled = !this.enabled; + this.enabled = this._disabledForSafeMode ? false : !this.enabled; + this._disabledForSafeMode = false; }, toggleSidebar: function SocialSidebar_toggle() { diff --git a/toolkit/components/social/SocialService.jsm b/toolkit/components/social/SocialService.jsm index b13b60ace7e6..e4d8f04f4b6c 100644 --- a/toolkit/components/social/SocialService.jsm +++ b/toolkit/components/social/SocialService.jsm @@ -59,11 +59,13 @@ XPCOMUtils.defineLazyGetter(SocialServiceInternal, "providers", function () { let providers = {}; let MANIFEST_PREFS = Services.prefs.getBranch("social.manifest."); let prefs = MANIFEST_PREFS.getChildList("", {}); + let appinfo = Cc["@mozilla.org/xre/app-info;1"] + .getService(Ci.nsIXULRuntime); prefs.forEach(function (pref) { try { var manifest = JSON.parse(MANIFEST_PREFS.getCharPref(pref)); if (manifest && typeof(manifest) == "object") { - let provider = new SocialProvider(manifest, SocialServiceInternal.enabled); + let provider = new SocialProvider(manifest, appinfo.inSafeMode ? false : SocialServiceInternal.enabled); providers[provider.origin] = provider; } } catch (err) { @@ -86,7 +88,11 @@ const SocialService = { }, set enabled(val) { let enable = !!val; - if (enable == SocialServiceInternal.enabled) + + // Allow setting to the same value when in safe mode so the + // feature can be force enabled. + if (enable == SocialServiceInternal.enabled && + !Services.appinfo.inSafeMode) return; Services.prefs.setBoolPref("social.enabled", enable);