/* 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/. */
// This file is loaded into the browser window scope. /* eslint-env mozilla/browser-window */
/** * Keeps thumbnails of open web pages up-to-date.
*/ var gBrowserThumbnails = { /** * Pref that controls whether we can store SSL content on disk
*/
PREF_DISK_CACHE_SSL: "browser.cache.disk_cache_ssl",
_captureDelayMS: 1000,
/** * Used to keep track of disk_cache_ssl preference
*/
_sslDiskCacheEnabled: null,
/** * Map of capture() timeouts assigned to their browsers.
*/
_timeouts: null,
/** * Top site URLs refresh timer.
*/
_topSiteURLsRefreshTimer: null,
/** * List of tab events we want to listen for.
*/
_tabEvents: ["TabClose", "TabSelect"],
init: function Thumbnails_init() {
gBrowser.addTabsProgressListener(this);
Services.prefs.addObserver(this.PREF_DISK_CACHE_SSL, this);
_shouldCapture: async function Thumbnails_shouldCapture(aBrowser) { // Capture only if it's the currently selected tab and not an about: page. if (
aBrowser != gBrowser.selectedBrowser ||
gBrowser.currentURI.schemeIs("about")
) { returnfalse;
} return PageThumbs.shouldStoreThumbnail(aBrowser);
},
_cancelDelayedCapture: function Thumbnails_cancelDelayedCapture(aBrowser) { if (this._timeouts.has(aBrowser)) {
aBrowser.removeEventListener("scroll", this); this._cancelDelayedCallbacks(aBrowser); this._timeouts.delete(aBrowser);
}
},
_cancelDelayedCallbacks: function Thumbnails_cancelDelayedCallbacks(
aBrowser
) {
let timeoutData = this._timeouts.get(aBrowser);
async function getTopSiteURLs() { // The _topSiteURLs getter can be expensive to run, but its return value can // change frequently on new profiles, so as a compromise we cache its return // value as a lazy getter for 1 minute every time it's called.
gBrowserThumbnails._topSiteURLsRefreshTimer = Cc[ "@mozilla.org/timer;1"
].createInstance(Ci.nsITimer);
gBrowserThumbnails._topSiteURLsRefreshTimer.initWithCallback(
gBrowserThumbnails,
60 * 1000,
Ci.nsITimer.TYPE_ONE_SHOT
);
let sites = []; // Get both the top sites returned by the query, and also any pinned sites // that the user might have added manually that also need a screenshot. // Also include top sites that don't have rich icons
let topSites = await NewTabUtils.activityStreamLinks.getTopSites();
sites.push(...topSites.filter(link => !(link.faviconSize >= 96)));
sites.push(...NewTabUtils.pinnedLinks.links); return sites.reduce((urls, link) => { if (link) {
urls.push(link.url);
} return urls;
}, []);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.