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

Unified Diff: extensions/browser/user_script_loader.cc

Issue 959413003: Implement <webview>.addContentScript/removeContentScript API [1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Delvin's comments. Created 5 years, 8 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
Index: extensions/browser/user_script_loader.cc
diff --git a/extensions/browser/user_script_loader.cc b/extensions/browser/user_script_loader.cc
index 1a0571870782474a1c94e1bc64150f1659793002..80d464089dcfc751314c0f1427981f0349c81b1a 100644
--- a/extensions/browser/user_script_loader.cc
+++ b/extensions/browser/user_script_loader.cc
@@ -444,25 +444,10 @@ void UserScriptLoader::OnScriptsLoaded(
// We've got scripts ready to go.
shared_memory_.reset(shared_memory.release());
- // If user scripts are coming from a <webview>, will only notify the
- // 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_);
- }
+ for (content::RenderProcessHost::iterator i(
+ content::RenderProcessHost::AllHostsIterator());
+ !i.IsAtEnd(); i.Advance()) {
+ SendUpdate(i.GetCurrentValue(), shared_memory_.get(), changed_hosts_);
}
changed_hosts_.clear();
@@ -475,8 +460,8 @@ void UserScriptLoader::OnScriptsLoaded(
void UserScriptLoader::SendUpdate(content::RenderProcessHost* process,
base::SharedMemory* shared_memory,
const std::set<HostID>& changed_hosts) {
- // Don't allow injection of content scripts into <webview>.
- if (process->IsIsolatedGuest())
+ // Don't allow injection of extensions' content scripts into <webview>.
+ if (process->IsIsolatedGuest() && host_id().id().empty())
return;
// Make sure we only send user scripts to processes in our browser_context.

Powered by Google App Engine
This is Rietveld 408576698