Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5006)

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 6772022: Make <all_urls> and file:///* in permissions trigger "Allow file access" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix more failures seen on trybots Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_ui_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index cb99385e0b63c712df2dfdb05cd0a57f8bf18636..78d964b41b190dbbe9d266b9055f65ed5edca165 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -199,7 +199,8 @@ void ExtensionServiceBackend::LoadSingleExtension(
FilePath extension_path = path_in;
file_util::AbsolutePath(&extension_path);
- int flags = Extension::NO_FLAGS;
+ int flags = Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD) ?
+ Extension::ALLOW_FILE_ACCESS : Extension::NO_FLAGS;
if (Extension::ShouldDoStrictErrorChecking(Extension::LOAD))
flags |= Extension::STRICT_ERROR_CHECKS;
std::string error;
@@ -798,6 +799,8 @@ void ExtensionService::LoadAllExtensions() {
int flags = Extension::NO_FLAGS;
if (Extension::ShouldDoStrictErrorChecking(info->extension_location))
flags |= Extension::STRICT_ERROR_CHECKS;
+ if (extension_prefs_->AllowFileAccess(info->extension_id))
+ flags |= Extension::ALLOW_FILE_ACCESS;
std::string error;
scoped_refptr<const Extension> extension(
extension_file_util::LoadExtension(
@@ -922,6 +925,8 @@ void ExtensionService::LoadInstalledExtension(const ExtensionInfo& info,
flags |= Extension::REQUIRE_KEY;
if (Extension::ShouldDoStrictErrorChecking(info.extension_location))
flags |= Extension::STRICT_ERROR_CHECKS;
+ if (extension_prefs_->AllowFileAccess(info.extension_id))
+ flags |= Extension::ALLOW_FILE_ACCESS;
extension = Extension::Create(
info.extension_path,
info.extension_location,
@@ -1089,12 +1094,19 @@ bool ExtensionService::AllowFileAccess(const Extension* extension) {
}
void ExtensionService::SetAllowFileAccess(const Extension* extension,
- bool allow) {
+ bool allow) {
+ // Reload to update browser state. Only bother if the value changed and the
+ // extension is actually enabled, since there is no UI otherwise.
+ bool old_allow = AllowFileAccess(extension);
+ if (allow == old_allow)
+ return;
+
extension_prefs_->SetAllowFileAccess(extension->id(), allow);
- NotificationService::current()->Notify(
- NotificationType::EXTENSION_USER_SCRIPTS_UPDATED,
- Source<Profile>(profile_),
- Details<const Extension>(extension));
+
+ bool extension_is_enabled = std::find(extensions_.begin(), extensions_.end(),
+ extension) != extensions_.end();
+ if (extension_is_enabled)
+ ReloadExtension(extension->id());
}
bool ExtensionService::GetBrowserActionVisibility(const Extension* extension) {
@@ -1494,9 +1506,7 @@ void ExtensionService::OnExtensionInstalled(const Extension* extension) {
extension_prefs_->OnExtensionInstalled(
extension, initial_state, initial_enable_incognito);
- // Unpacked extensions start off with file access since they are a developer
- // feature.
- if (extension->location() == Extension::LOAD)
+ if (Extension::ShouldAlwaysAllowFileAccess(Extension::LOAD))
extension_prefs_->SetAllowFileAccess(extension->id(), true);
// If the extension is a theme, tell the profile (and therefore ThemeProvider)
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_ui_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698