Bug 786095 - Initially disable Social API when in safe mode. r=felipe

This commit is contained in:
Jared Wein 2012-09-24 14:57:12 -07:00
Родитель 4af416bc9c
Коммит 9718200146
3 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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() {

Просмотреть файл

@ -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);