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

Unified Diff: extensions/browser/api/web_view/web_view_internal_api.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/web_view/web_view_internal_api.cc
diff --git a/extensions/browser/api/web_view/web_view_internal_api.cc b/extensions/browser/api/web_view/web_view_internal_api.cc
index 4b041e911764efabd574034f0e175b015ffebd65..dd9842ad6985207df51b2cf12e617be0fce85875 100644
--- a/extensions/browser/api/web_view/web_view_internal_api.cc
+++ b/extensions/browser/api/web_view/web_view_internal_api.cc
@@ -102,7 +102,19 @@ bool WebViewInternalExecuteCodeFunction::Init() {
return false;
details_ = details.Pass();
- return true;
+
+ if (extension()) {
+ set_host_id(HostID(HostID::EXTENSIONS, extension()->id()));
+ return true;
+ }
+
+ WebContents* web_contents = GetSenderWebContents();
+ if (web_contents && web_contents->GetWebUI()) {
+ const GURL& url = render_view_host()->GetSiteInstance()->GetSiteURL();
+ set_host_id(HostID(HostID::WEBUI, url.spec()));
+ return true;
+ }
+ return false;
}
bool WebViewInternalExecuteCodeFunction::ShouldInsertCSS() const {

Powered by Google App Engine
This is Rietveld 408576698