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

Unified Diff: extensions/browser/api/execute_code_function.cc

Issue 942533003: Enable <webview>.executeScript outside of Apps and Extensions [1] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@decouple_brower_isolated_world_routingid_user_script_UserScriptSet_non_hostset_2
Patch Set: Add a test. 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/api/execute_code_function.cc
diff --git a/extensions/browser/api/execute_code_function.cc b/extensions/browser/api/execute_code_function.cc
index 21845aa47ec48b07e549e7b449c10d0641799358..aebf61f46b4dd9dcec948e8cfa5326fea796cef3 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()) {

Powered by Google App Engine
This is Rietveld 408576698