| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/gfx/native_widget_types.h" |
| 10 #include "base/string_util.h" | 11 #include "base/string_util.h" |
| 11 #include "base/waitable_event.h" | 12 #include "base/waitable_event.h" |
| 12 #include "chrome/app/result_codes.h" | 13 #include "chrome/app/result_codes.h" |
| 13 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 14 #include "chrome/browser/cross_site_request_manager.h" | 15 #include "chrome/browser/cross_site_request_manager.h" |
| 15 #include "chrome/browser/debugger/debugger_wrapper.h" | 16 #include "chrome/browser/debugger/debugger_wrapper.h" |
| 16 #include "chrome/browser/profile.h" | 17 #include "chrome/browser/profile.h" |
| 17 #include "chrome/browser/metrics/user_metrics.h" | 18 #include "chrome/browser/metrics/user_metrics.h" |
| 18 #include "chrome/browser/renderer_host/render_process_host.h" | 19 #include "chrome/browser/renderer_host/render_process_host.h" |
| 19 #include "chrome/browser/renderer_host/render_view_host_delegate.h" | 20 #include "chrome/browser/renderer_host/render_view_host_delegate.h" |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 // initialized it) or may not (we have our own process or the old process | 123 // initialized it) or may not (we have our own process or the old process |
| 123 // crashed) have been initialized. Calling Init multiple times will be | 124 // crashed) have been initialized. Calling Init multiple times will be |
| 124 // ignored, so this is safe. | 125 // ignored, so this is safe. |
| 125 if (!process()->Init()) | 126 if (!process()->Init()) |
| 126 return false; | 127 return false; |
| 127 DCHECK(process()->channel()); | 128 DCHECK(process()->channel()); |
| 128 DCHECK(process()->profile()); | 129 DCHECK(process()->profile()); |
| 129 | 130 |
| 130 renderer_initialized_ = true; | 131 renderer_initialized_ = true; |
| 131 | 132 |
| 132 HANDLE modal_dialog_event; | 133 #if defined(OS_WIN) |
| 134 HANDLE modal_dialog_event_handle; |
| 133 HANDLE renderer_process_handle = process()->process().handle(); | 135 HANDLE renderer_process_handle = process()->process().handle(); |
| 134 if (renderer_process_handle == NULL) | 136 if (renderer_process_handle == NULL) |
| 135 renderer_process_handle = GetCurrentProcess(); | 137 renderer_process_handle = GetCurrentProcess(); |
| 136 | 138 |
| 137 BOOL result = DuplicateHandle(GetCurrentProcess(), | 139 BOOL result = DuplicateHandle(GetCurrentProcess(), |
| 138 modal_dialog_event_->handle(), | 140 modal_dialog_event_->handle(), |
| 139 renderer_process_handle, | 141 renderer_process_handle, |
| 140 &modal_dialog_event, | 142 &modal_dialog_event_handle, |
| 141 SYNCHRONIZE, | 143 SYNCHRONIZE, |
| 142 FALSE, | 144 FALSE, |
| 143 0); | 145 0); |
| 144 DCHECK(result) << "Couldn't duplicate the modal dialog handle for the renderer
."; | 146 DCHECK(result) << "Couldn't duplicate the modal dialog handle for the renderer
."; |
| 147 #endif |
| 145 | 148 |
| 146 DCHECK(view()); | 149 DCHECK(view()); |
| 147 Send(new ViewMsg_New(view()->GetPluginHWND(), | 150 |
| 151 ModalDialogEvent modal_dialog_event; |
| 152 #if defined(OS_WIN) |
| 153 modal_dialog_event.event = modal_dialog_event_handle; |
| 154 #endif |
| 155 |
| 156 Send(new ViewMsg_New(gfx::IdFromNativeView(view()->GetPluginHWND()), |
| 148 modal_dialog_event, | 157 modal_dialog_event, |
| 149 delegate_->GetWebkitPrefs(), | 158 delegate_->GetWebkitPrefs(), |
| 150 routing_id())); | 159 routing_id())); |
| 151 | 160 |
| 152 // Set the alternate error page, which is profile specific, in the renderer. | 161 // Set the alternate error page, which is profile specific, in the renderer. |
| 153 GURL url = delegate_->GetAlternateErrorPageURL(); | 162 GURL url = delegate_->GetAlternateErrorPageURL(); |
| 154 SetAlternateErrorPageURL(url); | 163 SetAlternateErrorPageURL(url); |
| 155 | 164 |
| 156 // If it's enabled, tell the renderer to set up the Javascript bindings for | 165 // If it's enabled, tell the renderer to set up the Javascript bindings for |
| 157 // sending messages back to the browser. | 166 // sending messages back to the browser. |
| (...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 if (run_modal_reply_msg_) { | 753 if (run_modal_reply_msg_) { |
| 745 if (--modal_dialog_count_ == 0) | 754 if (--modal_dialog_count_ == 0) |
| 746 modal_dialog_event_->Reset(); | 755 modal_dialog_event_->Reset(); |
| 747 Send(run_modal_reply_msg_); | 756 Send(run_modal_reply_msg_); |
| 748 run_modal_reply_msg_ = NULL; | 757 run_modal_reply_msg_ = NULL; |
| 749 } | 758 } |
| 750 RenderWidgetHost::Shutdown(); | 759 RenderWidgetHost::Shutdown(); |
| 751 } | 760 } |
| 752 | 761 |
| 753 void RenderViewHost::OnMsgCreateWindow(int route_id, | 762 void RenderViewHost::OnMsgCreateWindow(int route_id, |
| 754 HANDLE modal_dialog_event) { | 763 ModalDialogEvent modal_dialog_event) { |
| 755 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 764 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 765 base::WaitableEvent* waitable_event = new base::WaitableEvent( |
| 766 #if defined(OS_WIN) |
| 767 modal_dialog_event.event); |
| 768 #else |
| 769 true, false); |
| 770 #endif |
| 771 |
| 756 if (view) | 772 if (view) |
| 757 view->CreateNewWindow(route_id, | 773 view->CreateNewWindow(route_id, waitable_event); |
| 758 new base::WaitableEvent(modal_dialog_event)); | |
| 759 } | 774 } |
| 760 | 775 |
| 761 void RenderViewHost::OnMsgCreateWidget(int route_id, bool activatable) { | 776 void RenderViewHost::OnMsgCreateWidget(int route_id, bool activatable) { |
| 762 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); | 777 RenderViewHostDelegate::View* view = delegate_->GetViewDelegate(); |
| 763 if (view) | 778 if (view) |
| 764 view->CreateNewWidget(route_id, activatable); | 779 view->CreateNewWidget(route_id, activatable); |
| 765 } | 780 } |
| 766 | 781 |
| 767 void RenderViewHost::OnMsgShowView(int route_id, | 782 void RenderViewHost::OnMsgShowView(int route_id, |
| 768 WindowOpenDisposition disposition, | 783 WindowOpenDisposition disposition, |
| (...skipping 510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1279 std::string event_arg) { | 1294 std::string event_arg) { |
| 1280 Send(new ViewMsg_PersonalizationEvent(routing_id(), event_name, event_arg)); | 1295 Send(new ViewMsg_PersonalizationEvent(routing_id(), event_name, event_arg)); |
| 1281 } | 1296 } |
| 1282 #endif | 1297 #endif |
| 1283 | 1298 |
| 1284 void RenderViewHost::ForwardMessageFromExternalHost( | 1299 void RenderViewHost::ForwardMessageFromExternalHost( |
| 1285 const std::string& target, const std::string& message) { | 1300 const std::string& target, const std::string& message) { |
| 1286 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), target, | 1301 Send(new ViewMsg_HandleMessageFromExternalHost(routing_id(), target, |
| 1287 message)); | 1302 message)); |
| 1288 } | 1303 } |
| OLD | NEW |