summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc3
-rw-r--r--chrome/browser/renderer_host/render_widget_helper.cc42
-rw-r--r--chrome/browser/renderer_host/render_widget_helper.h21
-rw-r--r--chrome/renderer/render_view.cc29
-rw-r--r--chrome/renderer/render_view.h8
5 files changed, 47 insertions, 56 deletions
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 8fb8108..03bdbc8 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -134,7 +134,8 @@ BrowserRenderProcessHost::BrowserRenderProcessHost(Profile* profile)
base::TimeDelta::FromSeconds(5),
this, &BrowserRenderProcessHost::ClearTransportDIBCache)) {
DCHECK(host_id() >= 0); // We use a negative host_id_ in destruction.
- widget_helper_ = new RenderWidgetHelper(host_id());
+ widget_helper_ = new RenderWidgetHelper(
+ host_id(), g_browser_process->resource_dispatcher_host());
CacheManagerHost::GetInstance()->Add(host_id());
RendererSecurityPolicy::GetInstance()->Add(host_id());
diff --git a/chrome/browser/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc
index 24e1710..eabfe58 100644
--- a/chrome/browser/renderer_host/render_widget_helper.cc
+++ b/chrome/browser/renderer_host/render_widget_helper.cc
@@ -41,7 +41,8 @@ class RenderWidgetHelper::PaintMsgProxy : public Task {
DISALLOW_COPY_AND_ASSIGN(PaintMsgProxy);
};
-RenderWidgetHelper::RenderWidgetHelper(int render_process_id)
+RenderWidgetHelper::RenderWidgetHelper(
+ int render_process_id, ResourceDispatcherHost* resource_dispatcher_host)
: render_process_id_(render_process_id),
ui_loop_(MessageLoop::current()),
#if defined(OS_WIN)
@@ -49,7 +50,8 @@ RenderWidgetHelper::RenderWidgetHelper(int render_process_id)
#elif defined(OS_POSIX)
event_(false /* auto-reset */, false),
#endif
- block_popups_(false) {
+ block_popups_(false),
+ resource_dispatcher_host_(resource_dispatcher_host) {
}
RenderWidgetHelper::~RenderWidgetHelper() {
@@ -71,7 +73,6 @@ void RenderWidgetHelper::CancelResourceRequests(int render_widget_id) {
g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(this,
&RenderWidgetHelper::OnCancelResourceRequests,
- g_browser_process->resource_dispatcher_host(),
render_widget_id));
}
}
@@ -82,7 +83,6 @@ void RenderWidgetHelper::CrossSiteClosePageACK(int new_render_process_host_id,
g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
NewRunnableMethod(this,
&RenderWidgetHelper::OnCrossSiteClosePageACK,
- g_browser_process->resource_dispatcher_host(),
new_render_process_host_id,
new_request_id));
}
@@ -183,16 +183,16 @@ void RenderWidgetHelper::OnDispatchPaintMsg(PaintMsgProxy* proxy) {
}
void RenderWidgetHelper::OnCancelResourceRequests(
- ResourceDispatcherHost* dispatcher,
int render_widget_id) {
- dispatcher->CancelRequestsForRenderView(render_process_id_, render_widget_id);
+ resource_dispatcher_host_->CancelRequestsForRenderView(
+ render_process_id_, render_widget_id);
}
void RenderWidgetHelper::OnCrossSiteClosePageACK(
- ResourceDispatcherHost* dispatcher,
int new_render_process_host_id,
int new_request_id) {
- dispatcher->OnClosePageACK(new_render_process_host_id, new_request_id);
+ resource_dispatcher_host_->OnClosePageACK(
+ new_render_process_host_id, new_request_id);
}
void RenderWidgetHelper::CreateNewWindow(int opener_id,
@@ -225,12 +225,32 @@ void RenderWidgetHelper::CreateNewWindow(int opener_id,
DCHECK(result) << "Couldn't duplicate modal dialog event for the renderer.";
#endif
+ // Block resource requests until the view is created, since the HWND might be
+ // needed if a response ends up creating a plugin.
+ resource_dispatcher_host_->BlockRequestsForRenderView(
+ render_process_id_, *route_id);
+
// The easiest way to reach RenderViewHost is just to send a routed message.
ViewHostMsg_CreateWindowWithRoute msg(opener_id, *route_id,
modal_dialog_event_internal);
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &RenderWidgetHelper::OnSimulateReceivedMessage, msg));
+ this, &RenderWidgetHelper::OnCreateWindowOnUI, msg, *route_id));
+}
+
+void RenderWidgetHelper::OnCreateWindowOnUI(
+ const IPC::Message& message, int route_id) {
+ RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_);
+ if (host)
+ host->OnMessageReceived(message);
+
+ g_browser_process->io_thread()->message_loop()->PostTask(FROM_HERE,
+ NewRunnableMethod(this, &RenderWidgetHelper::OnCreateWindowOnIO, route_id));
+}
+
+void RenderWidgetHelper::OnCreateWindowOnIO(int route_id) {
+ resource_dispatcher_host_->ResumeBlockedRequestsForRenderView(
+ render_process_id_, route_id);
}
void RenderWidgetHelper::CreateNewWidget(int opener_id,
@@ -239,10 +259,10 @@ void RenderWidgetHelper::CreateNewWidget(int opener_id,
*route_id = GetNextRoutingID();
ViewHostMsg_CreateWidgetWithRoute msg(opener_id, *route_id, activatable);
ui_loop_->PostTask(FROM_HERE, NewRunnableMethod(
- this, &RenderWidgetHelper::OnSimulateReceivedMessage, msg));
+ this, &RenderWidgetHelper::OnCreateWidgetOnUI, msg));
}
-void RenderWidgetHelper::OnSimulateReceivedMessage(
+void RenderWidgetHelper::OnCreateWidgetOnUI(
const IPC::Message& message) {
RenderProcessHost* host = RenderProcessHost::FromID(render_process_id_);
if (host)
diff --git a/chrome/browser/renderer_host/render_widget_helper.h b/chrome/browser/renderer_host/render_widget_helper.h
index 317a72e..a3aa321 100644
--- a/chrome/browser/renderer_host/render_widget_helper.h
+++ b/chrome/browser/renderer_host/render_widget_helper.h
@@ -86,7 +86,8 @@ class ResourceDispatcherHost;
class RenderWidgetHelper :
public base::RefCountedThreadSafe<RenderWidgetHelper> {
public:
- RenderWidgetHelper(int render_process_id);
+ RenderWidgetHelper(int render_process_id,
+ ResourceDispatcherHost* resource_dispatcher_host);
~RenderWidgetHelper();
// Gets the next available routing id. This is thread safe.
@@ -151,16 +152,20 @@ class RenderWidgetHelper :
// Called on the UI thread to dispatch a paint message if necessary.
void OnDispatchPaintMsg(PaintMsgProxy* proxy);
- // Called on the UI thread to send a message to the RenderProcessHost.
- void OnSimulateReceivedMessage(const IPC::Message& message);
+ // Called on the UI thread to finish creating a window.
+ void OnCreateWindowOnUI(const IPC::Message& message, int route_id);
+
+ // Called on the IO thread after a window was created on the UI thread.
+ void OnCreateWindowOnIO(int route_id);
+
+ // Called on the UI thread to finish creating a widget.
+ void OnCreateWidgetOnUI(const IPC::Message& message);
// Called on the IO thread to cancel resource requests for the render widget.
- void OnCancelResourceRequests(ResourceDispatcherHost* dispatcher,
- int render_widget_id);
+ void OnCancelResourceRequests(int render_widget_id);
// Called on the IO thread to resume a cross-site response.
- void OnCrossSiteClosePageACK(ResourceDispatcherHost* dispatcher,
- int new_render_process_host_id,
+ void OnCrossSiteClosePageACK(int new_render_process_host_id,
int new_request_id);
#if defined(OS_MACOSX)
@@ -191,6 +196,8 @@ class RenderWidgetHelper :
// Whether popup blocking is enabled or not.
bool block_popups_;
+ ResourceDispatcherHost* resource_dispatcher_host_;
+
DISALLOW_COPY_AND_ASSIGN(RenderWidgetHelper);
};
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc
index 5c2b948..bf010f3 100644
--- a/chrome/renderer/render_view.cc
+++ b/chrome/renderer/render_view.cc
@@ -188,7 +188,6 @@ RenderView::RenderView(RenderThreadBase* render_thread)
disable_popup_blocking_(false),
has_unload_listener_(false),
decrement_shared_popup_at_destruction_(false),
- waiting_for_create_window_ack_(false),
form_field_autofill_request_id_(0),
popup_notification_visible_(false),
delay_seconds_for_form_state_sync_(kDefaultDelaySecondsForFormStateSync) {
@@ -343,18 +342,6 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
main_frame ? main_frame->GetURL() : GURL());
#endif
- // If the current RenderView instance represents a popup, then we
- // need to wait for ViewMsg_CreatingNew_ACK to be sent by the browser.
- // As part of this ack we also receive the browser window handle, which
- // parents any plugins instantiated in this RenderView instance.
- // Plugins can be instantiated only when we receive the parent window
- // handle as they are child windows.
- if (waiting_for_create_window_ack_ &&
- resource_dispatcher_->IsResourceMessage(message)) {
- queued_resource_messages_.push(new IPC::Message(message));
- return;
- }
-
// Let the resource dispatcher intercept resource messages first.
if (resource_dispatcher_->OnMessageReceived(message))
return;
@@ -364,7 +351,6 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
return;
IPC_BEGIN_MESSAGE_MAP(RenderView, message)
- IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck)
IPC_MESSAGE_HANDLER(ViewMsg_CaptureThumbnail, SendThumbnail)
IPC_MESSAGE_HANDLER(ViewMsg_PrintPages, OnPrintPages)
IPC_MESSAGE_HANDLER(ViewMsg_Navigate, OnNavigate)
@@ -451,20 +437,6 @@ void RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_END_MESSAGE_MAP()
}
-// Got a response from the browser after the renderer decided to create a new
-// view.
-void RenderView::OnCreatingNewAck(gfx::NativeViewId parent) {
- CompleteInit(parent);
- waiting_for_create_window_ack_ = false;
-
- while (!queued_resource_messages_.empty()) {
- IPC::Message* queued_msg = queued_resource_messages_.front();
- queued_resource_messages_.pop();
- resource_dispatcher_->OnMessageReceived(*queued_msg);
- delete queued_msg;
- }
-}
-
void RenderView::SendThumbnail() {
WebFrame* main_frame = webview()->GetMainFrame();
if (!main_frame)
@@ -1888,7 +1860,6 @@ WebView* RenderView::CreateWebView(WebView* webview, bool user_gesture) {
prefs, shared_popup_counter_,
routing_id);
view->set_opened_by_user_gesture(user_gesture);
- view->set_waiting_for_create_window_ack(true);
// Copy over the alternate error page URL so we can have alt error pages in
// the new render view (we don't need the browser to send the URL back down).
diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h
index 17f4cd1..9a0ec22 100644
--- a/chrome/renderer/render_view.h
+++ b/chrome/renderer/render_view.h
@@ -442,7 +442,6 @@ class RenderView : public RenderWidget,
void GoToEntryAtOffset(int offset);
// RenderView IPC message handlers
- void OnCreatingNewAck(gfx::NativeViewId parent);
void SendThumbnail();
void OnPrintPages();
void OnNavigate(const ViewMsg_Navigate_Params& params);
@@ -620,10 +619,6 @@ class RenderView : public RenderWidget,
// A helper method used by WasOpenedByUserGesture.
bool WasOpenedByUserGestureHelper() const;
- void set_waiting_for_create_window_ack(bool wait) {
- waiting_for_create_window_ack_ = wait;
- }
-
// Handles resource loads for this view.
scoped_refptr<ResourceDispatcher> resource_dispatcher_;
@@ -785,9 +780,6 @@ class RenderView : public RenderWidget,
// to wait for an ACK from the browser before proceeding.
std::queue<IPC::Message*> queued_resource_messages_;
- // Set if we are waiting for an ack for ViewHostMsg_CreateWindow
- bool waiting_for_create_window_ack_;
-
// The id of the last request sent for form field autofill. Used to ignore
// out of date responses.
int form_field_autofill_request_id_;