[Pkg-mozext-commits] [automatic-save-folder] 111/133: Fix: Fixed download not working with Firefox 19+

David Prévot taffit at moszumanska.debian.org
Mon Apr 27 20:33:57 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch wip
in repository automatic-save-folder.

commit 26bf1c2c2f1d23bfa40891ae0eb0cdf12b92f896
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date:   Wed Nov 28 17:47:28 2012 +0000

    Fix: Fixed download not working with Firefox 19+
    
    git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@120 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
 content/asf_download.js    | 47 ++++++++++++++++++++++++++++++++--------------
 content/asf_right_click.js | 21 ++++++++++++++++++++-
 content/common.dtd         |  2 +-
 3 files changed, 54 insertions(+), 16 deletions(-)

diff --git a/content/asf_download.js b/content/asf_download.js
index 12f61ef..0cc9ba3 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -58,23 +58,31 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
 			catch (e) { // nsIPrivateBrowsingService not working on FF2 and 3.0
 			}
 		}
-		
-		// Enable Private Browsing support with filepicker - Thanks to Ehsan Akhgari at http://ehsanakhgari.org/
-		if (this.versionChecker.compare(this.appInfo.version, "3.5") >= 0)
-		{
-			Components.utils.import("resource://gre/modules/DownloadLastDir.jsm");
-		}
-		
+
 		// Check if there is any filter in list
 		var nbrfilters = 	prefManager.getIntPref("extensions.asf.filtersNumber");
 		
-		
-		// load the domain and the filename of the saved file (copy the data from the firefox saving window and from the last active tab)
+		// Load Window and tab elements from the current active browser.
 		var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
 						   .getService(Components.interfaces.nsIWindowMediator);
 		var mainWindow = wm.getMostRecentWindow("navigator:browser");
-		
 		var currentTab = mainWindow.gBrowser.getBrowserAtIndex(mainWindow.gBrowser.tabContainer.selectedIndex);
+		
+		// Enable Private Browsing support with filepicker - Thanks to Ehsan Akhgari at http://ehsanakhgari.org/
+		if (this.versionChecker.compare(this.appInfo.version, "3.5") >= 0)
+		{
+			Components.utils.import("resource://gre/modules/DownloadLastDir.jsm");
+			
+			// since 2012-07-21, it uses a per-window privacy status instead of global service. (https://bugzilla.mozilla.org/show_bug.cgi?id=722995 ; https://hg.mozilla.org/mozilla-central/rev/03cd2ad254cc)
+			if (typeof(gDownloadLastDir) != "object")
+			{
+				var downloadModule = {};
+				Components.utils.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
+				gDownloadLastDir = new downloadModule.DownloadLastDir(mainWindow); // Load gDownloadLastDir for the active window 
+			}
+		}
+		
+		/* load the domain and the filename of the saved file (copy the data from the firefox saving window and from the last active tab) */	
 		// var tabLocation = currentTab.currentURI.spec;
 		var tabLocation = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.location;
 		var tabURL = mainWindow.gURLBar.value;
@@ -386,6 +394,17 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
 		var lastdir = this.prefManager.getBoolPref("extensions.asf.lastdir");	     // for Firefox2 : set save as Ctrl+S too		
 		var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);		
 		
+		// since 2012-07-21 gDownloadLastDir uses a per-window privacy status instead of global service.
+		if (typeof(gDownloadLastDir) != "object")
+		{
+			var downloadModule = {};
+			var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+							   .getService(Components.interfaces.nsIWindowMediator);
+			var mainWindow = wm.getMostRecentWindow("navigator:browser");
+			Components.utils.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
+			gDownloadLastDir = new downloadModule.DownloadLastDir(mainWindow);
+		}
+		
 		// Check if the user use the "useDownloadDir" setting to automatically save to "desktop" or "downloads" and force the suggested path to those folders instead of filtered path
 		if ( (folderList == 0) || (folderList == 1) )
 		{
@@ -463,7 +482,7 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
 		}
 		
 		
-		if (this.logtoconsole && !this.inPrivateBrowsing) this.console_print("save location changed to: "+directory.path);
+		if (this.logtoconsole && !this.inPrivateBrowsing) this.console_print("save location for "+uri+" changed to: "+directory.path);
 	},
 	
 	
