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

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

Issue 288053002: Block content scripts from executing until user grants permission (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: CQ Time! Created 6 years, 7 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/user_script_master.h ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/user_script_master.cc
diff --git a/chrome/browser/extensions/user_script_master.cc b/chrome/browser/extensions/user_script_master.cc
index 1bcf1347ff5a5cdce54f5177ff21a48e07349e7c..e32ceed769dff28d08529ccb7e5a82960cceeb41 100644
--- a/chrome/browser/extensions/user_script_master.cc
+++ b/chrome/browser/extensions/user_script_master.cc
@@ -389,8 +389,11 @@ void UserScriptMaster::NewScriptsAvailable(
for (content::RenderProcessHost::iterator i(
content::RenderProcessHost::AllHostsIterator());
!i.IsAtEnd(); i.Advance()) {
- SendUpdate(i.GetCurrentValue(), shared_memory_.get());
+ SendUpdate(i.GetCurrentValue(),
+ shared_memory_.get(),
+ changed_extensions_);
}
+ changed_extensions_.clear();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_USER_SCRIPTS_UPDATED,
@@ -421,6 +424,7 @@ void UserScriptMaster::OnExtensionLoaded(
user_scripts_.back().set_incognito_enabled(incognito_enabled);
}
if (extensions_service_ready_) {
+ changed_extensions_.insert(extension->id());
if (script_reloader_.get()) {
pending_load_ = true;
} else {
@@ -443,6 +447,7 @@ void UserScriptMaster::OnExtensionUnloaded(
new_user_scripts.push_back(*iter);
}
user_scripts_ = new_user_scripts;
+ changed_extensions_.insert(extension->id());
if (script_reloader_.get()) {
pending_load_ = true;
} else {
@@ -466,8 +471,11 @@ void UserScriptMaster::Observe(int type,
process->GetBrowserContext());
if (!profile_->IsSameProfile(profile))
return;
- if (ScriptsReady())
- SendUpdate(process, GetSharedMemory());
+ if (ScriptsReady()) {
+ SendUpdate(process,
+ GetSharedMemory(),
+ std::set<std::string>()); // Include all extensions.
+ }
break;
}
default:
@@ -490,8 +498,10 @@ void UserScriptMaster::StartLoad() {
script_reloader_->StartLoad(user_scripts_, extensions_info_);
}
-void UserScriptMaster::SendUpdate(content::RenderProcessHost* process,
- base::SharedMemory* shared_memory) {
+void UserScriptMaster::SendUpdate(
+ content::RenderProcessHost* process,
+ base::SharedMemory* shared_memory,
+ const std::set<std::string>& changed_extensions) {
// Don't allow injection of content scripts into <webview>.
if (process->IsGuest())
return;
@@ -511,8 +521,10 @@ void UserScriptMaster::SendUpdate(content::RenderProcessHost* process,
if (!shared_memory->ShareToProcess(handle, &handle_for_process))
return; // This can legitimately fail if the renderer asserts at startup.
- if (base::SharedMemory::IsHandleValid(handle_for_process))
- process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process));
+ if (base::SharedMemory::IsHandleValid(handle_for_process)) {
+ process->Send(new ExtensionMsg_UpdateUserScripts(handle_for_process,
+ changed_extensions));
+ }
}
} // namespace extensions
« no previous file with comments | « chrome/browser/extensions/user_script_master.h ('k') | extensions/common/extension_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698