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

Unified Diff: extensions/renderer/script_injection_manager.cc

Issue 492133002: Renderer changes for wiring up shared memory with declarative injection (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed up tests and responded to other comments Created 6 years, 4 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/renderer/script_injection_manager.cc
diff --git a/extensions/renderer/script_injection_manager.cc b/extensions/renderer/script_injection_manager.cc
index 2d18757f2caceb601b39c7a771d4bef5713c61f7..2dc7f7ded668be6d7372e5a92456aa7626df21ae 100644
--- a/extensions/renderer/script_injection_manager.cc
+++ b/extensions/renderer/script_injection_manager.cc
@@ -48,6 +48,10 @@ class ScriptInjectionManager::RVOHelper : public content::RenderViewObserver {
virtual void OnDestruct() OVERRIDE;
virtual void OnExecuteCode(const ExtensionMsg_ExecuteCode_Params& params);
+ virtual void OnExecuteDeclarativeScript(int tab_id,
+ const ExtensionId& extension_id,
+ int64 script_id,
+ const GURL& url);
virtual void OnPermitScriptInjection(int64 request_id);
// Tells the ScriptInjectionManager to run tasks associated with
@@ -87,6 +91,8 @@ bool ScriptInjectionManager::RVOHelper::OnMessageReceived(
IPC_MESSAGE_HANDLER(ExtensionMsg_ExecuteCode, OnExecuteCode)
IPC_MESSAGE_HANDLER(ExtensionMsg_PermitScriptInjection,
OnPermitScriptInjection)
+ IPC_MESSAGE_HANDLER(ExtensionMsg_ExecuteDeclarativeScript,
+ OnExecuteDeclarativeScript)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
@@ -150,6 +156,19 @@ void ScriptInjectionManager::RVOHelper::OnExecuteCode(
manager_->HandleExecuteCode(params, render_view());
}
+void ScriptInjectionManager::RVOHelper::OnExecuteDeclarativeScript(
+ int tab_id,
+ const ExtensionId& extension_id,
+ int64 script_id,
+ const GURL& url) {
+ blink::WebFrame* main_frame = render_view()->GetWebView()->mainFrame();
Devlin 2014/08/27 23:01:11 We should a) NULL-check the main frame. b) check t
Mark Dittmer 2014/08/28 13:02:42 Done. I have one potential concern, but I don't th
Devlin 2014/08/28 17:53:57 The only time it wouldn't inject before a page cha
+ manager_->HandleExecuteDeclarativeScript(main_frame,
+ tab_id,
+ extension_id,
+ script_id,
+ url);
+}
+
void ScriptInjectionManager::RVOHelper::OnPermitScriptInjection(
int64 request_id) {
manager_->HandlePermitScriptInjection(request_id);
@@ -323,6 +342,30 @@ void ScriptInjectionManager::HandleExecuteCode(
}
}
+void ScriptInjectionManager::HandleExecuteDeclarativeScript(
+ blink::WebFrame* web_frame,
+ int tab_id,
+ const ExtensionId& extension_id,
+ int64 script_id,
Devlin 2014/08/27 23:01:11 these aren't int64s...
Mark Dittmer 2014/08/28 13:02:42 Done. Here and user_script_set_manager.
+ const GURL& url) {
+ const Extension* extension = extensions_->GetByID(extension_id);
+ scoped_ptr<ScriptInjection> injection =
+ user_script_set_manager_->GetInjectionForDeclarativeScript(
+ script_id,
+ web_frame,
+ tab_id,
+ url,
+ extension);
+ if (injection.get()) {
+ ScriptsRunInfo scripts_run_info;
+ // TODO(markdittmer): Use return value of TryToInject for error handling.
+ injection->TryToInject(UserScript::BROWSER_DRIVEN,
+ extension,
+ &scripts_run_info);
+ scripts_run_info.LogRun(web_frame, UserScript::BROWSER_DRIVEN);
+ }
+}
+
void ScriptInjectionManager::HandlePermitScriptInjection(int64 request_id) {
ScopedVector<ScriptInjection>::iterator iter =
pending_injections_.begin();

Powered by Google App Engine
This is Rietveld 408576698