summaryrefslogtreecommitdiffstats
path: root/extensions/browser/api/execute_code_function.cc
diff options
context:
space:
mode:
authorhanxi <hanxi@chromium.org>2015-03-09 13:46:59 -0700
committerCommit bot <commit-bot@chromium.org>2015-03-09 20:47:49 +0000
commit79f7a57302cae3f7afcd53c6dff542e32bada999 (patch)
treeffa0c8be372fff6f9c02f7a83e05928cb6472c65 /extensions/browser/api/execute_code_function.cc
parent7b41c6561705c1645d65313d116f35c582bd6247 (diff)
downloadchromium_src-79f7a57302cae3f7afcd53c6dff542e32bada999.zip
chromium_src-79f7a57302cae3f7afcd53c6dff542e32bada999.tar.gz
chromium_src-79f7a57302cae3f7afcd53c6dff542e32bada999.tar.bz2
Enable <webview>.executeScript outside of Apps and Extensions [1]
This patch enables javascript code injection like <webview>.executeScript({code: ...}), but does not include file injection like <webview>.executeScript({file: ...}). File injection will be in another patch. BUG=434081 Review URL: https://codereview.chromium.org/942533003 Cr-Commit-Position: refs/heads/master@{#319727}
Diffstat (limited to 'extensions/browser/api/execute_code_function.cc')
-rw-r--r--extensions/browser/api/execute_code_function.cc8
1 files changed, 6 insertions, 2 deletions
diff --git a/extensions/browser/api/execute_code_function.cc b/extensions/browser/api/execute_code_function.cc
index 21845aa..aebf61f 100644
--- a/extensions/browser/api/execute_code_function.cc
+++ b/extensions/browser/api/execute_code_function.cc
@@ -129,7 +129,7 @@ bool ExecuteCodeFunction::Execute(const std::string& code_string) {
if (!executor)
return false;
- if (!extension())
+ if (!extension() && !IsWebView())
return false;
ScriptExecutor::ScriptType script_type = ScriptExecutor::JAVASCRIPT;
@@ -162,7 +162,7 @@ bool ExecuteCodeFunction::Execute(const std::string& code_string) {
CHECK_NE(UserScript::UNDEFINED, run_at);
executor->ExecuteScript(
- extension()->id(),
+ host_id_,
script_type,
code_string,
frame_scope,
@@ -204,6 +204,10 @@ bool ExecuteCodeFunction::RunAsync() {
if (!details_->file.get())
return false;
+
+ if (!extension())
+ return false;
+
resource_ = extension()->GetResource(*details_->file);
if (resource_.extension_root().empty() || resource_.relative_path().empty()) {