Bug 1101478 - Remove the WindowsJumpLists.jsm depedency on hasHistoryEntries. r=jimm

--HG--
extra : rebase_source : 70a9d7a7d4d302ba30dd88d9af01ac61537191ce
extra : histedit_source : 67c597fc0b1bb518aadb15ba4458f92637cb7275%2C20fc9edaf1d6d93ecc669163dc6f26ff86ac5c0b
This commit is contained in:
Marco Bonardo 2014-11-21 12:50:35 +01:00
parent 73e5db56dd
commit 9a4b237bc4

View File

@ -52,15 +52,11 @@ XPCOMUtils.defineLazyGetter(this, "_stringBundle", function() {
.createBundle("chrome://browser/locale/taskbar.properties");
});
XPCOMUtils.defineLazyGetter(this, "PlacesUtils", function() {
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
return PlacesUtils;
});
XPCOMUtils.defineLazyModuleGetter(this, "PlacesUtils",
"resource://gre/modules/PlacesUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "NetUtil", function() {
Components.utils.import("resource://gre/modules/NetUtil.jsm");
return NetUtil;
});
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
"resource://gre/modules/NetUtil.jsm");
XPCOMUtils.defineLazyServiceGetter(this, "_idle",
"@mozilla.org/widget/idleservice;1",
@ -77,6 +73,16 @@ XPCOMUtils.defineLazyServiceGetter(this, "_winShellService",
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
XPCOMUtils.defineLazyGetter(this, "gHistoryObserver", function() {
return Object.freeze({
onClearHistory() {
WinTaskbarJumpList.update();
},
QueryInterface: XPCOMUtils.generateQI(Ci.nsINavHistoryObserver),
__noSuchMethod__: () => {}, // Catch all of the other notifications.
});
});
/**
* Global functions
*/
@ -146,7 +152,7 @@ this.WinTaskbarJumpList =
/**
* Startup, shutdown, and update
*/
*/
startup: function WTBJL_startup() {
// exit if this isn't win7 or higher.
@ -155,7 +161,7 @@ this.WinTaskbarJumpList =
// Win shell shortcut maintenance. If we've gone through an update,
// this will update any pinned taskbar shortcuts. Not specific to
// jump lists, but this was a convienent place to call it.
// jump lists, but this was a convienent place to call it.
try {
// dev builds may not have helper.exe, ignore failures.
this._shortcutMaintenance();
@ -186,14 +192,6 @@ this.WinTaskbarJumpList =
_shutdown: function WTBJL__shutdown() {
this._shuttingDown = true;
// Correctly handle a clear history on shutdown. If there are no
// entries be sure to empty all history lists. Luckily Places caches
// this value, so it's a pretty fast call.
if (!PlacesUtils.history.hasHistoryEntries) {
this.update();
}
this._free();
},
@ -253,13 +251,13 @@ this.WinTaskbarJumpList =
/**
* Taskbar api wrappers
*/
*/
_startBuild: function WTBJL__startBuild() {
var removedItems = Cc["@mozilla.org/array;1"].
createInstance(Ci.nsIMutableArray);
this._builder.abortListBuild();
if (this._builder.initListBuild(removedItems)) {
if (this._builder.initListBuild(removedItems)) {
// Prior to building, delete removed items from history.
this._clearHistory(removedItems);
return true;
@ -283,7 +281,7 @@ this.WinTaskbarJumpList =
task.args, task.iconIndex, null);
items.appendElement(item, false);
}, this);
if (items.length > 0)
this._builder.addListToBuild(this._builder.JUMPLIST_CATEGORY_TASKS, items);
},
@ -294,11 +292,6 @@ this.WinTaskbarJumpList =
},
_buildFrequent: function WTBJL__buildFrequent() {
// If history is empty, just bail out.
if (!PlacesUtils.history.hasHistoryEntries) {
return;
}
// Windows supports default frequent and recent lists,
// but those depend on internal windows visit tracking
// which we don't populate. So we build our own custom
@ -324,7 +317,7 @@ this.WinTaskbarJumpList =
let title = aResult.title || aResult.uri;
let faviconPageUri = Services.io.newURI(aResult.uri, null, null);
let shortcut = this._getHandlerAppItem(title, title, aResult.uri, 1,
let shortcut = this._getHandlerAppItem(title, title, aResult.uri, 1,
faviconPageUri);
items.appendElement(shortcut, false);
this._frequentHashList.push(aResult.uri);
@ -334,11 +327,6 @@ this.WinTaskbarJumpList =
},
_buildRecent: function WTBJL__buildRecent() {
// If history is empty, just bail out.
if (!PlacesUtils.history.hasHistoryEntries) {
return;
}
var items = Cc["@mozilla.org/array;1"].
createInstance(Ci.nsIMutableArray);
// Frequent items will be skipped, so we select a double amount of
@ -386,8 +374,8 @@ this.WinTaskbarJumpList =
* Jump list item creation helpers
*/
_getHandlerAppItem: function WTBJL__getHandlerAppItem(name, description,
args, iconIndex,
_getHandlerAppItem: function WTBJL__getHandlerAppItem(name, description,
args, iconIndex,
faviconPageUri) {
var file = Services.dirsvc.get("XREExeF", Ci.nsILocalFile);
@ -469,7 +457,7 @@ this.WinTaskbarJumpList =
/**
* Prefs utilities
*/
*/
_refreshPrefs: function WTBJL__refreshPrefs() {
this._enabled = _prefs.getBoolPref(PREF_TASKBAR_ENABLED);
@ -481,7 +469,7 @@ this.WinTaskbarJumpList =
/**
* Init and shutdown utilities
*/
*/
_initTaskbar: function WTBJL__initTaskbar() {
this._builder = _taskbarService.createJumpListBuilder();
@ -498,12 +486,14 @@ this.WinTaskbarJumpList =
Services.obs.addObserver(this, "profile-before-change", false);
Services.obs.addObserver(this, "browser:purge-session-history", false);
_prefs.addObserver("", this, false);
PlacesUtils.history.addObserver(gHistoryObserver, false);
},
_freeObs: function WTBJL__freeObs() {
Services.obs.removeObserver(this, "profile-before-change");
Services.obs.removeObserver(this, "browser:purge-session-history");
_prefs.removeObserver("", this);
PlacesUtils.history.removeObserver(gHistoryObserver);
},
_updateTimer: function WTBJL__updateTimer() {