Backed out changeset fc5225b5022b (bug 1101478) for causing bug 1103966.

This commit is contained in:
Ryan VanderMeulen 2014-12-10 10:02:17 -05:00
Родитель 5d3df25f61
Коммит 9fd87ba59e
1 изменённых файлов: 37 добавлений и 27 удалений

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

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