diff options
author | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-11 01:40:00 +0000 |
---|---|---|
committer | rdevlin.cronin@chromium.org <rdevlin.cronin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-05-11 01:40:00 +0000 |
commit | 39ef0a7c5702b00d8a502f58fce6c6ab503b5496 (patch) | |
tree | 35b5da1749ccfce7b23941a2a23091330f67016e /extensions/renderer/user_script_slave.cc | |
parent | 0d05a1587e9fd1af5c29facbf72f37aa121747ad (diff) | |
download | chromium_src-39ef0a7c5702b00d8a502f58fce6c6ab503b5496.zip chromium_src-39ef0a7c5702b00d8a502f58fce6c6ab503b5496.tar.gz chromium_src-39ef0a7c5702b00d8a502f58fce6c6ab503b5496.tar.bz2 |
Introduce ActiveScriptController, track active extension scripts.
ActiveScriptController tracks all running active scripts (content scripts and
scripts injected via tabs.executeScript), and, if the flag is enabled, ensures
an ExtensionAction is displayed in the location bar.
Next step: Require permission before executing scripts.
TBR=sky@chromium.org (mechanical, no-impact changes to c/b/ui)
BUG=362353
Review URL: https://codereview.chromium.org/270153004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@269681 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'extensions/renderer/user_script_slave.cc')
-rw-r--r-- | extensions/renderer/user_script_slave.cc | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/extensions/renderer/user_script_slave.cc b/extensions/renderer/user_script_slave.cc index 64cd3f6..f05d214 100644 --- a/extensions/renderer/user_script_slave.cc +++ b/extensions/renderer/user_script_slave.cc @@ -194,6 +194,10 @@ void UserScriptSlave::InjectScripts(WebFrame* frame, ExecutingScriptsMap extensions_executing_scripts; + blink::WebFrame* top_frame = frame->top(); + content::RenderView* top_render_view = + content::RenderView::FromWebView(top_frame->view()); + for (size_t i = 0; i < scripts_.size(); ++i) { std::vector<WebScriptSource> sources; UserScript* script = scripts_[i]; @@ -214,7 +218,7 @@ void UserScriptSlave::InjectScripts(WebFrame* frame, const int kNoProcessId = -1; if (!PermissionsData::CanExecuteScriptOnPage(extension, data_source_url, - frame->top()->document().url(), + top_frame->document().url(), kNoTabId, script, kNoProcessId, @@ -234,6 +238,15 @@ void UserScriptSlave::InjectScripts(WebFrame* frame, } if (script->run_location() == location) { + // TODO(rdevlin.cronin): Right now, this is just a notification, but soon + // we should block without user consent. + if (PermissionsData::RequiresActionForScriptExecution(extension)) { + top_render_view->Send( + new ExtensionHostMsg_NotifyExtensionScriptExecution( + top_render_view->GetRoutingID(), + extension->id(), + top_render_view->GetPageId())); + } num_scripts += script->js_scripts().size(); for (size_t j = 0; j < script->js_scripts().size(); ++j) { UserScript::File& file = script->js_scripts()[j]; @@ -282,13 +295,10 @@ void UserScriptSlave::InjectScripts(WebFrame* frame, // Notify the browser if any extensions are now executing scripts. if (!extensions_executing_scripts.empty()) { - blink::WebFrame* top_frame = frame->top(); - content::RenderView* render_view = - content::RenderView::FromWebView(top_frame->view()); - render_view->Send(new ExtensionHostMsg_ContentScriptsExecuting( - render_view->GetRoutingID(), + top_render_view->Send(new ExtensionHostMsg_ContentScriptsExecuting( + top_render_view->GetRoutingID(), extensions_executing_scripts, - render_view->GetPageId(), + top_render_view->GetPageId(), ScriptContext::GetDataSourceURLForFrame(top_frame))); } |