Index: chrome/browser/extensions/user_script_loader.cc |
diff --git a/chrome/browser/extensions/user_script_loader.cc b/chrome/browser/extensions/user_script_loader.cc |
index 24e042ba48284f2202405c3f71331797f9392ce4..f41cd83c2e05e2410cb60bdf7ef6367c0d992854 100644 |
--- a/chrome/browser/extensions/user_script_loader.cc |
+++ b/chrome/browser/extensions/user_script_loader.cc |
@@ -441,11 +441,30 @@ void UserScriptLoader::OnScriptsLoaded( |
// We've got scripts ready to go. |
shared_memory_.reset(shared_memory.release()); |
+ // If user scripts are comming from a <webview>, will only notify the |
+ // RenderProcessHost of that <webview>; otherwise will notify all of the |
+ // RenderProcessHosts. |
+ bool is_web_view = false; |
+ int render_process_id = -1; |
+ const UserScriptList* scripts = user_scripts.get(); |
Devlin
2015/02/23 20:15:00
Why cache this, isntead of just using user_scripts
Xi Han
2015/02/24 16:19:54
Each of them is fine to me. Update.
|
+ if (scripts && !scripts->empty() && |
+ (*scripts)[0].consumer_instance_type() == |
+ UserScript::ConsumerInstanceType::WEBVIEW) { |
+ DCHECK(scripts->size() == 1); |
Devlin
2015/02/23 20:15:00
nit: DCHECK_EQ(1u, scripts->size());
Xi Han
2015/02/24 16:19:54
Done.
|
+ is_web_view = true; |
+ render_process_id = (*scripts)[0].routing_info().render_process_id; |
+ } |
+ |
for (content::RenderProcessHost::iterator i( |
Devlin
2015/02/23 20:15:00
I think this is clearer as:
if (is_web_view) {
R
Fady Samuel
2015/02/23 20:16:57
Does this mean that there is one UserScriptLoader
Xi Han
2015/02/24 16:19:54
Great idea, the logic is much clear now.
Xi Han
2015/02/24 16:19:54
We still have UserScriptLoader per hostID, user sc
|
content::RenderProcessHost::AllHostsIterator()); |
!i.IsAtEnd(); |
i.Advance()) { |
+ if (is_web_view && i.GetCurrentValue()->GetID() != render_process_id) { |
+ continue; |
+ } |
SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_); |
+ if (is_web_view) |
+ break; |
} |
changed_hosts_.clear(); |