Commit d70bea9d authored by fsamuel@chromium.org's avatar fsamuel@chromium.org

Browser Plugin: Simplify NewWindow code

Previously, there were two code paths in BrowserPluginGuest to request a new window (new <webview>) from the embedder: one for suppressed openers and one for unsuppressed openers. This CL unifies the two code paths.

BUG=none
Test=WebViewTest.Shim, WebViewTest.NewWindow


Review URL: https://chromiumcodereview.appspot.com/13649007

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@192499 0039d316-1c4b-4281-b951-d872f2087c98
parent 09e74c42
......@@ -322,7 +322,8 @@ void BrowserPluginGuest::AddNewContents(WebContents* source,
const gfx::Rect& initial_pos,
bool user_gesture,
bool* was_blocked) {
*was_blocked = false;
if (was_blocked)
*was_blocked = false;
RequestNewWindowPermission(static_cast<WebContentsImpl*>(new_contents),
disposition, initial_pos, user_gesture);
}
......@@ -698,7 +699,6 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
// renderer process paints inside.
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
#endif
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
......@@ -724,13 +724,6 @@ void BrowserPluginGuest::Attach(
WebContentsViewGuest* new_view =
static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
new_view->CreateViewForWidget(web_contents()->GetRenderViewHost());
// Reply to ViewHostMsg_ShowView to inform the renderer that the browser has
// processed the move. The browser may have ignored the move, but it
// finished processing. This is used because the renderer keeps a temporary
// cache of the widget position while these asynchronous operations are in
// progress.
Send(new ViewMsg_Move_ACK(web_contents()->GetRoutingID()));
}
// Once a new guest is attached to the DOM of the embedder page, then the
// lifetime of the new guest is no longer managed by the opener guest.
......@@ -1084,18 +1077,6 @@ void BrowserPluginGuest::OnShowPopup(
}
#endif
void BrowserPluginGuest::OnShowView(int route_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_bounds,
bool user_gesture) {
RenderViewHostImpl* rvh = RenderViewHostImpl::FromID(
web_contents()->GetRenderProcessHost()->GetID(), route_id);
WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
WebContents::FromRenderViewHost(rvh));
RequestNewWindowPermission(
web_contents, disposition, initial_bounds, user_gesture);
}
void BrowserPluginGuest::OnShowWidget(int route_id,
const gfx::Rect& initial_pos) {
gfx::Rect screen_pos(initial_pos);
......
......@@ -195,9 +195,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
// Exposes the protected web_contents() from WebContentsObserver.
WebContentsImpl* GetWebContents();
// Kill the guest process.
void Terminate();
// Overridden in tests.
virtual void SetDamageBuffer(
const BrowserPluginHostMsg_ResizeGuest_Params& params);
......@@ -376,10 +373,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
#if defined(OS_MACOSX)
void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params);
#endif
void OnShowView(int route_id,
WindowOpenDisposition disposition,
const gfx::Rect& initial_bounds,
bool user_gesture);
void OnShowWidget(int route_id, const gfx::Rect& initial_pos);
// Overriden in tests.
virtual void OnTakeFocus(bool reverse);
......
......@@ -1355,15 +1355,15 @@ void WebContentsImpl::CreateNewWindow(
new_contents->Init(create_params);
// Save the window for later if we're not suppressing the opener (since it
// will be shown immediately) and if it's not a guest (since we separately
// track when to show guests).
if (!params.opener_suppressed && !is_guest) {
WebContentsViewPort* new_view = new_contents->view_.get();
// TODO(brettw): It seems bogus that we have to call this function on the
// newly created object and give it one of its own member variables.
new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
// will be shown immediately).
if (!params.opener_suppressed) {
if (!is_guest) {
WebContentsViewPort* new_view = new_contents->view_.get();
// TODO(brettw): It seems bogus that we have to call this function on the
// newly created object and give it one of its own member variables.
new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
}
// Save the created window associated with the route so we can show it
// later.
DCHECK_NE(MSG_ROUTING_NONE, route_id);
......@@ -1507,6 +1507,10 @@ WebContentsImpl* WebContentsImpl::GetCreatedWindow(int route_id) {
registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
Source<WebContents>(new_contents));
// Don't initialize the guest WebContents immediately.
if (new_contents->GetRenderProcessHost()->IsGuest())
return new_contents;
if (!new_contents->GetRenderProcessHost()->HasConnection() ||
!new_contents->GetRenderViewHost()->GetView())
return NULL;
......
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