@@ -1238,7 +1257,7 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
 
 	// get TabGroup name, from https://hg.mozilla.org/mozilla-central/rev/b284e10652d3
 	getActiveGroupName: function () {
-
+		
 		var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
 						   .getService(Components.interfaces.nsIWindowMediator);
 		var mainWindow = wm.getMostRecentWindow("navigator:browser");
@@ -1254,8 +1273,8 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
 		if (activeTab.pinned)
 		{
 			// It's an app tab, so it won't have a .tabItem.
-			groupItem = null;
-		} 
+			groupItem = null; // I didn't find how to get the Active Group's Name.
+		}
 		else if (activeTabItem)
 		{
 			groupItem = activeTabItem.parent;
diff --git a/content/asf_right_click.js b/content/asf_right_click.js
index 25e3d68..8b4f18a 100644
--- a/content/asf_right_click.js
+++ b/content/asf_right_click.js
@@ -120,6 +120,14 @@ var automatic_save_folder = {
 							   .getService(Components.interfaces.nsIWindowMediator);
 			var mainWindow = wm.getMostRecentWindow("navigator:browser");
 			
+			// since 2012-07-21 gDownloadLastDir uses a per-window privacy status instead of global service. (https://bugzilla.mozilla.org/show_bug.cgi?id=722995 ; https://hg.mozilla.org/mozilla-central/rev/03cd2ad254cc)
+			if (typeof(gDownloadLastDir) != "object" && this.versionChecker.compare(this.appInfo.version, "3.5") >= 0) // gDownloadLastDir is only in 3.5+, prevents error on old Firefox (I'll remove support of old versions soon)
+			{
+				var downloadModule = {};
+				Components.utils.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
+				gDownloadLastDir = new downloadModule.DownloadLastDir(mainWindow); // Load gDownloadLastDir for the active window
+			}
+			
 			var tabURL = mainWindow.gURLBar.value;
 			var tabGroupName = this.getActiveGroupName();
 			var currentReferrer = mainWindow.gBrowser.mCurrentTab.linkedBrowser.contentDocument.referrer;
@@ -360,6 +368,17 @@ var automatic_save_folder = {
 		var lastdir = this.prefManager.getBoolPref("extensions.asf.lastdir");	     // for Firefox2 : set save as Ctrl+S too
 		var directory = Components.classes["@mozilla.org/file/local;1"].createInstance(Components.interfaces.nsILocalFile);
 		
+		// since 2012-07-21 gDownloadLastDir uses a per-window privacy status instead of global service.
+		if (typeof(gDownloadLastDir) != "object" && this.versionChecker.compare(this.appInfo.version, "3.5") >= 0)
+		{
+			var downloadModule = {};
+			var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
+							   .getService(Components.interfaces.nsIWindowMediator);
+			var mainWindow = wm.getMostRecentWindow("navigator:browser");
+			Components.utils.import("resource://gre/modules/DownloadLastDir.jsm", downloadModule);
+			gDownloadLastDir = new downloadModule.DownloadLastDir(mainWindow);
+		}
+		
 		if (!path) 
 		{
 			directory = Components.classes["@mozilla.org/file/directory_service;1"]
@@ -404,7 +423,7 @@ var automatic_save_folder = {
 			gDownloadLastDir.setFile(uri, directory);
 		}
 		
-		if (this.logtoconsole && !this.inPrivateBrowsing) this.console_print("save location changed to: "+directory.path);
+		if (this.logtoconsole && !this.inPrivateBrowsing) this.console_print("save location for "+uri+" changed to: "+directory.path);
 	},
 	
 	
diff --git a/content/common.dtd b/content/common.dtd
index 853f996..1fe4ea9 100644
--- a/content/common.dtd
+++ b/content/common.dtd
@@ -1,5 +1,5 @@
 <!-- Current version -->
-<!ENTITY asf.version "1.0.5bRev119">
+<!ENTITY asf.version "1.0.5bRev120">
 
 <!ENTITY about.translators "
 - cs : Stanislav Horáček<br />

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/automatic-save-folder.git



More information about the Pkg-mozext-commits mailing list