| 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();
|
| + 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,
|
| + 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();
|
|
|