Respect private browsing in extension
This commit is contained in:
		
							parent
							
								
									4358ebc18b
								
							
						
					
					
						commit
						ae7f2e9fcc
					
				| @ -40,11 +40,19 @@ var Settings = (function SettingsClosure() { | |||||||
|   })(); |   })(); | ||||||
|   var extPrefix = 'extensions.uriloader@pdf.js'; |   var extPrefix = 'extensions.uriloader@pdf.js'; | ||||||
|   var isExtension = location.protocol == 'chrome:' && !isLocalStorageEnabled; |   var isExtension = location.protocol == 'chrome:' && !isLocalStorageEnabled; | ||||||
|  |   var inPrivateBrowsing = false; | ||||||
|  |   if (isExtension) { | ||||||
|  |     var pbs = Components.classes['@mozilla.org/privatebrowsing;1'] | ||||||
|  |               .getService(Components.interfaces.nsIPrivateBrowsingService); | ||||||
|  |     inPrivateBrowsing = pbs.privateBrowsingEnabled; | ||||||
|  |   } | ||||||
| 
 | 
 | ||||||
|   function Settings(fingerprint) { |   function Settings(fingerprint) { | ||||||
|     var database = null; |     var database = null; | ||||||
|     var index; |     var index; | ||||||
|     if (isExtension) |     if (inPrivateBrowsing) | ||||||
|  |       return false; | ||||||
|  |     else if (isExtension) | ||||||
|       database = Application.prefs.getValue(extPrefix + '.database', '{}'); |       database = Application.prefs.getValue(extPrefix + '.database', '{}'); | ||||||
|     else if (isLocalStorageEnabled) |     else if (isLocalStorageEnabled) | ||||||
|       database = localStorage.getItem('database') || '{}'; |       database = localStorage.getItem('database') || '{}'; | ||||||
| @ -76,6 +84,8 @@ var Settings = (function SettingsClosure() { | |||||||
| 
 | 
 | ||||||
|   Settings.prototype = { |   Settings.prototype = { | ||||||
|     set: function settingsSet(name, val) { |     set: function settingsSet(name, val) { | ||||||
|  |       if (inPrivateBrowsing) | ||||||
|  |         return false; | ||||||
|       var file = this.file; |       var file = this.file; | ||||||
|       file[name] = val; |       file[name] = val; | ||||||
|       if (isExtension) |       if (isExtension) | ||||||
| @ -86,6 +96,9 @@ var Settings = (function SettingsClosure() { | |||||||
|     }, |     }, | ||||||
| 
 | 
 | ||||||
|     get: function settingsGet(name, defaultValue) { |     get: function settingsGet(name, defaultValue) { | ||||||
|  |       if (inPrivateBrowsing) | ||||||
|  |         return defaultValue; | ||||||
|  |       else | ||||||
|         return this.file[name] || defaultValue; |         return this.file[name] || defaultValue; | ||||||
|     } |     } | ||||||
|   }; |   }; | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user