diff options
author | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 17:49:08 +0000 |
---|---|---|
committer | mpcomplete@chromium.org <mpcomplete@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-24 17:49:08 +0000 |
commit | 05c82189519642144323493e1d0cd65c41ce81ce (patch) | |
tree | abb760e7c2d610ab059eec1222fc3d15b6b30db5 /chrome/browser/extensions/user_script_master.cc | |
parent | eb40bc39aafb7933251450019e5b4bcb805982f5 (diff) | |
download | chromium_src-05c82189519642144323493e1d0cd65c41ce81ce.zip chromium_src-05c82189519642144323493e1d0cd65c41ce81ce.tar.gz chromium_src-05c82189519642144323493e1d0cd65c41ce81ce.tar.bz2 |
Require user opt-in before allowing content script injection on file URLs.
BUG=47180
Review URL: http://codereview.chromium.org/2809034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50737 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/user_script_master.cc')
-rw-r--r-- | chrome/browser/extensions/user_script_master.cc | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc index 608f9db..c651c2e 100644 --- a/chrome/browser/extensions/user_script_master.cc +++ b/chrome/browser/extensions/user_script_master.cc @@ -306,6 +306,8 @@ UserScriptMaster::UserScriptMaster(const FilePath& script_dir, Profile* profile) Source<Profile>(profile_)); registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, Source<Profile>(profile_)); + registrar_.Add(this, NotificationType::EXTENSION_USER_SCRIPTS_UPDATED, + Source<Profile>(profile_)); } UserScriptMaster::~UserScriptMaster() { @@ -348,11 +350,14 @@ void UserScriptMaster::Observe(NotificationType type, Extension* extension = Details<Extension>(details).ptr(); bool incognito_enabled = profile_->GetExtensionsService()-> IsIncognitoEnabled(extension); + bool allow_file_access = profile_->GetExtensionsService()-> + AllowFileAccess(extension); const UserScriptList& scripts = extension->content_scripts(); for (UserScriptList::const_iterator iter = scripts.begin(); iter != scripts.end(); ++iter) { lone_scripts_.push_back(*iter); lone_scripts_.back().set_incognito_enabled(incognito_enabled); + lone_scripts_.back().set_allow_file_access(allow_file_access); } if (extensions_service_ready_) StartScan(); @@ -375,6 +380,23 @@ void UserScriptMaster::Observe(NotificationType type, break; } + case NotificationType::EXTENSION_USER_SCRIPTS_UPDATED: { + Extension* extension = Details<Extension>(details).ptr(); + UserScriptList new_lone_scripts; + bool incognito_enabled = profile_->GetExtensionsService()-> + IsIncognitoEnabled(extension); + bool allow_file_access = profile_->GetExtensionsService()-> + AllowFileAccess(extension); + for (UserScriptList::iterator iter = lone_scripts_.begin(); + iter != lone_scripts_.end(); ++iter) { + if (iter->extension_id() == extension->id()) { + iter->set_incognito_enabled(incognito_enabled); + iter->set_allow_file_access(allow_file_access); + } + } + StartScan(); + break; + } default: DCHECK(false); |