summaryrefslogtreecommitdiff
path: root/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/download.js
diff options
context:
space:
mode:
authorRuben Rodriguez <ruben@gnu.org>2018-09-13 20:39:48 -0400
committerRuben Rodriguez <ruben@gnu.org>2018-09-13 21:02:13 -0400
commitd26b319fd6f98517cc3421f10bf18698b953e4d2 (patch)
treebc70c4e472a2eaf514d411dba5067d530e5bbea9 /data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/download.js
parentc3b304c51a3386ea09527a479a883253ea35243a (diff)
Updated extensions list for v60
Diffstat (limited to 'data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/download.js')
-rw-r--r--data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/download.js95
1 files changed, 0 insertions, 95 deletions
diff --git a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/download.js b/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/download.js
deleted file mode 100644
index 20fef54..0000000
--- a/data/extensions/jid1-KtlZuoiikVfFew@jetpack/node_modules/pathfinder/lib/download.js
+++ /dev/null
@@ -1,95 +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/. */
-'use strict';
-
-const { Ci, Cc, Cu } = require('chrome');
-const { Class } = require('sdk/core/heritage');
-const { on, off, emit, setListeners } = require('sdk/event/core');
-const { EventTarget } = require("sdk/event/target");
-const { ns } = require("sdk/core/namespace");
-const { validateOptions } = require("sdk/deprecated/api-utils");
-const { isValidURI } = require("sdk/url");
-
-const PROGRESS_LISTENER_NS = ns();
-
-const { Services } = Cu.import('resource://gre/modules/Services.jsm', {});
-
-const rules = {
- url: {
- // Also converts a URL instance to string, bug 857902
- map: function (url) url.toString(),
- ok: isValidURI
- },
- destination: {
- is: ['string']
- }
-};
-
-const Download = Class({
- extends: EventTarget,
- initialize: function(options) {
- // Setup listeners.
- setListeners(this, options);
-
- options = validateOptions(options, rules);
-
- const wbp = Cc["@mozilla.org/embedding/browser/nsWebBrowserPersist;1"]
- .createInstance(Ci.nsIWebBrowserPersist);
- let listener = ProgressListener({
- download: this
- });
-
- wbp.progressListener = listener;
-
- let localFile = Cc["@mozilla.org/file/local;1"]
- .createInstance(Ci.nsILocalFile);
- localFile.initWithPath(options.destination);
- localFile.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, parseInt("0666", 8));
- localFile = localFile.QueryInterface(Ci.nsIFile);
-
- let uri = Services.io.newURI(options.url, null, null);
- wbp.saveURI(uri, null, null, null, null, localFile, null);
- }
-});
-exports.Download = Download;
-
-const ProgressListener = Class({
- initialize: function(options) {
- const internals = PROGRESS_LISTENER_NS(this);
- internals.options = options;
- this.onStateChange = this.onStateChange.bind(this);
- },
- get options() PROGRESS_LISTENER_NS(this).options,
- get download() this.options.download,
- onLocationChange: function(aWebProgress, aRequest, aLocation, aFlags) {
- },
- onProgressChange: function(aWebProgress, aRequest, aCurSelfProgress, aMaxSelfProgress, aCurTotalProgress, aMaxTotalProgress) {
- emit(this.download, 'progress', {
- current: aCurTotalProgress,
- total: aMaxTotalProgress
- })
- },
- onSecurityChange: function(aWebProgress, aRequest, aState) {
- },
- onStateChange: function(aWebProgress, aRequest, aStateFlags, aStatus) {
- if (!(aStateFlags & Ci.nsIWebProgressListener.STATE_STOP))
- return;
-
- try {
- var { responseStatus, requestSucceeded } = aRequest.QueryInterface(Ci.nsIHttpChannel);
- }
- catch (e) {
- //console.exception(e);
- }
-
- emit(this.download, 'complete', {
- responseStatus: responseStatus,
- requestSucceeded: requestSucceeded
- });
-
- return;
- },
- onStatusChange: function(aWebProgress, aRequest, aStatus, aMessage) {
- }
-});