From 2e076f7e4e98dcf2e4a48e19948f78fcb0fb1ada Mon Sep 17 00:00:00 2001 From: Deathamns Date: Thu, 12 Mar 2015 12:09:45 +0100 Subject: [PATCH] Remove unnecessary fallback code for downloading --- platform/chromium/vapi-background.js | 1 - platform/chromium/vapi-common.js | 27 +++------------------------ platform/firefox/vapi-background.js | 3 +-- platform/firefox/vapi-common.js | 27 +++------------------------ 4 files changed, 7 insertions(+), 51 deletions(-) diff --git a/platform/chromium/vapi-background.js b/platform/chromium/vapi-background.js index 6a0a15f41..791afb7d9 100644 --- a/platform/chromium/vapi-background.js +++ b/platform/chromium/vapi-background.js @@ -36,7 +36,6 @@ var vAPI = self.vAPI = self.vAPI || {}; var chrome = self.chrome; var manifest = chrome.runtime.getManifest(); -vAPI.isMainProcess = true; vAPI.chrome = true; var noopFunc = function(){}; diff --git a/platform/chromium/vapi-common.js b/platform/chromium/vapi-common.js index 77216462e..799136d5e 100644 --- a/platform/chromium/vapi-common.js +++ b/platform/chromium/vapi-common.js @@ -54,30 +54,9 @@ vAPI.download = function(details) { } var a = document.createElement('a'); - - if ( 'download' in a ) { - a.href = details.url; - a.setAttribute('download', details.filename || ''); - a.dispatchEvent(new MouseEvent('click')); - return; - } - - var request = { - what: 'gotoURL', - details: { - url: details.url, - index: -1 - } - }; - - if ( vAPI.isMainProcess ) { - vAPI.tabs.open(request.details); - return; - } - - var messager = vAPI.messaging.channel('_download'); - messager.send(request); - messager.close(); + a.href = details.url; + a.setAttribute('download', details.filename || ''); + a.dispatchEvent(new MouseEvent('click')); }; /******************************************************************************/ diff --git a/platform/firefox/vapi-background.js b/platform/firefox/vapi-background.js index 1821f932c..30b8532bf 100644 --- a/platform/firefox/vapi-background.js +++ b/platform/firefox/vapi-background.js @@ -38,7 +38,6 @@ const {Services} = Cu.import('resource://gre/modules/Services.jsm', null); /******************************************************************************/ var vAPI = self.vAPI = self.vAPI || {}; -vAPI.isMainProcess = true; vAPI.firefox = true; vAPI.fennec = Services.appinfo.ID === '{aa3c5121-dab2-40e2-81ca-7ea25febc110}'; @@ -1875,7 +1874,7 @@ vAPI.optionsObserver = { register: function () { var obs = Components.classes['@mozilla.org/observer-service;1'].getService(Components.interfaces.nsIObserverService); obs.addObserver(this, "addon-options-displayed", false); - + cleanupTasks.push(this.unregister.bind(this)); }, diff --git a/platform/firefox/vapi-common.js b/platform/firefox/vapi-common.js index c935a638f..de8f92fe0 100644 --- a/platform/firefox/vapi-common.js +++ b/platform/firefox/vapi-common.js @@ -50,30 +50,9 @@ vAPI.download = function(details) { } var a = document.createElement('a'); - - if ( 'download' in a ) { - a.href = details.url; - a.setAttribute('download', details.filename || ''); - a.dispatchEvent(new MouseEvent('click')); - return; - } - - var request = { - what: 'gotoURL', - details: { - url: details.url, - index: -1 - } - }; - - if ( vAPI.isMainProcess ) { - vAPI.tabs.open(request.details); - return; - } - - var messager = vAPI.messaging.channel('_download'); - messager.send(request); - messager.close(); + a.href = details.url; + a.setAttribute('download', details.filename || ''); + a.dispatchEvent(new MouseEvent('click')); }; /******************************************************************************/