Commit 62d1c31d authored by kalman@chromium.org's avatar kalman@chromium.org

Change GuestViewInternalCreateGuestFunction to create the guest view using the

calling WebContents, not whatever the "associated" WebContents is.

BUG=402318
R=fsamuel@chromium.org, jamescook@chromium.org

Review URL: https://codereview.chromium.org/458323002

Cr-Commit-Position: refs/heads/master@{#289118}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289118 0039d316-1c4b-4281-b951-d872f2087c98
parent 5b97a1c8
...@@ -2252,3 +2252,8 @@ IN_PROC_BROWSER_TEST_F(WebViewCaptureTest, ...@@ -2252,3 +2252,8 @@ IN_PROC_BROWSER_TEST_F(WebViewCaptureTest,
DISABLED_Shim_ScreenshotCapture) { DISABLED_Shim_ScreenshotCapture) {
TestHelper("testScreenshotCapture", "web_view/shim", NO_TEST_SERVER); TestHelper("testScreenshotCapture", "web_view/shim", NO_TEST_SERVER);
} }
IN_PROC_BROWSER_TEST_F(WebViewTest, WebViewInBackgroundPage) {
ASSERT_TRUE(RunExtensionTest("platform_apps/web_view/background"))
<< message_;
}
...@@ -33,12 +33,19 @@ bool GuestViewInternalCreateGuestFunction::RunAsync() { ...@@ -33,12 +33,19 @@ bool GuestViewInternalCreateGuestFunction::RunAsync() {
GuestViewManager::WebContentsCreatedCallback callback = GuestViewManager::WebContentsCreatedCallback callback =
base::Bind(&GuestViewInternalCreateGuestFunction::CreateGuestCallback, base::Bind(&GuestViewInternalCreateGuestFunction::CreateGuestCallback,
this); this);
content::WebContents* embedder_web_contents =
content::WebContents::FromRenderViewHost(render_view_host());
if (!embedder_web_contents) {
error_ = "Guest views can only be embedded in web content";
return false;
}
guest_view_manager->CreateGuest(view_type, guest_view_manager->CreateGuest(view_type,
extension_id(), extension_id(),
GetAssociatedWebContents(), embedder_web_contents,
*create_params, *create_params,
callback); callback);
return true; return true;
} }
......
<!--
* Copyright 2014 The Chromium Authors. All rights reserved. Use of this
* source code is governed by a BSD-style license that can be found in the
* LICENSE file.
-->
<html>
<body>
<webview></webview>
<script src="background.js"></script>
</body>
</html>
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
var pass = chrome.test.callbackPass;
var WEBVIEW_SRC = "data:text/html,<body>One</body>";
chrome.test.runTests([
// Tests that embedding <webview> inside a background page loads.
function inDOM() {
var webview = document.querySelector('webview');
webview.addEventListener('contentload', pass());
webview.setAttribute('src', WEBVIEW_SRC);
},
// Tests that creating and attaching a WebView element inside a background
// page loads.
function newWebView() {
var webview = new WebView();
webview.addEventListener('contentload', pass());
webview.src = WEBVIEW_SRC;
document.body.appendChild(webview);
}
]);
{
"name": "Platform App Test: <webview> background page access",
"version": "1",
"permissions": [
"webview"
],
"app": {
"background": {
"page": "background.html"
}
}
}
...@@ -121,6 +121,9 @@ void GuestViewBase::Init(const std::string& embedder_extension_id, ...@@ -121,6 +121,9 @@ void GuestViewBase::Init(const std::string& embedder_extension_id,
extensions::ExtensionRegistry::Get(browser_context_) extensions::ExtensionRegistry::Get(browser_context_)
->enabled_extensions() ->enabled_extensions()
.GetByID(embedder_extension_id); .GetByID(embedder_extension_id);
// Ok for |embedder_extension| to be NULL, the embedder might be WebUI.
CHECK(embedder_web_contents);
int embedder_process_id = int embedder_process_id =
embedder_web_contents->GetRenderProcessHost()->GetID(); embedder_web_contents->GetRenderProcessHost()->GetID();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment