[Pkg-mozext-commits] [automatic-save-folder] 115/133: Fix: Fixed Private Browsing detection with Firefox 20+ (Temporary solution. I will use proper version detection later)

David Prévot taffit at moszumanska.debian.org
Mon Apr 27 20:33:58 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 9185bdc5e13cc6f3de6e5997ac53062591ff8b74
Author: Cyan <Cyan at d0063192-6b2e-11de-89a9-0b20f3e2dceb>
Date:   Sat Mar 16 11:11:23 2013 +0000

    Fix: Fixed Private Browsing detection with Firefox 20+
        (Temporary solution. I will use proper version detection later)
    
    git-svn-id: http://automatic-save-folder.googlecode.com/svn/trunk@124 d0063192-6b2e-11de-89a9-0b20f3e2dceb
---
 content/asf.js              |  3 +++
 content/asf_download.js     | 18 ++++++++++--------
 content/asf_right_click.js  | 25 ++++++++++++++++---------
 content/common.dtd          |  2 +-
 defaults/preferences/asf.js |  2 +-
 5 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/content/asf.js b/content/asf.js
index 8ca3733..c901d90 100644
--- a/content/asf.js
+++ b/content/asf.js
@@ -1746,6 +1746,9 @@ var automatic_save_folder = {
 		addon_GUUID = "dta at downthemall.net";
 		DTA = enabledItems.indexOf(addon_GUUID,0);
 		if (DTA >= 0) return true;
+		addon_GUUID = "dta%40downthemall.net";
+		DTA = enabledItems.indexOf(addon_GUUID,0);
+		if (DTA >= 0) return true;
 		
 		return false;
 	},
diff --git a/content/asf_download.js b/content/asf_download.js
index 891805a..8d6554d 100644
--- a/content/asf_download.js
+++ b/content/asf_download.js
@@ -46,8 +46,14 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
 		var appInfo = automatic_save_folder.appInfo;
 		this.checkFirefoxVersion();
 		
+		// 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);
+		
 		// Check if the user is in PrivateBrowsing mode.
-		if (this.firefoxversion >= 3)
+		if (this.versionChecker.compare(this.appInfo.version, "3.5") >= 0)// nsIPrivateBrowsingService supported from FF3.5 to FF20
 		{
 			try
 			{
@@ -55,16 +61,12 @@ Copyright (C) 2007-2012 Éric Cassar (Cyan).
 									.getService(Components.interfaces.nsIPrivateBrowsingService);
 				this.inPrivateBrowsing = pbs.privateBrowsingEnabled;
 			}
-			catch (e) { // nsIPrivateBrowsingService not working on FF2 and 3.0
+			catch(e) // FF21+
+			{
+				this.inPrivateBrowsing = mainWindow.gBrowser.docShell.QueryInterface(Components.interfaces.nsILoadContext).usePrivateBrowsing;
 			}
 		}
 
-		// 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)
 		{
diff --git a/content/asf_right_click.js b/content/asf_right_click.js
index 4ee2674..6e6558a 100644
--- a/content/asf_right_click.js
+++ b/content/asf_right_click.js
@@ -102,20 +102,27 @@ var automatic_save_folder = {
 			// Setting private variables usable in this function
 			var prefManager = this.prefManager;
 			
-			// Check if the user is in PrivateBrowsing mode.
-			if (this.versionChecker.compare(this.appInfo.version, "3.5") >= 0) //not working on FF2 and 3.0
-			{
-				var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
-									.getService(Components.interfaces.nsIPrivateBrowsingService);
-				this.inPrivateBrowsing = pbs.privateBrowsingEnabled;
-				Components.utils.import("resource://gre/modules/DownloadLastDir.jsm");
-			}
-			
 			// load the domain and the filename of the saved file
 			var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
 							   .getService(Components.interfaces.nsIWindowMediator);
 			var mainWindow = wm.getMostRecentWindow("navigator:browser");
 			
+			// Check if the user is in PrivateBrowsing mode.
+			if (this.versionChecker.compare(this.appInfo.version, "3.5") >= 0)// nsIPrivateBrowsingService supported from FF3.5 to FF20
+			{
+				try
+				{
+					var pbs = Components.classes["@mozilla.org/privatebrowsing;1"]
+										.getService(Components.interfaces.nsIPrivateBrowsingService);
+					this.inPrivateBrowsing = pbs.privateBrowsingEnabled;
+				}
+				catch(e) // FF21+
+				{
+					this.inPrivateBrowsing = mainWindow.gBrowser.docShell.QueryInterface(Components.interfaces.nsILoadContext).usePrivateBrowsing;
+				}
+				Components.utils.import("resource://gre/modules/DownloadLastDir.jsm");
+			}
+			
 			// 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)
 			{
diff --git a/content/common.dtd b/content/common.dtd
index f4d2351..c8af818 100644
--- a/content/common.dtd
+++ b/content/common.dtd
@@ -1,7 +1,7 @@
 <!-- Strings which don't need a translation -->
 
 <!-- Current version -->
-<!ENTITY asf.version "1.0.5bRev123">
+<!ENTITY asf.version "1.0.5bRev124">
 
 <!ENTITY about.translators "
 - cs : Stanislav Horáček<br />
diff --git a/defaults/preferences/asf.js b/defaults/preferences/asf.js
index c3de710..31d5407 100644
--- a/defaults/preferences/asf.js
+++ b/defaults/preferences/asf.js
@@ -1,4 +1,4 @@
- pref("extensions.asf.currentVersion", "1.0.5bRev123");
+ pref("extensions.asf.currentVersion", "1.0.5bRev124");
  pref("extensions.asf.lastdir", true);
  pref("extensions.asf.keeptemp", true);
  pref("extensions.asf.viewdloption", false);

-- 
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