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

Unified Diff: extensions/browser/user_script_loader.cc

Issue 906493004: Refactoring: de-couple Extensions from "script injection System" [render side]:2 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_1
Patch Set: resubmit Created 5 years, 10 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 | « no previous file | extensions/common/user_script.h » ('j') | extensions/common/user_script.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: extensions/browser/user_script_loader.cc
diff --git a/extensions/browser/user_script_loader.cc b/extensions/browser/user_script_loader.cc
index 2b836332feba5479d89b2d0b271eeab152d76386..cc0ce00cf82f4c2d9a8e0122ca8f6b1d082207c6 100644
--- a/extensions/browser/user_script_loader.cc
+++ b/extensions/browser/user_script_loader.cc
@@ -444,11 +444,24 @@ void UserScriptLoader::OnScriptsLoaded(
// We've got scripts ready to go.
shared_memory_.reset(shared_memory.release());
- for (content::RenderProcessHost::iterator i(
- content::RenderProcessHost::AllHostsIterator());
- !i.IsAtEnd();
- i.Advance()) {
- SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_);
+ // If user scripts are comming from a <webview>, will only notify the
Nico 2015/03/05 00:40:11 nit: "coming"
+ // RenderProcessHost of that <webview>; otherwise will notify all of the
+ // RenderProcessHosts.
+ if (user_scripts && !user_scripts->empty() &&
+ (*user_scripts)[0].consumer_instance_type() ==
+ UserScript::ConsumerInstanceType::WEBVIEW) {
+ DCHECK_EQ(1u, user_scripts->size());
+ int render_process_id = (*user_scripts)[0].routing_info().render_process_id;
+ content::RenderProcessHost* host =
+ content::RenderProcessHost::FromID(render_process_id);
+ if (host)
+ SendUpdate(host, shared_memory_.get(), changed_hosts_);
+ } else {
+ for (content::RenderProcessHost::iterator i(
+ content::RenderProcessHost::AllHostsIterator());
+ !i.IsAtEnd(); i.Advance()) {
+ SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_);
+ }
}
changed_hosts_.clear();
« no previous file with comments | « no previous file | extensions/common/user_script.h » ('j') | extensions/common/user_script.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698