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, ...@@ -322,7 +322,8 @@ void BrowserPluginGuest::AddNewContents(WebContents* source,
const gfx::Rect& initial_pos, const gfx::Rect& initial_pos,
bool user_gesture, bool user_gesture,
bool* was_blocked) { bool* was_blocked) {
*was_blocked = false; if (was_blocked)
*was_blocked = false;
RequestNewWindowPermission(static_cast<WebContentsImpl*>(new_contents), RequestNewWindowPermission(static_cast<WebContentsImpl*>(new_contents),
disposition, initial_pos, user_gesture); disposition, initial_pos, user_gesture);
} }
...@@ -698,7 +699,6 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) { ...@@ -698,7 +699,6 @@ bool BrowserPluginGuest::OnMessageReceived(const IPC::Message& message) {
// renderer process paints inside. // renderer process paints inside.
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup)
#endif #endif
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView)
IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget)
IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus)
IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse)
...@@ -724,13 +724,6 @@ void BrowserPluginGuest::Attach( ...@@ -724,13 +724,6 @@ void BrowserPluginGuest::Attach(
WebContentsViewGuest* new_view = WebContentsViewGuest* new_view =
static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); static_cast<WebContentsViewGuest*>(GetWebContents()->GetView());
new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); 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 // 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. // lifetime of the new guest is no longer managed by the opener guest.
...@@ -1084,18 +1077,6 @@ void BrowserPluginGuest::OnShowPopup( ...@@ -1084,18 +1077,6 @@ void BrowserPluginGuest::OnShowPopup(
} }
#endif #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, void BrowserPluginGuest::OnShowWidget(int route_id,
const gfx::Rect& initial_pos) { const gfx::Rect& initial_pos) {
gfx::Rect screen_pos(initial_pos); gfx::Rect screen_pos(initial_pos);
......
...@@ -195,9 +195,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, ...@@ -195,9 +195,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
// Exposes the protected web_contents() from WebContentsObserver. // Exposes the protected web_contents() from WebContentsObserver.
WebContentsImpl* GetWebContents(); WebContentsImpl* GetWebContents();
// Kill the guest process.
void Terminate();
// Overridden in tests. // Overridden in tests.
virtual void SetDamageBuffer( virtual void SetDamageBuffer(
const BrowserPluginHostMsg_ResizeGuest_Params& params); const BrowserPluginHostMsg_ResizeGuest_Params& params);
...@@ -376,10 +373,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver, ...@@ -376,10 +373,6 @@ class CONTENT_EXPORT BrowserPluginGuest : public NotificationObserver,
#if defined(OS_MACOSX) #if defined(OS_MACOSX)
void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params); void OnShowPopup(const ViewHostMsg_ShowPopup_Params& params);
#endif #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); void OnShowWidget(int route_id, const gfx::Rect& initial_pos);
// Overriden in tests. // Overriden in tests.
virtual void OnTakeFocus(bool reverse); virtual void OnTakeFocus(bool reverse);
......
...@@ -1355,15 +1355,15 @@ void WebContentsImpl::CreateNewWindow( ...@@ -1355,15 +1355,15 @@ void WebContentsImpl::CreateNewWindow(
new_contents->Init(create_params); new_contents->Init(create_params);
// Save the window for later if we're not suppressing the opener (since it // 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 // will be shown immediately).
// track when to show guests). if (!params.opener_suppressed) {
if (!params.opener_suppressed && !is_guest) { if (!is_guest) {
WebContentsViewPort* new_view = new_contents->view_.get(); WebContentsViewPort* new_view = new_contents->view_.get();
// TODO(brettw): It seems bogus that we have to call this function on the // 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. // newly created object and give it one of its own member variables.
new_view->CreateViewForWidget(new_contents->GetRenderViewHost()); new_view->CreateViewForWidget(new_contents->GetRenderViewHost());
}
// Save the created window associated with the route so we can show it // Save the created window associated with the route so we can show it
// later. // later.
DCHECK_NE(MSG_ROUTING_NONE, route_id); DCHECK_NE(MSG_ROUTING_NONE, route_id);
...@@ -1507,6 +1507,10 @@ WebContentsImpl* WebContentsImpl::GetCreatedWindow(int route_id) { ...@@ -1507,6 +1507,10 @@ WebContentsImpl* WebContentsImpl::GetCreatedWindow(int route_id) {
registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED, registrar_.Remove(this, NOTIFICATION_WEB_CONTENTS_DESTROYED,
Source<WebContents>(new_contents)); Source<WebContents>(new_contents));
// Don't initialize the guest WebContents immediately.
if (new_contents->GetRenderProcessHost()->IsGuest())
return new_contents;
if (!new_contents->GetRenderProcessHost()->HasConnection() || if (!new_contents->GetRenderProcessHost()->HasConnection() ||
!new_contents->GetRenderViewHost()->GetView()) !new_contents->GetRenderViewHost()->GetView())
return NULL; 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