Revert 95815 - Make extension file URL access opt-in.
This corrects an issue causing file URL access to default on for <all_urls> and file:/// permissions. We also revert all extension's "allow file access" flags to false since we can't distinguish between extensions that were installed with the bug present and those where the user clicked allow file access. Unpacked extensions will now have opt-in file access as well.
BUG=91577
TEST=ExtensionServiceTest.DefaultFileAccess
Review URL: http://codereview.chromium.org/7574017
[email protected]
Review URL: http://codereview.chromium.org/7595005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95820 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 0ac80c7..5c05c6c 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -304,7 +304,12 @@
const FilePath& extension_path, bool prompt_for_plugins) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
std::string id = Extension::GenerateIdForPath(extension_path);
- bool allow_file_access = frontend_->extension_prefs()->AllowFileAccess(id);
+ // Unpacked extensions default to allowing file access, but if that has been
+ // overridden, don't reset the value.
+ bool allow_file_access =
+ Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD);
+ if (frontend_->extension_prefs()->HasAllowFileAccessSetting(id))
+ allow_file_access = frontend_->extension_prefs()->AllowFileAccess(id);
BrowserThread::PostTask(BrowserThread::FILE, FROM_HERE,
NewRunnableMethod(
@@ -1029,9 +1034,13 @@
file_util::AbsolutePath(&extension_path);
std::string id = Extension::GenerateIdForPath(extension_path);
+ bool allow_file_access =
+ Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD);
+ if (extension_prefs()->HasAllowFileAccessSetting(id))
+ allow_file_access = extension_prefs()->AllowFileAccess(id);
int flags = Extension::NO_FLAGS;
- if (extension_prefs()->AllowFileAccess(id))
+ if (allow_file_access)
flags |= Extension::ALLOW_FILE_ACCESS;
if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD))
flags |= Extension::STRICT_ERROR_CHECKS;
@@ -2196,6 +2205,13 @@
initial_enable ? Extension::ENABLED : Extension::DISABLED,
from_webstore);
+ // Unpacked extensions default to allowing file access, but if that has been
+ // overridden, don't reset the value.
+ if (Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD) &&
+ !extension_prefs_->HasAllowFileAccessSetting(id)) {
+ extension_prefs_->SetAllowFileAccess(id, true);
+ }
+
NotificationService::current()->Notify(
chrome::NOTIFICATION_EXTENSION_INSTALLED,
Source<Profile>(profile_),