Bug 692295 - Remove nsWindowsShellService's ShortcutMaintenance method and calls now that it is no longer needed. r=jimm
Removes nsIWindowsShellService.idl since there are no longer custom methods and it can just use nsIShellService.idl
Removes a couple of includes that are no longer used and should have been removed after the code to delete Firefox prefetch files was removed

/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- *//* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */const{classes:Cc,interfaces:Ci,results:Cr,utils:Cu}=Components;Cu.import("resource://gre/modules/XPCOMUtils.jsm");Cu.import("resource://gre/modules/Services.jsm");// Stop updating jumplists after some idle time.constIDLE_TIMEOUT_SECONDS=5*60;// PrefsconstPREF_TASKBAR_BRANCH="browser.taskbar.lists.";constPREF_TASKBAR_ENABLED="enabled";constPREF_TASKBAR_ITEMCOUNT="maxListItemCount";constPREF_TASKBAR_FREQUENT="frequent.enabled";constPREF_TASKBAR_RECENT="recent.enabled";constPREF_TASKBAR_TASKS="tasks.enabled";constPREF_TASKBAR_REFRESH="refreshInSeconds";// Hash keys for pendingStatements.constLIST_TYPE={FREQUENT:0,RECENT:1}/** * Exports */this.EXPORTED_SYMBOLS=["WinTaskbarJumpList",];/** * Smart getters */XPCOMUtils.defineLazyGetter(this,"_prefs",function(){returnServices.prefs.getBranch(PREF_TASKBAR_BRANCH);});XPCOMUtils.defineLazyGetter(this,"_stringBundle",function(){returnServices.strings.createBundle("chrome://browser/locale/taskbar.properties");});XPCOMUtils.defineLazyServiceGetter(this,"_idle","@mozilla.org/widget/idleservice;1","nsIIdleService");XPCOMUtils.defineLazyServiceGetter(this,"_taskbarService","@mozilla.org/windows-taskbar;1","nsIWinTaskbar");XPCOMUtils.defineLazyModuleGetter(this,"PlacesUtils","resource://gre/modules/PlacesUtils.jsm");XPCOMUtils.defineLazyModuleGetter(this,"PrivateBrowsingUtils","resource://gre/modules/PrivateBrowsingUtils.jsm");/** * Global functions */function_getString(name){return_stringBundle.GetStringFromName(name);}// Task list configuration data object.vartasksCfg=[/** * Task configuration options: title, description, args, iconIndex, open, close. * * title - Task title displayed in the list. (strings in the table are temp fillers.) * description - Tooltip description on the list item. * args - Command line args to invoke the task. * iconIndex - Optional win icon index into the main application for the * list item. * open - Boolean indicates if the command should be visible after the browser opens. * close - Boolean indicates if the command should be visible after the browser closes. */// Open new tab{gettitle(){return_getString("taskbar.tasks.newTab.label");},getdescription(){return_getString("taskbar.tasks.newTab.description");},args:"-new-tab about:blank",iconIndex:3,// New window iconopen:true,close:true,// The jump list already has an app launch icon, but// we don't always update the list on shutdown.// Thus true for consistency.},// Open new window{gettitle(){return_getString("taskbar.tasks.newWindow.label");},getdescription(){return_getString("taskbar.tasks.newWindow.description");},args:"-browser",iconIndex:2,// New tab iconopen:true,close:true,// No point, but we don't always update the list on// shutdown. Thus true for consistency.},// Open new private window{gettitle(){return_getString("taskbar.tasks.newPrivateWindow.label");},getdescription(){return_getString("taskbar.tasks.newPrivateWindow.description");},args:"-private-window",iconIndex:4,// Private browsing mode iconopen:true,close:true,// No point, but we don't always update the list on// shutdown. Thus true for consistency.},];// Implementationthis.WinTaskbarJumpList={_builder:null,_tasks:null,_shuttingDown:false,/** * Startup, shutdown, and update */startup:functionWTBJL_startup(){// exit if this isn't win7 or higher.if(!this._initTaskbar())return;// Store our task list config datathis._tasks=tasksCfg;// retrieve taskbar related prefs.this._refreshPrefs();// observer for private browsing and our prefs branchthis._initObs();// jump list refresh timerthis._updateTimer();},update:functionWTBJL_update(){// are we disabled via prefs? don't do anything!if(!this._enabled)return;// do what we came here to do, update the taskbar jumplistthis._buildList();},_shutdown:functionWTBJL__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();},/** * List building * * @note Async builders must add their mozIStoragePendingStatement to * _pendingStatements object, using a different LIST_TYPE entry for * each statement. Once finished they must remove it and call * commitBuild(). When there will be no more _pendingStatements, * commitBuild() will commit for real. */_pendingStatements:{},_hasPendingStatements:functionWTBJL__hasPendingStatements(){returnObject.keys(this._pendingStatements).length>0;},_buildList:functionWTBJL__buildList(){if(this._hasPendingStatements()){// We were requested to update the list while another update was in// progress, this could happen at shutdown, idle or privatebrowsing.// Abort the current list building.for(letlistTypeinthis._pendingStatements){this._pendingStatements[listType].cancel();deletethis._pendingStatements[listType];}this._builder.abortListBuild();}// anything to build?if(!this._showFrequent&&!this._showRecent&&!this._showTasks){// don't leave the last list hanging on the taskbar.this._deleteActiveJumpList();return;}if(!this._startBuild())return;if(this._showTasks)this._buildTasks();// Space for frequent items takes priority over recent.if(this._showFrequent)this._buildFrequent();if(this._showRecent)this._buildRecent();this._commitBuild();},/** * Taskbar api wrappers */_startBuild:functionWTBJL__startBuild(){varremovedItems=Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);this._builder.abortListBuild();if(this._builder.initListBuild(removedItems)){// Prior to building, delete removed items from history.this._clearHistory(removedItems);returntrue;}returnfalse;},_commitBuild:functionWTBJL__commitBuild(){if(this._hasPendingStatements()){return;}this._builder.commitListBuild(succeed=>{if(!succeed){this._builder.abortListBuild();}});},_buildTasks:functionWTBJL__buildTasks(){varitems=Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);this._tasks.forEach(function(task){if((this._shuttingDown&&!task.close)||(!this._shuttingDown&&!task.open))return;varitem=this._getHandlerAppItem(task.title,task.description,task.args,task.iconIndex,null);items.appendElement(item);},this);if(items.length>0)this._builder.addListToBuild(this._builder.JUMPLIST_CATEGORY_TASKS,items);},_buildCustom:functionWTBJL__buildCustom(title,items){if(items.length>0)this._builder.addListToBuild(this._builder.JUMPLIST_CATEGORY_CUSTOMLIST,items,title);},_buildFrequent:functionWTBJL__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// frequent and recent lists using our nav history data.varitems=Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);// track frequent items so that we don't add them to// the recent list.this._frequentHashList=[];this._pendingStatements[LIST_TYPE.FREQUENT]=this._getHistoryResults(Ci.nsINavHistoryQueryOptions.SORT_BY_VISITCOUNT_DESCENDING,this._maxItemCount,function(aResult){if(!aResult){deletethis._pendingStatements[LIST_TYPE.FREQUENT];// The are no more results, build the list.this._buildCustom(_getString("taskbar.frequent.label"),items);this._commitBuild();return;}lettitle=aResult.title||aResult.uri;letfaviconPageUri=Services.io.newURI(aResult.uri);letshortcut=this._getHandlerAppItem(title,title,aResult.uri,1,faviconPageUri);items.appendElement(shortcut);this._frequentHashList.push(aResult.uri);},this);},_buildRecent:functionWTBJL__buildRecent(){// If history is empty, just bail out.if(!PlacesUtils.history.hasHistoryEntries){return;}varitems=Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray);// Frequent items will be skipped, so we select a double amount of// entries and stop fetching results at _maxItemCount.varcount=0;this._pendingStatements[LIST_TYPE.RECENT]=this._getHistoryResults(Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING,this._maxItemCount*2,function(aResult){if(!aResult){// The are no more results, build the list.this._buildCustom(_getString("taskbar.recent.label"),items);deletethis._pendingStatements[LIST_TYPE.RECENT];this._commitBuild();return;}if(count>=this._maxItemCount){return;}// Do not add items to recent that have already been added to frequent.if(this._frequentHashList&&this._frequentHashList.indexOf(aResult.uri)!=-1){return;}lettitle=aResult.title||aResult.uri;letfaviconPageUri=Services.io.newURI(aResult.uri);letshortcut=this._getHandlerAppItem(title,title,aResult.uri,1,faviconPageUri);items.appendElement(shortcut);count++;},this);},_deleteActiveJumpList:functionWTBJL__deleteAJL(){this._builder.deleteActiveList();},/** * Jump list item creation helpers */_getHandlerAppItem:functionWTBJL__getHandlerAppItem(name,description,args,iconIndex,faviconPageUri){varfile=Services.dirsvc.get("XREExeF",Ci.nsILocalFile);varhandlerApp=Cc["@mozilla.org/uriloader/local-handler-app;1"].createInstance(Ci.nsILocalHandlerApp);handlerApp.executable=file;// handlers default to the leaf name if a name is not specifiedif(name&&name.length!=0)handlerApp.name=name;handlerApp.detailedDescription=description;handlerApp.appendParameter(args);varitem=Cc["@mozilla.org/windows-jumplistshortcut;1"].createInstance(Ci.nsIJumpListShortcut);item.app=handlerApp;item.iconIndex=iconIndex;item.faviconPageUri=faviconPageUri;returnitem;},_getSeparatorItem:functionWTBJL__getSeparatorItem(){varitem=Cc["@mozilla.org/windows-jumplistseparator;1"].createInstance(Ci.nsIJumpListSeparator);returnitem;},/** * Nav history helpers */_getHistoryResults:functionWTBLJL__getHistoryResults(aSortingMode,aLimit,aCallback,aScope){varoptions=PlacesUtils.history.getNewQueryOptions();options.maxResults=aLimit;options.sortingMode=aSortingMode;varquery=PlacesUtils.history.getNewQuery();// Return the pending statement to the caller, to allow cancelation.returnPlacesUtils.history.QueryInterface(Ci.nsPIPlacesDatabase).asyncExecuteLegacyQueries([query],1,options,{handleResult(aResultSet){for(letrow;(row=aResultSet.getNextRow());){try{aCallback.call(aScope,{uri:row.getResultByIndex(1),title:row.getResultByIndex(2)});}catch(e){}}},handleError(aError){Cu.reportError("Async execution error ("+aError.result+"): "+aError.message);},handleCompletion(aReason){aCallback.call(WinTaskbarJumpList,null);},});},_clearHistory:functionWTBJL__clearHistory(items){if(!items)return;varURIsToRemove=[];vare=items.enumerate();while(e.hasMoreElements()){letoldItem=e.getNext().QueryInterface(Ci.nsIJumpListShortcut);if(oldItem){try{// in case we get a bad urileturiSpec=oldItem.app.getParameter(0);URIsToRemove.push(Services.io.newURI(uriSpec));}catch(err){}}}if(URIsToRemove.length>0){PlacesUtils.history.remove(URIsToRemove).catch(Cu.reportError);}},/** * Prefs utilities */_refreshPrefs:functionWTBJL__refreshPrefs(){this._enabled=_prefs.getBoolPref(PREF_TASKBAR_ENABLED);this._showFrequent=_prefs.getBoolPref(PREF_TASKBAR_FREQUENT);this._showRecent=_prefs.getBoolPref(PREF_TASKBAR_RECENT);this._showTasks=_prefs.getBoolPref(PREF_TASKBAR_TASKS);this._maxItemCount=_prefs.getIntPref(PREF_TASKBAR_ITEMCOUNT);},/** * Init and shutdown utilities */_initTaskbar:functionWTBJL__initTaskbar(){this._builder=_taskbarService.createJumpListBuilder();if(!this._builder||!this._builder.available)returnfalse;returntrue;},_initObs:functionWTBJL__initObs(){// If the browser is closed while in private browsing mode, the "exit"// notification is fired on quit-application-granted.// History cleanup can happen at profile-change-teardown.Services.obs.addObserver(this,"profile-before-change");Services.obs.addObserver(this,"browser:purge-session-history");_prefs.addObserver("",this);},_freeObs:functionWTBJL__freeObs(){Services.obs.removeObserver(this,"profile-before-change");Services.obs.removeObserver(this,"browser:purge-session-history");_prefs.removeObserver("",this);},_updateTimer:functionWTBJL__updateTimer(){if(this._enabled&&!this._shuttingDown&&!this._timer){this._timer=Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);this._timer.initWithCallback(this,_prefs.getIntPref(PREF_TASKBAR_REFRESH)*1000,this._timer.TYPE_REPEATING_SLACK);}elseif((!this._enabled||this._shuttingDown)&&this._timer){this._timer.cancel();deletethis._timer;}},_hasIdleObserver:false,_updateIdleObserver:functionWTBJL__updateIdleObserver(){if(this._enabled&&!this._shuttingDown&&!this._hasIdleObserver){_idle.addIdleObserver(this,IDLE_TIMEOUT_SECONDS);this._hasIdleObserver=true;}elseif((!this._enabled||this._shuttingDown)&&this._hasIdleObserver){_idle.removeIdleObserver(this,IDLE_TIMEOUT_SECONDS);this._hasIdleObserver=false;}},_free:functionWTBJL__free(){this._freeObs();this._updateTimer();this._updateIdleObserver();deletethis._builder;},/** * Notification handlers */notify:functionWTBJL_notify(aTimer){// Add idle observer on the first notification so it doesn't hit startup.this._updateIdleObserver();this.update();},observe:functionWTBJL_observe(aSubject,aTopic,aData){switch(aTopic){case"nsPref:changed":if(this._enabled==true&&!_prefs.getBoolPref(PREF_TASKBAR_ENABLED))this._deleteActiveJumpList();this._refreshPrefs();this._updateTimer();this._updateIdleObserver();this.update();break;case"profile-before-change":this._shutdown();break;case"browser:purge-session-history":this.update();break;case"idle":if(this._timer){this._timer.cancel();deletethis._timer;}break;case"active":this._updateTimer();break;}},};