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

Unified Diff: chrome/browser/extensions/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: Rebase and remove ConsumerInstanceInfo(id). 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: 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();
« 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