summaryrefslogtreecommitdiffstats
path: root/application/basilisk/components/newtab/PreviewProvider.jsm
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2018-02-02 05:06:10 -0500
committerMatt A. Tobin <email@mattatobin.com>2018-02-02 05:06:10 -0500
commit6d614170cbfa958564eb5f824234ad5a9e484344 (patch)
tree3e1eb384382f30987cb2e64bd654afa8b74fd06b /application/basilisk/components/newtab/PreviewProvider.jsm
parent2a6b605d64b19411a300efdbbd7f78c349f90206 (diff)
downloadUXP-6d614170cbfa958564eb5f824234ad5a9e484344.tar
UXP-6d614170cbfa958564eb5f824234ad5a9e484344.tar.gz
UXP-6d614170cbfa958564eb5f824234ad5a9e484344.tar.lz
UXP-6d614170cbfa958564eb5f824234ad5a9e484344.tar.xz
UXP-6d614170cbfa958564eb5f824234ad5a9e484344.zip
Revert "Add Basilisk"
This reverts commit e72ef92b5bdc43cd2584198e2e54e951b70299e8.
Diffstat (limited to 'application/basilisk/components/newtab/PreviewProvider.jsm')
-rw-r--r--application/basilisk/components/newtab/PreviewProvider.jsm49
1 files changed, 0 insertions, 49 deletions
diff --git a/application/basilisk/components/newtab/PreviewProvider.jsm b/application/basilisk/components/newtab/PreviewProvider.jsm
deleted file mode 100644
index 7e6d06e3d..000000000
--- a/application/basilisk/components/newtab/PreviewProvider.jsm
+++ /dev/null
@@ -1,49 +0,0 @@
-/* global XPCOMUtils, BackgroundPageThumbs, FileUtils, PageThumbsStorage, Task, MIMEService */
-/* exported PreviewProvider */
-
-"use strict";
-
-this.EXPORTED_SYMBOLS = ["PreviewProvider"];
-
-const {utils: Cu} = Components;
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-Cu.import("resource://gre/modules/Task.jsm");
-Cu.import("resource://gre/modules/PageThumbs.jsm");
-Cu.import("resource://gre/modules/FileUtils.jsm");
-const {OS} = Cu.import("resource://gre/modules/osfile.jsm", {});
-
-XPCOMUtils.defineLazyModuleGetter(this, "BackgroundPageThumbs",
- "resource://gre/modules/BackgroundPageThumbs.jsm");
-XPCOMUtils.defineLazyServiceGetter(this, "MIMEService",
- "@mozilla.org/mime;1", "nsIMIMEService");
-
-let PreviewProvider = {
- /**
- * Returns a thumbnail as a data URI for a url, creating it if necessary
- *
- * @param {String} url
- * a url to obtain a thumbnail for
- * @return {Promise} A Promise that resolves with a base64 encoded thumbnail
- */
- getThumbnail: Task.async(function* PreviewProvider_getThumbnail(url) {
- try {
- yield BackgroundPageThumbs.captureIfMissing(url);
- let imgPath = PageThumbsStorage.getFilePathForURL(url);
-
- // OS.File object used to easily read off-thread
- let file = yield OS.File.open(imgPath, {read: true, existing: true});
-
- // nsIFile object needed for MIMEService
- let nsFile = FileUtils.File(imgPath);
-
- let contentType = MIMEService.getTypeFromFile(nsFile);
- let bytes = yield file.read();
- let encodedData = btoa(String.fromCharCode.apply(null, bytes));
- file.close();
- return `data:${contentType};base64,${encodedData}`;
- } catch (err) {
- Cu.reportError(`PreviewProvider_getThumbnail error: ${err}`);
- throw err;
- }
- })
-};