| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_helper.h" | 5 #include "content/browser/renderer_host/render_widget_helper.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/posix/eintr_wrapper.h" | 10 #include "base/posix/eintr_wrapper.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 | 95 |
| 96 void RenderWidgetHelper::OnResumeDeferredNavigation( | 96 void RenderWidgetHelper::OnResumeDeferredNavigation( |
| 97 const GlobalRequestID& request_id) { | 97 const GlobalRequestID& request_id) { |
| 98 resource_dispatcher_host_->ResumeDeferredNavigation(request_id); | 98 resource_dispatcher_host_->ResumeDeferredNavigation(request_id); |
| 99 } | 99 } |
| 100 | 100 |
| 101 void RenderWidgetHelper::CreateNewWindow( | 101 void RenderWidgetHelper::CreateNewWindow( |
| 102 const ViewHostMsg_CreateWindow_Params& params, | 102 const ViewHostMsg_CreateWindow_Params& params, |
| 103 bool no_javascript_access, | 103 bool no_javascript_access, |
| 104 base::ProcessHandle render_process, | 104 base::ProcessHandle render_process, |
| 105 int* route_id, | 105 int32* route_id, |
| 106 int* main_frame_route_id, | 106 int32* main_frame_route_id, |
| 107 int32* main_frame_widget_route_id, |
| 107 SessionStorageNamespace* session_storage_namespace) { | 108 SessionStorageNamespace* session_storage_namespace) { |
| 108 if (params.opener_suppressed || no_javascript_access) { | 109 if (params.opener_suppressed || no_javascript_access) { |
| 109 // If the opener is supppressed or script access is disallowed, we should | 110 // If the opener is supppressed or script access is disallowed, we should |
| 110 // open the window in a new BrowsingInstance, and thus a new process. That | 111 // open the window in a new BrowsingInstance, and thus a new process. That |
| 111 // means the current renderer process will not be able to route messages to | 112 // means the current renderer process will not be able to route messages to |
| 112 // it. Because of this, we will immediately show and navigate the window | 113 // it. Because of this, we will immediately show and navigate the window |
| 113 // in OnCreateWindowOnUI, using the params provided here. | 114 // in OnCreateWindowOnUI, using the params provided here. |
| 114 *route_id = MSG_ROUTING_NONE; | 115 *route_id = MSG_ROUTING_NONE; |
| 115 *main_frame_route_id = MSG_ROUTING_NONE; | 116 *main_frame_route_id = MSG_ROUTING_NONE; |
| 117 *main_frame_widget_route_id = MSG_ROUTING_NONE; |
| 116 } else { | 118 } else { |
| 117 *route_id = GetNextRoutingID(); | 119 *route_id = GetNextRoutingID(); |
| 118 *main_frame_route_id = GetNextRoutingID(); | 120 *main_frame_route_id = GetNextRoutingID(); |
| 121 // TODO(avi): When RenderViewHostImpl has-a RenderWidgetHostImpl, this |
| 122 // should be updated to give the widget a distinct routing ID. |
| 123 // https://crbug.com/545684 |
| 124 *main_frame_widget_route_id = *route_id; |
| 119 // Block resource requests until the view is created, since the HWND might | 125 // Block resource requests until the view is created, since the HWND might |
| 120 // be needed if a response ends up creating a plugin. | 126 // be needed if a response ends up creating a plugin. |
| 121 resource_dispatcher_host_->BlockRequestsForRoute( | 127 resource_dispatcher_host_->BlockRequestsForRoute( |
| 122 render_process_id_, *route_id); | 128 render_process_id_, *route_id); |
| 123 resource_dispatcher_host_->BlockRequestsForRoute( | 129 resource_dispatcher_host_->BlockRequestsForRoute( |
| 124 render_process_id_, *main_frame_route_id); | 130 render_process_id_, *main_frame_route_id); |
| 125 } | 131 } |
| 126 | 132 |
| 127 BrowserThread::PostTask( | 133 BrowserThread::PostTask( |
| 128 BrowserThread::UI, FROM_HERE, | 134 BrowserThread::UI, FROM_HERE, |
| 129 base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, | 135 base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, this, params, |
| 130 this, params, *route_id, *main_frame_route_id, | 136 *route_id, *main_frame_route_id, *main_frame_widget_route_id, |
| 131 make_scoped_refptr(session_storage_namespace))); | 137 make_scoped_refptr(session_storage_namespace))); |
| 132 } | 138 } |
| 133 | 139 |
| 134 void RenderWidgetHelper::OnCreateWindowOnUI( | 140 void RenderWidgetHelper::OnCreateWindowOnUI( |
| 135 const ViewHostMsg_CreateWindow_Params& params, | 141 const ViewHostMsg_CreateWindow_Params& params, |
| 136 int route_id, | 142 int32 route_id, |
| 137 int main_frame_route_id, | 143 int32 main_frame_route_id, |
| 144 int32 main_frame_widget_route_id, |
| 138 SessionStorageNamespace* session_storage_namespace) { | 145 SessionStorageNamespace* session_storage_namespace) { |
| 139 RenderViewHostImpl* host = | 146 RenderViewHostImpl* host = |
| 140 RenderViewHostImpl::FromID(render_process_id_, params.opener_id); | 147 RenderViewHostImpl::FromID(render_process_id_, params.opener_id); |
| 141 if (host) | 148 if (host) |
| 142 host->CreateNewWindow(route_id, main_frame_route_id, params, | 149 host->CreateNewWindow(route_id, main_frame_route_id, |
| 143 session_storage_namespace); | 150 main_frame_widget_route_id, params, |
| 151 session_storage_namespace); |
| 144 } | 152 } |
| 145 | 153 |
| 146 void RenderWidgetHelper::OnResumeRequestsForView(int route_id) { | 154 void RenderWidgetHelper::OnResumeRequestsForView(int route_id) { |
| 147 resource_dispatcher_host_->ResumeBlockedRequestsForRoute( | 155 resource_dispatcher_host_->ResumeBlockedRequestsForRoute( |
| 148 render_process_id_, route_id); | 156 render_process_id_, route_id); |
| 149 } | 157 } |
| 150 | 158 |
| 151 void RenderWidgetHelper::CreateNewWidget(int opener_id, | 159 void RenderWidgetHelper::CreateNewWidget(int opener_id, |
| 152 blink::WebPopupType popup_type, | 160 blink::WebPopupType popup_type, |
| 153 int* route_id) { | 161 int* route_id) { |
| (...skipping 23 matching lines...) Expand all Loading... |
| 177 | 185 |
| 178 void RenderWidgetHelper::OnCreateFullscreenWidgetOnUI(int32 opener_id, | 186 void RenderWidgetHelper::OnCreateFullscreenWidgetOnUI(int32 opener_id, |
| 179 int32 route_id) { | 187 int32 route_id) { |
| 180 RenderViewHostImpl* host = RenderViewHostImpl::FromID( | 188 RenderViewHostImpl* host = RenderViewHostImpl::FromID( |
| 181 render_process_id_, opener_id); | 189 render_process_id_, opener_id); |
| 182 if (host) | 190 if (host) |
| 183 host->CreateNewFullscreenWidget(route_id); | 191 host->CreateNewFullscreenWidget(route_id); |
| 184 } | 192 } |
| 185 | 193 |
| 186 } // namespace content | 194 } // namespace content |
| OLD | NEW |