diff options
Diffstat (limited to 'chrome/browser')
6 files changed, 76 insertions, 27 deletions
diff --git a/chrome/browser/renderer_host/render_view_host.cc b/chrome/browser/renderer_host/render_view_host.cc index 4445099..43de151 100644 --- a/chrome/browser/renderer_host/render_view_host.cc +++ b/chrome/browser/renderer_host/render_view_host.cc @@ -559,8 +559,7 @@ void RenderViewHost::JavaScriptMessageBoxClosed(IPC::Message* reply_msg, } void RenderViewHost::JavaScriptMessageBoxWindowDestroyed() { - if (--modal_dialog_count_ == 0) - modal_dialog_event_->Reset(); + ResetModalDialogEvent(); } void RenderViewHost::ModalHTMLDialogClosed(IPC::Message* reply_msg, @@ -568,8 +567,7 @@ void RenderViewHost::ModalHTMLDialogClosed(IPC::Message* reply_msg, if (is_waiting_for_unload_ack_) StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); - if (--modal_dialog_count_ == 0) - modal_dialog_event_->Reset(); + ResetModalDialogEvent(); ViewHostMsg_ShowModalHTMLDialog::WriteReplyParams(reply_msg, json_retval); Send(reply_msg); @@ -812,8 +810,7 @@ void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { void RenderViewHost::Shutdown() { // If we are being run modally (see RunModal), then we need to cleanup. if (run_modal_reply_msg_) { - if (--modal_dialog_count_ == 0) - modal_dialog_event_->Reset(); + ResetModalDialogEvent(); Send(run_modal_reply_msg_); run_modal_reply_msg_ = NULL; } @@ -865,8 +862,7 @@ void RenderViewHost::OnMsgShowWidget(int route_id, void RenderViewHost::OnMsgRunModal(IPC::Message* reply_msg) { DCHECK(!run_modal_reply_msg_); - if (modal_dialog_count_++ == 0) - modal_dialog_event_->Signal(); + SignalModalDialogEvent(); run_modal_reply_msg_ = reply_msg; // TODO(darin): Bug 1107929: Need to inform our delegate to show this view in @@ -1200,8 +1196,7 @@ void RenderViewHost::OnMsgRunJavaScriptMessage( const int flags, IPC::Message* reply_msg) { StopHangMonitorTimeout(); - if (modal_dialog_count_++ == 0) - modal_dialog_event_->Signal(); + SignalModalDialogEvent(); delegate_->RunJavaScriptMessage(message, default_prompt, frame_url, flags, reply_msg, &are_javascript_messages_suppressed_); @@ -1211,8 +1206,7 @@ void RenderViewHost::OnMsgRunBeforeUnloadConfirm(const GURL& frame_url, const std::wstring& message, IPC::Message* reply_msg) { StopHangMonitorTimeout(); - if (modal_dialog_count_++ == 0) - modal_dialog_event_->Signal(); + SignalModalDialogEvent(); delegate_->RunBeforeUnloadConfirm(message, reply_msg); } @@ -1220,8 +1214,7 @@ void RenderViewHost::OnMsgShowModalHTMLDialog( const GURL& url, int width, int height, const std::string& json_arguments, IPC::Message* reply_msg) { StopHangMonitorTimeout(); - if (modal_dialog_count_++ == 0) - modal_dialog_event_->Signal(); + SignalModalDialogEvent(); delegate_->ShowModalHTMLDialog(url, width, height, json_arguments, reply_msg); } @@ -1509,3 +1502,13 @@ void RenderViewHost::OnAccessibilityFocusChange(int acc_obj_id) { void RenderViewHost::OnCSSInserted() { delegate_->DidInsertCSS(); } + +void RenderViewHost::SignalModalDialogEvent() { + if (modal_dialog_count_++ == 0) + modal_dialog_event_->Signal(); +} + +void RenderViewHost::ResetModalDialogEvent() { + if (--modal_dialog_count_ == 0) + modal_dialog_event_->Reset(); +} diff --git a/chrome/browser/renderer_host/render_view_host.h b/chrome/browser/renderer_host/render_view_host.h index 6d39844..210d74f 100644 --- a/chrome/browser/renderer_host/render_view_host.h +++ b/chrome/browser/renderer_host/render_view_host.h @@ -409,6 +409,9 @@ class RenderViewHost : public RenderWidgetHost, const std::string& response, const std::string& error); + void SignalModalDialogEvent(); + void ResetModalDialogEvent(); + protected: // RenderWidgetHost protected overrides. virtual void UnhandledKeyboardEvent(const NativeWebKeyboardEvent& event); diff --git a/chrome/browser/renderer_host/render_widget_helper.cc b/chrome/browser/renderer_host/render_widget_helper.cc index 7105f8c..9d898b8 100644 --- a/chrome/browser/renderer_host/render_widget_helper.cc +++ b/chrome/browser/renderer_host/render_widget_helper.cc @@ -265,6 +265,36 @@ void RenderWidgetHelper::OnCreateWidgetOnUI( host->CreateNewWidget(route_id, activatable); } +void RenderWidgetHelper::SignalModalDialogEvent(int routing_id) { + ui_loop()->PostTask(FROM_HERE, + NewRunnableMethod( + this, &RenderWidgetHelper::SignalModalDialogEventOnUI, + routing_id)); +} + +void RenderWidgetHelper::SignalModalDialogEventOnUI(int routing_id) { + RenderViewHost* host = RenderViewHost::FromID(render_process_id_, + routing_id); + if (host) { + host->SignalModalDialogEvent(); + } +} + +void RenderWidgetHelper::ResetModalDialogEvent(int routing_id) { + ui_loop()->PostTask(FROM_HERE, + NewRunnableMethod( + this, &RenderWidgetHelper::ResetModalDialogEventOnUI, + routing_id)); +} + +void RenderWidgetHelper::ResetModalDialogEventOnUI(int routing_id) { + RenderViewHost* host = RenderViewHost::FromID(render_process_id_, + routing_id); + if (host) { + host->ResetModalDialogEvent(); + } +} + #if defined(OS_MACOSX) TransportDIB* RenderWidgetHelper::MapTransportDIB(TransportDIB::Id dib_id) { AutoLock locked(allocated_dibs_lock_); diff --git a/chrome/browser/renderer_host/render_widget_helper.h b/chrome/browser/renderer_host/render_widget_helper.h index 5392750..0ff672b 100644 --- a/chrome/browser/renderer_host/render_widget_helper.h +++ b/chrome/browser/renderer_host/render_widget_helper.h @@ -138,6 +138,12 @@ class RenderWidgetHelper : void FreeTransportDIB(TransportDIB::Id dib_id); #endif + // Helper functions to signal and reset the modal dialog event, used to + // signal the renderer that it needs to pump messages while waiting for + // sync calls to return. These functions proxy the request to the UI thread. + void SignalModalDialogEvent(int routing_id); + void ResetModalDialogEvent(int routing_id); + private: // A class used to proxy a paint message. PaintMsgProxy objects are created // on the IO thread and destroyed on the UI thread. @@ -181,6 +187,9 @@ class RenderWidgetHelper : std::map<TransportDIB::Id, int> allocated_dibs_; #endif + void SignalModalDialogEventOnUI(int routing_id); + void ResetModalDialogEventOnUI(int routing_id); + // A map of live paint messages. Must hold pending_paints_lock_ to access. // The PaintMsgProxy objects are not owned by this map. (See PaintMsgProxy // for details about how the lifetime of instances are managed.) diff --git a/chrome/browser/renderer_host/resource_message_filter.cc b/chrome/browser/renderer_host/resource_message_filter.cc index fa3af6ec3..6858430 100644 --- a/chrome/browser/renderer_host/resource_message_filter.cc +++ b/chrome/browser/renderer_host/resource_message_filter.cc @@ -737,15 +737,13 @@ void ResourceMessageFilter::OnGetDefaultPrintSettingsReply( #if defined(OS_WIN) -void ResourceMessageFilter::OnScriptedPrint(gfx::NativeViewId host_window_id, - int cookie, - int expected_pages_count, - bool has_selection, - IPC::Message* reply_msg) { - HWND host_window = gfx::NativeViewFromId(host_window_id); +void ResourceMessageFilter::OnScriptedPrint( + const ViewHostMsg_ScriptedPrint_Params& params, + IPC::Message* reply_msg) { + HWND host_window = gfx::NativeViewFromId(params.host_window_id); scoped_refptr<printing::PrinterQuery> printer_query; - print_job_manager_->PopPrinterQuery(cookie, &printer_query); + print_job_manager_->PopPrinterQuery(params.cookie, &printer_query); if (!printer_query.get()) { printer_query = new printing::PrinterQuery; } @@ -754,6 +752,7 @@ void ResourceMessageFilter::OnScriptedPrint(gfx::NativeViewId host_window_id, this, &ResourceMessageFilter::OnScriptedPrintReply, printer_query, + params.routing_id, reply_msg); // Shows the Print... dialog box. This is asynchronous, only the IPC message // sender will hang until the Print dialog is dismissed. @@ -764,15 +763,19 @@ void ResourceMessageFilter::OnScriptedPrint(gfx::NativeViewId host_window_id, host_window = GetAncestor(host_window, GA_ROOTOWNER); } DCHECK(host_window); + + render_widget_helper_->SignalModalDialogEvent(params.routing_id); + printer_query->GetSettings(printing::PrinterQuery::ASK_USER, host_window, - expected_pages_count, - has_selection, + params.expected_pages_count, + params.has_selection, task); } void ResourceMessageFilter::OnScriptedPrintReply( scoped_refptr<printing::PrinterQuery> printer_query, + int routing_id, IPC::Message* reply_msg) { ViewMsg_PrintPages_Params params; if (printer_query->last_status() != printing::PrintingContext::OK || @@ -791,6 +794,7 @@ void ResourceMessageFilter::OnScriptedPrintReply( } else { printer_query->StopWorker(); } + render_widget_helper_->ResetModalDialogEvent(routing_id); } #endif // OS_WIN diff --git a/chrome/browser/renderer_host/resource_message_filter.h b/chrome/browser/renderer_host/resource_message_filter.h index 91a20d8..70eeaf8 100644 --- a/chrome/browser/renderer_host/resource_message_filter.h +++ b/chrome/browser/renderer_host/resource_message_filter.h @@ -48,6 +48,8 @@ namespace WebKit { struct WebScreenInfo; } +struct ViewHostMsg_ScriptedPrint_Params; + // This class filters out incoming IPC messages for network requests and // processes them on the IPC thread. As a result, network requests are not // delayed by costly UI processing that may be occuring on the main thread of @@ -204,13 +206,11 @@ class ResourceMessageFilter : public IPC::ChannelProxy::MessageFilter, // A javascript code requested to print the current page. The renderer host // have to show to the user the print dialog and returns the selected print // settings. - void OnScriptedPrint(gfx::NativeViewId host_window, - int cookie, - int expected_pages_count, - bool has_selection, + void OnScriptedPrint(const ViewHostMsg_ScriptedPrint_Params& params, IPC::Message* reply_msg); void OnScriptedPrintReply( scoped_refptr<printing::PrinterQuery> printer_query, + int routing_id, IPC::Message* reply_msg); #endif // Browser side transport DIB allocation |