OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/render_view_host.h" | 5 #include "chrome/browser/renderer_host/render_view_host.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 720 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
731 delegate_->LoadStateChanged(url, load_state, upload_position, upload_size); | 731 delegate_->LoadStateChanged(url, load_state, upload_position, upload_size); |
732 } | 732 } |
733 | 733 |
734 bool RenderViewHost::SuddenTerminationAllowed() const { | 734 bool RenderViewHost::SuddenTerminationAllowed() const { |
735 return sudden_termination_allowed_ || process()->sudden_termination_allowed(); | 735 return sudden_termination_allowed_ || process()->sudden_termination_allowed(); |
736 } | 736 } |
737 | 737 |
738 /////////////////////////////////////////////////////////////////////////////// | 738 /////////////////////////////////////////////////////////////////////////////// |
739 // RenderViewHost, IPC message handlers: | 739 // RenderViewHost, IPC message handlers: |
740 | 740 |
741 void RenderViewHost::OnMessageReceived(const IPC::Message& msg) { | 741 bool RenderViewHost::OnMessageReceived(const IPC::Message& msg) { |
742 #if defined(OS_WIN) | 742 #if defined(OS_WIN) |
743 // On Windows there's a potential deadlock with sync messsages going in | 743 // On Windows there's a potential deadlock with sync messsages going in |
744 // a circle from browser -> plugin -> renderer -> browser. | 744 // a circle from browser -> plugin -> renderer -> browser. |
745 // On Linux we can avoid this by avoiding sync messages from browser->plugin. | 745 // On Linux we can avoid this by avoiding sync messages from browser->plugin. |
746 // On Mac we avoid this by not supporting windowed plugins. | 746 // On Mac we avoid this by not supporting windowed plugins. |
747 if (msg.is_sync() && !msg.is_caller_pumping_messages()) { | 747 if (msg.is_sync() && !msg.is_caller_pumping_messages()) { |
748 // NOTE: IF YOU HIT THIS ASSERT, THE SOLUTION IS ALMOST NEVER TO RUN A | 748 // NOTE: IF YOU HIT THIS ASSERT, THE SOLUTION IS ALMOST NEVER TO RUN A |
749 // NESTED MESSAGE LOOP IN THE RENDERER!!! | 749 // NESTED MESSAGE LOOP IN THE RENDERER!!! |
750 // That introduces reentrancy which causes hard to track bugs. You should | 750 // That introduces reentrancy which causes hard to track bugs. You should |
751 // find a way to either turn this into an asynchronous message, or one | 751 // find a way to either turn this into an asynchronous message, or one |
752 // that can be answered on the IO thread. | 752 // that can be answered on the IO thread. |
753 NOTREACHED() << "Can't send sync messages to UI thread without pumping " | 753 NOTREACHED() << "Can't send sync messages to UI thread without pumping " |
754 "messages in the renderer or else deadlocks can occur if the page " | 754 "messages in the renderer or else deadlocks can occur if the page " |
755 "has windowed plugins! (message type " << msg.type() << ")"; | 755 "has windowed plugins! (message type " << msg.type() << ")"; |
756 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); | 756 IPC::Message* reply = IPC::SyncMessage::GenerateReply(&msg); |
757 reply->set_reply_error(); | 757 reply->set_reply_error(); |
758 Send(reply); | 758 Send(reply); |
759 return; | 759 return true; |
760 } | 760 } |
761 #endif | 761 #endif |
762 | 762 |
| 763 bool handled = true; |
763 bool msg_is_ok = true; | 764 bool msg_is_ok = true; |
764 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHost, msg, msg_is_ok) | 765 IPC_BEGIN_MESSAGE_MAP_EX(RenderViewHost, msg, msg_is_ok) |
765 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnMsgShowView) | 766 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnMsgShowView) |
766 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnMsgShowWidget) | 767 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnMsgShowWidget) |
767 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, | 768 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowFullscreenWidget, |
768 OnMsgShowFullscreenWidget) | 769 OnMsgShowFullscreenWidget) |
769 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnMsgRunModal) | 770 IPC_MESSAGE_HANDLER_DELAY_REPLY(ViewHostMsg_RunModal, OnMsgRunModal) |
770 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) | 771 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewReady, OnMsgRenderViewReady) |
771 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) | 772 IPC_MESSAGE_HANDLER(ViewHostMsg_RenderViewGone, OnMsgRenderViewGone) |
772 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_FrameNavigate, OnMsgNavigate(msg)) | 773 IPC_MESSAGE_HANDLER_GENERIC(ViewHostMsg_FrameNavigate, OnMsgNavigate(msg)) |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
910 OnDetectedPhishingSite) | 911 OnDetectedPhishingSite) |
911 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) | 912 IPC_MESSAGE_HANDLER(ViewHostMsg_ScriptEvalResponse, OnScriptEvalResponse) |
912 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, | 913 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateContentRestrictions, |
913 OnUpdateContentRestrictions) | 914 OnUpdateContentRestrictions) |
914 #if defined(OS_MACOSX) | 915 #if defined(OS_MACOSX) |
915 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) | 916 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnMsgShowPopup) |
916 #endif | 917 #endif |
917 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, | 918 IPC_MESSAGE_HANDLER(ViewHostMsg_PagesReadyForPreview, |
918 OnPagesReadyForPreview) | 919 OnPagesReadyForPreview) |
919 // Have the super handle all other messages. | 920 // Have the super handle all other messages. |
920 IPC_MESSAGE_UNHANDLED(RenderWidgetHost::OnMessageReceived(msg)) | 921 IPC_MESSAGE_UNHANDLED(handled = RenderWidgetHost::OnMessageReceived(msg)) |
921 IPC_END_MESSAGE_MAP_EX() | 922 IPC_END_MESSAGE_MAP_EX() |
922 | 923 |
923 if (!msg_is_ok) { | 924 if (!msg_is_ok) { |
924 // The message had a handler, but its de-serialization failed. | 925 // The message had a handler, but its de-serialization failed. |
925 // Kill the renderer. | 926 // Kill the renderer. |
926 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); | 927 UserMetrics::RecordAction(UserMetricsAction("BadMessageTerminate_RVH")); |
927 process()->ReceivedBadMessage(); | 928 process()->ReceivedBadMessage(); |
928 } | 929 } |
| 930 |
| 931 return handled; |
929 } | 932 } |
930 | 933 |
931 void RenderViewHost::Shutdown() { | 934 void RenderViewHost::Shutdown() { |
932 // If we are being run modally (see RunModal), then we need to cleanup. | 935 // If we are being run modally (see RunModal), then we need to cleanup. |
933 if (run_modal_reply_msg_) { | 936 if (run_modal_reply_msg_) { |
934 Send(run_modal_reply_msg_); | 937 Send(run_modal_reply_msg_); |
935 run_modal_reply_msg_ = NULL; | 938 run_modal_reply_msg_ = NULL; |
936 } | 939 } |
937 | 940 |
938 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); | 941 DevToolsManager* devtools_manager = DevToolsManager::GetInstance(); |
(...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2287 if (printer_query.get()) { | 2290 if (printer_query.get()) { |
2288 BrowserThread::PostTask( | 2291 BrowserThread::PostTask( |
2289 BrowserThread::IO, FROM_HERE, | 2292 BrowserThread::IO, FROM_HERE, |
2290 NewRunnableMethod(printer_query.get(), | 2293 NewRunnableMethod(printer_query.get(), |
2291 &printing::PrinterQuery::StopWorker)); | 2294 &printing::PrinterQuery::StopWorker)); |
2292 } | 2295 } |
2293 | 2296 |
2294 // Send the printingDone msg for now. | 2297 // Send the printingDone msg for now. |
2295 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); | 2298 Send(new ViewMsg_PrintingDone(routing_id(), params.document_cookie, true)); |
2296 } | 2299 } |
OLD | NEW |