[Pkg-mozext-commits] [adblock-plus] 08/22: Issue 293 - AdBlock button is slow to appear on toolbar after launching Firefox
David Prévot
taffit at moszumanska.debian.org
Thu Jun 5 14:01:09 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository adblock-plus.
commit 98d75fc2890a315acfb9c0692c8b3fe4c8fa37ba
Author: Wladimir Palant <trev at adblockplus.org>
Date: Fri May 23 13:30:34 2014 +0200
Issue 293 - AdBlock button is slow to appear on toolbar after launching Firefox
---
lib/ui.js | 119 +++++++++++++++++++++++++++++++++++---------------------------
1 file changed, 68 insertions(+), 51 deletions(-)
diff --git a/lib/ui.js b/lib/ui.js
index 2262a80..e61200a 100644
--- a/lib/ui.js
+++ b/lib/ui.js
@@ -284,6 +284,9 @@ let UI = exports.UI =
this.processOverlay(request.responseXML.documentElement);
+ // Don't wait for the rest of the startup sequence, add icon already
+ this.addToolbarButton();
+
overlayLoaded = true;
if (overlayLoaded && filtersLoaded && sessionRestored)
this.initDone();
@@ -396,10 +399,59 @@ let UI = exports.UI =
*/
initDone: function()
{
+ // The icon might be added already, make sure its state is correct
+ this.updateState();
+
+ // Listen for pref and filters changes
+ Prefs.addListener(function(name)
+ {
+ if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaultstatusbaraction")
+ this.updateState();
+ else if (name == "showinstatusbar")
+ {
+ for (let window in this.applicationWindows)
+ this.updateStatusbarIcon(window);
+ }
+ }.bind(this));
+ FilterNotifier.addListener(function(action)
+ {
+ if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(action) || action == "load")
+ this.updateState();
+ }.bind(this));
+
+ notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
+ notificationTimer.initWithCallback(this.showNextNotification.bind(this),
+ 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT);
+ onShutdown.add(function() notificationTimer.cancel());
+
+ // Add "anti-adblock messages" notification
+ initAntiAdblockNotification();
+
+ let documentCreationObserver = {
+ observe: function(subject, topic, data)
+ {
+ if (!(subject instanceof Ci.nsIDOMWindow))
+ return;
+
+ this.showNextNotification(subject.location.href);
+ }.bind(UI)
+ };
+ Services.obs.addObserver(documentCreationObserver, "content-document-global-created", false);
+ onShutdown.add(function()
+ {
+ Services.obs.removeObserver(documentCreationObserver, "content-document-global-created", false);
+ });
+
+ // Execute first-run actions if a window is open already, otherwise it
+ // will happen in applyToWindow() when a window is opened.
+ this.firstRunActions(this.currentWindow);
+ },
+
+ addToolbarButton: function()
+ {
let {WindowObserver} = require("windowObserver");
new WindowObserver(this);
- // Add toolbar icon
let {defaultToolbarPosition} = require("appSupport");
if ("abp-toolbarbutton" in this.overlay && defaultToolbarPosition)
{
@@ -412,7 +464,7 @@ let UI = exports.UI =
// No built-in CustomizableUI API, use our own implementation.
({CustomizableUI}) = require("customizableUI");
}
-
+
CustomizableUI.createWidget({
id: "abp-toolbarbutton",
type: "custom",
@@ -438,46 +490,22 @@ let UI = exports.UI =
});
onShutdown.add(CustomizableUI.destroyWidget.bind(CustomizableUI, "abp-toolbarbutton"));
}
+ },
- // Listen for pref and filters changes
- Prefs.addListener(function(name)
- {
- if (name == "enabled" || name == "defaulttoolbaraction" || name == "defaultstatusbaraction")
- this.updateState();
- else if (name == "showinstatusbar")
- {
- for (let window in this.applicationWindows)
- this.updateStatusbarIcon(window);
- }
- }.bind(this));
- FilterNotifier.addListener(function(action)
- {
- if (/^(filter|subscription)\.(added|removed|disabled|updated)$/.test(action) || action == "load")
- this.updateState();
- }.bind(this));
-
- notificationTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
- notificationTimer.initWithCallback(this.showNextNotification.bind(this),
- 3 * 60 * 1000, Ci.nsITimer.TYPE_ONE_SHOT);
- onShutdown.add(function() notificationTimer.cancel());
-
- // Add "anti-adblock messages" notification
- initAntiAdblockNotification();
+ firstRunActions: function(window)
+ {
+ if (this.firstRunDone || !window || FilterStorage._loading)
+ return;
- let documentCreationObserver = {
- observe: function(subject, topic, data)
- {
- if (!(subject instanceof Ci.nsIDOMWindow))
- return;
+ this.firstRunDone = true;
- this.showNextNotification(subject.location.href);
- }.bind(UI)
- };
- Services.obs.addObserver(documentCreationObserver, "content-document-global-created", false);
- onShutdown.add(function()
+ let {addonVersion} = require("info");
+ let prevVersion = Prefs.currentVersion;
+ if (prevVersion != addonVersion)
{
- Services.obs.removeObserver(documentCreationObserver, "content-document-global-created", false);
- });
+ Prefs.currentVersion = addonVersion;
+ this.addSubscription(window, prevVersion);
+ }
},
/**
@@ -551,18 +579,7 @@ let UI = exports.UI =
}, false);
// First-run actions?
- if (!this.firstRunDone)
- {
- this.firstRunDone = true;
-
- let {addonVersion} = require("info");
- let prevVersion = Prefs.currentVersion;
- if (prevVersion != addonVersion)
- {
- Prefs.currentVersion = addonVersion;
- this.addSubscription(window, prevVersion);
- }
- }
+ this.firstRunActions(window);
// Some people actually switch off browser.frames.enabled and are surprised
// that things stop working...
@@ -1076,7 +1093,7 @@ let UI = exports.UI =
if (location && Policy.isWhitelisted(location.spec))
state = "whitelisted";
}
-
+
let popupId = "abp-status-popup";
if (icon.localName == "statusbarpanel")
{
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/adblock-plus.git
More information about the Pkg-mozext-commits
mailing list