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

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: nits. Created 5 years, 10 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..40478fc75f900bb614c57eb436141fbd70b1efe0 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,23 @@ bool WebViewInternalExecuteCodeFunction::Init() {
return false;
details_ = details.Pass();
- return true;
+
+ if (extension()) {
+ set_host_id(make_scoped_ptr(new HostID(HostID::EXTENSIONS,
+ extension()->id())));
+ return true;
+ }
+
+ auto rvh = render_view_host();
Devlin 2015/02/25 17:22:36 Why use auto here? It subtracts, rather than adds
Xi Han 2015/02/26 15:13:45 Updated.
+ if (rvh) {
+ WebContents* web_contents = WebContents::FromRenderViewHost(rvh);
+ if (web_contents && web_contents->GetWebUI()) {
+ const GURL& url = rvh->GetSiteInstance()->GetSiteURL();
+ set_host_id(make_scoped_ptr(new HostID(HostID::WEBUI, url.spec())));
+ return true;
+ }
+ }
+ return false;
}
bool WebViewInternalExecuteCodeFunction::ShouldInsertCSS() const {

Powered by Google App Engine
This is Rietveld 408576698