diff options
author | Matt A. Tobin <email@mattatobin.com> | 2018-02-02 05:06:10 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2018-02-02 05:06:10 -0500 |
commit | 6d614170cbfa958564eb5f824234ad5a9e484344 (patch) | |
tree | 3e1eb384382f30987cb2e64bd654afa8b74fd06b /application/basilisk/base/content/browser-thumbnails.js | |
parent | 2a6b605d64b19411a300efdbbd7f78c349f90206 (diff) | |
download | uxp-6d614170cbfa958564eb5f824234ad5a9e484344.tar.gz |
Revert "Add Basilisk"
This reverts commit e72ef92b5bdc43cd2584198e2e54e951b70299e8.
Diffstat (limited to 'application/basilisk/base/content/browser-thumbnails.js')
-rw-r--r-- | application/basilisk/base/content/browser-thumbnails.js | 142 |
1 files changed, 0 insertions, 142 deletions
diff --git a/application/basilisk/base/content/browser-thumbnails.js b/application/basilisk/base/content/browser-thumbnails.js deleted file mode 100644 index 86040a51d1..0000000000 --- a/application/basilisk/base/content/browser-thumbnails.js +++ /dev/null @@ -1,142 +0,0 @@ -/* 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/. */ - -/** - * 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, - - /** - * List of tab events we want to listen for. - */ - _tabEvents: ["TabClose", "TabSelect"], - - init: function Thumbnails_init() { - PageThumbs.addExpirationFilter(this); - gBrowser.addTabsProgressListener(this); - Services.prefs.addObserver(this.PREF_DISK_CACHE_SSL, this, false); - - this._sslDiskCacheEnabled = - Services.prefs.getBoolPref(this.PREF_DISK_CACHE_SSL); - - this._tabEvents.forEach(function(aEvent) { - gBrowser.tabContainer.addEventListener(aEvent, this); - }, this); - - this._timeouts = new WeakMap(); - }, - - uninit: function Thumbnails_uninit() { - PageThumbs.removeExpirationFilter(this); - gBrowser.removeTabsProgressListener(this); - Services.prefs.removeObserver(this.PREF_DISK_CACHE_SSL, this); - - this._tabEvents.forEach(function(aEvent) { - gBrowser.tabContainer.removeEventListener(aEvent, this); - }, this); - }, - - handleEvent: function Thumbnails_handleEvent(aEvent) { - switch (aEvent.type) { - case "scroll": - let browser = aEvent.currentTarget; - if (this._timeouts.has(browser)) - this._delayedCapture(browser); - break; - case "TabSelect": - this._delayedCapture(aEvent.target.linkedBrowser); - break; - case "TabClose": { - this._clearTimeout(aEvent.target.linkedBrowser); - break; - } - } - }, - - observe: function Thumbnails_observe() { - this._sslDiskCacheEnabled = - Services.prefs.getBoolPref(this.PREF_DISK_CACHE_SSL); - }, - - filterForThumbnailExpiration: - function Thumbnails_filterForThumbnailExpiration(aCallback) { - aCallback(this._topSiteURLs); - }, - - /** - * State change progress listener for all tabs. - */ - onStateChange: function Thumbnails_onStateChange(aBrowser, aWebProgress, - aRequest, aStateFlags, aStatus) { - if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP && - aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK) - this._delayedCapture(aBrowser); - }, - - _capture: function Thumbnails_capture(aBrowser) { - // Only capture about:newtab top sites. - if (this._topSiteURLs.indexOf(aBrowser.currentURI.spec) == -1) - return; - this._shouldCapture(aBrowser, function(aResult) { - if (aResult) { - PageThumbs.captureAndStoreIfStale(aBrowser); - } - }); - }, - - _delayedCapture: function Thumbnails_delayedCapture(aBrowser) { - if (this._timeouts.has(aBrowser)) - clearTimeout(this._timeouts.get(aBrowser)); - else - aBrowser.addEventListener("scroll", this, true); - - let timeout = setTimeout(function() { - this._clearTimeout(aBrowser); - this._capture(aBrowser); - }.bind(this), this._captureDelayMS); - - this._timeouts.set(aBrowser, timeout); - }, - - _shouldCapture: function Thumbnails_shouldCapture(aBrowser, aCallback) { - // Capture only if it's the currently selected tab. - if (aBrowser != gBrowser.selectedBrowser) { - aCallback(false); - return; - } - PageThumbs.shouldStoreThumbnail(aBrowser, aCallback); - }, - - get _topSiteURLs() { - return NewTabUtils.links.getLinks().reduce((urls, link) => { - if (link) - urls.push(link.url); - return urls; - }, []); - }, - - _clearTimeout: function Thumbnails_clearTimeout(aBrowser) { - if (this._timeouts.has(aBrowser)) { - aBrowser.removeEventListener("scroll", this); - clearTimeout(this._timeouts.get(aBrowser)); - this._timeouts.delete(aBrowser); - } - } -}; |