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

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: Add comments. Created 5 years, 9 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..c28403697544ed87043fc5c39160e370930fb1b1 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,10 +460,6 @@ 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())
- return;
-
// Make sure we only send user scripts to processes in our browser_context.
if (!ExtensionsBrowserClient::Get()->IsSameContext(
browser_context_, process->GetBrowserContext()))
@@ -495,8 +476,9 @@ void UserScriptLoader::SendUpdate(content::RenderProcessHost* 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,
- host_id(), changed_hosts));
+ process->Send(new ExtensionMsg_UpdateUserScripts(
+ handle_for_process, host_id(), changed_hosts,
+ process->IsIsolatedGuest()));
}
}

Powered by Google App Engine
This is Rietveld 408576698