Bug 1073095 - nsPermissionManager.cpp references a browser path by default in kDefaultsUrlPrefName. Make the permissions.manager.defaultsUrl pref overridable. r=benjamin
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Fri, 13 Feb 2015 23:32:41 +0200
changeset 256356 dc40389064bc5bacf1a5033269094639895cfb3b
parent 256355 d81339c7ac5220668003bd25e62276c8d8f044f9
child 256357 819fefe0c733e373a552a6b78e1f1e1b483a366f
push id4610
push userjlund@mozilla.com
push dateMon, 30 Mar 2015 18:32:55 +0000
treeherdermozilla-beta@4df54044d9ef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbenjamin
bugs1073095
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1073095 - nsPermissionManager.cpp references a browser path by default in kDefaultsUrlPrefName. Make the permissions.manager.defaultsUrl pref overridable. r=benjamin
browser/app/default_permissions
browser/app/jar.mn
browser/app/permissions
browser/app/profile/firefox.js
extensions/cookie/nsPermissionManager.cpp
--- a/browser/app/jar.mn
+++ b/browser/app/jar.mn
@@ -1,4 +1,3 @@
 browser.jar:
-
-# The file that holds the default permissions (which is loaded by nsPermissionManager) for the browser.
-    default_permissions (default_permissions)
+% resource app %
+  defaults/permissions (permissions)
rename from browser/app/default_permissions
rename to browser/app/permissions
--- a/browser/app/profile/firefox.js
+++ b/browser/app/profile/firefox.js
@@ -405,16 +405,19 @@ pref("browser.search.context.loadInBackg
 
 pref("browser.search.showOneOffButtons", true);
 
 // comma seperated list of of engines to hide in the search panel.
 pref("browser.search.hiddenOneOffs", "");
 
 pref("browser.sessionhistory.max_entries", 50);
 
+// Built-in default permissions.
+pref("permissions.manager.defaultsUrl", "resource://app/defaults/permissions");
+
 // handle links targeting new windows
 // 1=current window/tab, 2=new window, 3=new tab in most recent window
 pref("browser.link.open_newwindow", 3);
 
 // handle external links (i.e. links opened from a different application)
 // default: use browser.link.open_newwindow
 // 1-3: see browser.link.open_newwindow for interpretation
 pref("browser.link.open_newwindow.override.external", -1);
--- a/extensions/cookie/nsPermissionManager.cpp
+++ b/extensions/cookie/nsPermissionManager.cpp
@@ -357,20 +357,18 @@ nsPermissionManager::AppClearDataObserve
 // nsPermissionManager Implementation
 
 static const char kPermissionsFileName[] = "permissions.sqlite";
 #define HOSTS_SCHEMA_VERSION 4
 
 static const char kHostpermFileName[] = "hostperm.1";
 
 // Default permissions are read from a URL - this is the preference we read
-// to find that URL.
+// to find that URL. If not set, don't use any default permissions.
 static const char kDefaultsUrlPrefName[] = "permissions.manager.defaultsUrl";
-// If the pref above doesn't exist, the URL we use by default.
-static const char kDefaultsUrl[] = "resource://app/chrome/browser/default_permissions";
 
 static const char kPermissionChangeNotification[] = PERM_CHANGE_NOTIFICATION;
 
 NS_IMPL_ISUPPORTS(nsPermissionManager, nsIPermissionManager, nsIObserver, nsISupportsWeakReference)
 
 nsPermissionManager::nsPermissionManager()
  : mLargestID(0)
  , mIsShuttingDown(false)
@@ -1887,23 +1885,19 @@ nsPermissionManager::Import()
   return NS_OK;
 }
 
 // ImportDefaults will read a URL with default permissions and add them to the
 // in-memory copy of permissions.  The database is *not* written to.
 nsresult
 nsPermissionManager::ImportDefaults()
 {
-  // We allow prefs to override the default permissions URI, mainly as a hook
-  // for testing.
-  nsCString defaultsURL;
-  if (mozilla::Preferences::HasUserValue(kDefaultsUrlPrefName)) {
-    defaultsURL = mozilla::Preferences::GetCString(kDefaultsUrlPrefName);
-  } else {
-    defaultsURL = NS_LITERAL_CSTRING(kDefaultsUrl);
+  nsCString defaultsURL = mozilla::Preferences::GetCString(kDefaultsUrlPrefName);
+  if (defaultsURL.IsEmpty()) { // == Don't use built-in permissions.
+    return NS_OK;
   }
 
   nsresult rv;
   nsCOMPtr<nsIIOService> ioservice =
     do_GetService("@mozilla.org/network/io-service;1", &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIURI> defaultsURI;