mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-17 07:15:46 +00:00
Bug 1309946 - disable addonwatcher for easy uplift, r=Yoric
MozReview-Commit-ID: 1mjO3oPhSOw --HG-- extra : rebase_source : 189e36fc00428000fc66dbd3087e94293b6a4f23
This commit is contained in:
parent
dad56d4819
commit
df4c4fd5f5
@ -385,9 +385,6 @@ BrowserGlue.prototype = {
|
||||
case "test-initialize-sanitizer":
|
||||
this._sanitizer.onStartup();
|
||||
break;
|
||||
case AddonWatcher.TOPIC_SLOW_ADDON_DETECTED:
|
||||
this._notifySlowAddon(data);
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -427,10 +424,6 @@ BrowserGlue.prototype = {
|
||||
os.addObserver(this, "flash-plugin-hang", false);
|
||||
os.addObserver(this, "xpi-signature-changed", false);
|
||||
|
||||
if (AppConstants.NIGHTLY_BUILD) {
|
||||
os.addObserver(this, AddonWatcher.TOPIC_SLOW_ADDON_DETECTED, false);
|
||||
}
|
||||
|
||||
this._flashHangCount = 0;
|
||||
this._firstWindowReady = new Promise(resolve => this._firstWindowLoaded = resolve);
|
||||
|
||||
@ -486,116 +479,6 @@ BrowserGlue.prototype = {
|
||||
this._distributionCustomizer.applyPrefDefaults();
|
||||
},
|
||||
|
||||
_notifySlowAddon: function BG_notifySlowAddon(addonId) {
|
||||
let addonCallback = function(addon) {
|
||||
if (!addon) {
|
||||
Cu.reportError("couldn't look up addon: " + addonId);
|
||||
return;
|
||||
}
|
||||
let win = RecentWindow.getMostRecentBrowserWindow();
|
||||
|
||||
if (!win) {
|
||||
return;
|
||||
}
|
||||
|
||||
let brandBundle = win.document.getElementById("bundle_brand");
|
||||
let brandShortName = brandBundle.getString("brandShortName");
|
||||
let message = win.gNavigatorBundle.getFormattedString("addonwatch.slow", [addon.name, brandShortName]);
|
||||
let notificationBox = win.document.getElementById("global-notificationbox");
|
||||
let notificationId = "addon-slow:" + addonId;
|
||||
let notification = notificationBox.getNotificationWithValue(notificationId);
|
||||
|
||||
// Monitor the response of users
|
||||
const STATE_WARNING_DISPLAYED = 0;
|
||||
const STATE_USER_PICKED_DISABLE = 1;
|
||||
const STATE_USER_PICKED_IGNORE_FOR_NOW = 2;
|
||||
const STATE_USER_PICKED_IGNORE_FOREVER = 3;
|
||||
const STATE_USER_CLOSED_NOTIFICATION = 4;
|
||||
|
||||
let update = function(response) {
|
||||
Services.telemetry.getHistogramById("SLOW_ADDON_WARNING_STATES").add(response);
|
||||
}
|
||||
|
||||
let complete = false;
|
||||
let start = Date.now();
|
||||
let done = function(response) {
|
||||
// Only report the first reason for closing.
|
||||
if (complete) {
|
||||
return;
|
||||
}
|
||||
complete = true;
|
||||
update(response);
|
||||
Services.telemetry.getHistogramById("SLOW_ADDON_WARNING_RESPONSE_TIME").add(Date.now() - start);
|
||||
};
|
||||
|
||||
update(STATE_WARNING_DISPLAYED);
|
||||
|
||||
if (notification) {
|
||||
notification.label = message;
|
||||
} else {
|
||||
let buttons = [
|
||||
{
|
||||
label: win.gNavigatorBundle.getFormattedString("addonwatch.disable.label", [addon.name]),
|
||||
accessKey: "", // workaround for bug 1192901
|
||||
callback() {
|
||||
done(STATE_USER_PICKED_DISABLE);
|
||||
addon.userDisabled = true;
|
||||
if (addon.pendingOperations == addon.PENDING_NONE) {
|
||||
return;
|
||||
}
|
||||
let restartMessage = win.gNavigatorBundle.getFormattedString("addonwatch.restart.message", [addon.name, brandShortName]);
|
||||
let restartButton = [
|
||||
{
|
||||
label: win.gNavigatorBundle.getFormattedString("addonwatch.restart.label", [brandShortName]),
|
||||
accessKey: win.gNavigatorBundle.getString("addonwatch.restart.accesskey"),
|
||||
callback() {
|
||||
let appStartup = Cc["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Ci.nsIAppStartup);
|
||||
appStartup.quit(appStartup.eForceQuit | appStartup.eRestart);
|
||||
}
|
||||
}
|
||||
];
|
||||
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
|
||||
notificationBox.appendNotification(restartMessage, "restart-" + addonId, "",
|
||||
priority, restartButton);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: win.gNavigatorBundle.getString("addonwatch.ignoreSession.label"),
|
||||
accessKey: win.gNavigatorBundle.getString("addonwatch.ignoreSession.accesskey"),
|
||||
callback() {
|
||||
done(STATE_USER_PICKED_IGNORE_FOR_NOW);
|
||||
AddonWatcher.ignoreAddonForSession(addonId);
|
||||
}
|
||||
},
|
||||
{
|
||||
label: win.gNavigatorBundle.getString("addonwatch.ignorePerm.label"),
|
||||
accessKey: win.gNavigatorBundle.getString("addonwatch.ignorePerm.accesskey"),
|
||||
callback() {
|
||||
done(STATE_USER_PICKED_IGNORE_FOREVER);
|
||||
AddonWatcher.ignoreAddonPermanently(addonId);
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
const priority = notificationBox.PRIORITY_WARNING_MEDIUM;
|
||||
notification = notificationBox.appendNotification(
|
||||
message, notificationId, "",
|
||||
priority, buttons,
|
||||
function(topic) {
|
||||
if (topic == "removed") {
|
||||
// Other callbacks are called before this one and only the first
|
||||
// call to `done` is taken into account, so if this call to `done`
|
||||
// gets through, this means that the user has closed the notification
|
||||
// manually.
|
||||
done(STATE_USER_CLOSED_NOTIFICATION);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
AddonManager.getAddonByID(addonId, addonCallback);
|
||||
},
|
||||
|
||||
// runs on startup, before the first command line handler is invoked
|
||||
// (i.e. before the first window is opened)
|
||||
_finalUIStartup: function BG__finalUIStartup() {
|
||||
|
@ -5406,11 +5406,7 @@ pref("intl.allow-insecure-text-input", false);
|
||||
pref("dom.meta-viewport.enabled", false);
|
||||
|
||||
// The interval at which to check for slow running addons
|
||||
#ifdef NIGHTLY_BUILD
|
||||
pref("browser.addon-watch.interval", 15000);
|
||||
#else
|
||||
pref("browser.addon-watch.interval", -1);
|
||||
#endif
|
||||
pref("browser.addon-watch.ignore", "[\"mochikit@mozilla.org\",\"special-powers@mozilla.org\",\"fxdevtools-adapters@mozilla.org\",\"fx-devtools\",\"webcompat-reporter@mozilla.org\"]");
|
||||
|
||||
// Search service settings
|
||||
|
@ -45,6 +45,9 @@ this.AddonWatcher = {
|
||||
TOPIC_SLOW_ADDON_DETECTED: "addon-watcher-detected-slow-addon",
|
||||
|
||||
init() {
|
||||
if (Preferences.get("browser.addon-watch.interval", -1) == -1) {
|
||||
return;
|
||||
}
|
||||
this._initializedTimeStamp = Cu.now();
|
||||
|
||||
try {
|
||||
|
@ -8,6 +8,7 @@ support-files =
|
||||
browser_compartments_script.js
|
||||
|
||||
[browser_AddonWatcher.js]
|
||||
skip-if = true
|
||||
[browser_compartments.js]
|
||||
skip-if = os == "linux" && !debug && e10s # Bug 1230018
|
||||
[browser_addonPerformanceAlerts.js]
|
||||
|
Loading…
Reference in New Issue
Block a user