| 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 void RenderWidgetHelper::OnSimulateSwapOutACK( | 243 void RenderWidgetHelper::OnSimulateSwapOutACK( |
| 244 const ViewMsg_SwapOut_Params& params) { | 244 const ViewMsg_SwapOut_Params& params) { |
| 245 resource_dispatcher_host_->OnSimulateSwapOutACK(params); | 245 resource_dispatcher_host_->OnSimulateSwapOutACK(params); |
| 246 } | 246 } |
| 247 | 247 |
| 248 void RenderWidgetHelper::CreateNewWindow( | 248 void RenderWidgetHelper::CreateNewWindow( |
| 249 const ViewHostMsg_CreateWindow_Params& params, | 249 const ViewHostMsg_CreateWindow_Params& params, |
| 250 bool no_javascript_access, | 250 bool no_javascript_access, |
| 251 base::ProcessHandle render_process, | 251 base::ProcessHandle render_process, |
| 252 int* route_id, | 252 int* route_id, |
| 253 int* main_frame_route_id, |
| 253 int* surface_id, | 254 int* surface_id, |
| 254 SessionStorageNamespace* session_storage_namespace) { | 255 SessionStorageNamespace* session_storage_namespace) { |
| 255 if (params.opener_suppressed || no_javascript_access) { | 256 if (params.opener_suppressed || no_javascript_access) { |
| 256 // If the opener is supppressed or script access is disallowed, we should | 257 // If the opener is supppressed or script access is disallowed, we should |
| 257 // open the window in a new BrowsingInstance, and thus a new process. That | 258 // open the window in a new BrowsingInstance, and thus a new process. That |
| 258 // means the current renderer process will not be able to route messages to | 259 // means the current renderer process will not be able to route messages to |
| 259 // it. Because of this, we will immediately show and navigate the window | 260 // it. Because of this, we will immediately show and navigate the window |
| 260 // in OnCreateWindowOnUI, using the params provided here. | 261 // in OnCreateWindowOnUI, using the params provided here. |
| 261 *route_id = MSG_ROUTING_NONE; | 262 *route_id = MSG_ROUTING_NONE; |
| 263 *main_frame_route_id = MSG_ROUTING_NONE; |
| 262 *surface_id = 0; | 264 *surface_id = 0; |
| 263 } else { | 265 } else { |
| 264 *route_id = GetNextRoutingID(); | 266 *route_id = GetNextRoutingID(); |
| 267 *main_frame_route_id = GetNextRoutingID(); |
| 265 *surface_id = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( | 268 *surface_id = GpuSurfaceTracker::Get()->AddSurfaceForRenderer( |
| 266 render_process_id_, *route_id); | 269 render_process_id_, *route_id); |
| 267 // Block resource requests until the view is created, since the HWND might | 270 // Block resource requests until the view is created, since the HWND might |
| 268 // be needed if a response ends up creating a plugin. | 271 // be needed if a response ends up creating a plugin. |
| 269 resource_dispatcher_host_->BlockRequestsForRoute( | 272 resource_dispatcher_host_->BlockRequestsForRoute( |
| 270 render_process_id_, *route_id); | 273 render_process_id_, *route_id); |
| 274 resource_dispatcher_host_->BlockRequestsForRoute( |
| 275 render_process_id_, *main_frame_route_id); |
| 271 } | 276 } |
| 272 | 277 |
| 273 BrowserThread::PostTask( | 278 BrowserThread::PostTask( |
| 274 BrowserThread::UI, FROM_HERE, | 279 BrowserThread::UI, FROM_HERE, |
| 275 base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, | 280 base::Bind(&RenderWidgetHelper::OnCreateWindowOnUI, |
| 276 this, params, *route_id, | 281 this, params, *route_id, *main_frame_route_id, |
| 277 make_scoped_refptr(session_storage_namespace))); | 282 make_scoped_refptr(session_storage_namespace))); |
| 278 } | 283 } |
| 279 | 284 |
| 280 void RenderWidgetHelper::OnCreateWindowOnUI( | 285 void RenderWidgetHelper::OnCreateWindowOnUI( |
| 281 const ViewHostMsg_CreateWindow_Params& params, | 286 const ViewHostMsg_CreateWindow_Params& params, |
| 282 int route_id, | 287 int route_id, |
| 288 int main_frame_route_id, |
| 283 SessionStorageNamespace* session_storage_namespace) { | 289 SessionStorageNamespace* session_storage_namespace) { |
| 284 RenderViewHostImpl* host = | 290 RenderViewHostImpl* host = |
| 285 RenderViewHostImpl::FromID(render_process_id_, params.opener_id); | 291 RenderViewHostImpl::FromID(render_process_id_, params.opener_id); |
| 286 if (host) | 292 if (host) |
| 287 host->CreateNewWindow(route_id, params, session_storage_namespace); | 293 host->CreateNewWindow(route_id, main_frame_route_id, params, |
| 294 session_storage_namespace); |
| 288 } | 295 } |
| 289 | 296 |
| 290 void RenderWidgetHelper::OnResumeRequestsForView(int route_id) { | 297 void RenderWidgetHelper::OnResumeRequestsForView(int route_id) { |
| 291 resource_dispatcher_host_->ResumeBlockedRequestsForRoute( | 298 resource_dispatcher_host_->ResumeBlockedRequestsForRoute( |
| 292 render_process_id_, route_id); | 299 render_process_id_, route_id); |
| 293 } | 300 } |
| 294 | 301 |
| 295 void RenderWidgetHelper::CreateNewWidget(int opener_id, | 302 void RenderWidgetHelper::CreateNewWidget(int opener_id, |
| 296 WebKit::WebPopupType popup_type, | 303 WebKit::WebPopupType popup_type, |
| 297 int* route_id, | 304 int* route_id, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { | 393 i = allocated_dibs_.begin(); i != allocated_dibs_.end(); ++i) { |
| 387 if (HANDLE_EINTR(close(i->second)) < 0) | 394 if (HANDLE_EINTR(close(i->second)) < 0) |
| 388 PLOG(ERROR) << "close: " << i->first; | 395 PLOG(ERROR) << "close: " << i->first; |
| 389 } | 396 } |
| 390 | 397 |
| 391 allocated_dibs_.clear(); | 398 allocated_dibs_.clear(); |
| 392 } | 399 } |
| 393 #endif | 400 #endif |
| 394 | 401 |
| 395 } // namespace content | 402 } // namespace content |
| OLD | NEW |