Index: chrome/browser/extensions/extension_prefs.cc |
diff --git a/chrome/browser/extensions/extension_prefs.cc b/chrome/browser/extensions/extension_prefs.cc |
index 1e1a3d6213bad6203e724e734f88ea57556a9162..e979f8eb8006cc5694198dca4ce6038019688ed4 100644 |
--- a/chrome/browser/extensions/extension_prefs.cc |
+++ b/chrome/browser/extensions/extension_prefs.cc |
@@ -10,6 +10,7 @@ |
#include "chrome/browser/extensions/extension_pref_store.h" |
#include "chrome/browser/prefs/pref_notifier.h" |
#include "chrome/browser/prefs/scoped_user_pref_update.h" |
+#include "chrome/common/url_constants.h" |
#include "chrome/common/extensions/extension.h" |
#include "chrome/common/extensions/url_pattern.h" |
#include "chrome/common/pref_names.h" |
@@ -567,11 +568,15 @@ bool ExtensionPrefs::GetGrantedPermissions( |
// The granted host permissions contain hosts from the manifest's |
// "permissions" array and from the content script "matches" arrays, |
// so the URLPattern needs to accept valid schemes from both types. |
+ // file:/// is temporarily included, but is removed below if not actually |
+ // allowed. |
+ int valid_schemes = Extension::kValidHostPermissionSchemes | |
+ UserScript::kValidUserScriptSchemes | URLPattern::SCHEME_FILE; |
+ bool allow_file_access = AllowFileAccess(extension_id); |
+ |
for (std::set<std::string>::iterator i = host_permissions.begin(); |
i != host_permissions.end(); ++i) { |
- URLPattern pattern( |
- Extension::kValidHostPermissionSchemes | |
- UserScript::kValidUserScriptSchemes); |
+ URLPattern pattern(valid_schemes); |
// Parse without strict checks, so that new strict checks do not |
// fail on a pattern in an installed extension. |
@@ -579,6 +584,15 @@ bool ExtensionPrefs::GetGrantedPermissions( |
*i, URLPattern::PARSE_LENIENT)) { |
NOTREACHED(); // Corrupt prefs? Hand editing? |
} else { |
+ if (!allow_file_access && pattern.MatchesScheme(chrome::kFileScheme)) { |
+ if (pattern.scheme() == chrome::kFileScheme) { |
+ continue; |
+ } else { |
+ CHECK_EQ("*", pattern.scheme()); |
+ pattern.set_valid_schemes( |
+ pattern.valid_schemes() & ~URLPattern::SCHEME_FILE); |
+ } |
+ } |
host_extent->AddPattern(pattern); |
} |
} |