| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 // button), so this test makes sure we only send the message once. | 313 // button), so this test makes sure we only send the message once. |
| 314 if (!is_waiting_for_unload_ack_) { | 314 if (!is_waiting_for_unload_ack_) { |
| 315 // Start the hang monitor in case the renderer hangs in the beforeunload | 315 // Start the hang monitor in case the renderer hangs in the beforeunload |
| 316 // handler. | 316 // handler. |
| 317 is_waiting_for_unload_ack_ = true; | 317 is_waiting_for_unload_ack_ = true; |
| 318 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 318 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
| 319 Send(new ViewMsg_ShouldClose(routing_id())); | 319 Send(new ViewMsg_ShouldClose(routing_id())); |
| 320 } | 320 } |
| 321 } | 321 } |
| 322 | 322 |
| 323 void RenderViewHost::FirePageUnload() { | 323 void RenderViewHost::ClosePage(bool for_cross_site_transition, |
| 324 ClosePage(process()->pid(), routing_id()); | 324 int new_render_process_host_id, |
| 325 } | |
| 326 | |
| 327 // static | |
| 328 void RenderViewHost::ClosePageIgnoringUnloadEvents(int render_process_host_id, | |
| 329 int request_id) { | |
| 330 RenderViewHost* rvh = RenderViewHost::FromID(render_process_host_id, | |
| 331 request_id); | |
| 332 if (!rvh) | |
| 333 return; | |
| 334 | |
| 335 rvh->StopHangMonitorTimeout(); | |
| 336 rvh->is_waiting_for_unload_ack_ = false; | |
| 337 | |
| 338 rvh->set_sudden_termination_allowed(true); | |
| 339 rvh->delegate()->Close(rvh); | |
| 340 } | |
| 341 | |
| 342 void RenderViewHost::ClosePage(int new_render_process_host_id, | |
| 343 int new_request_id) { | 325 int new_request_id) { |
| 344 // Start the hang monitor in case the renderer hangs in the unload handler. | 326 // Start the hang monitor in case the renderer hangs in the unload handler. |
| 345 is_waiting_for_unload_ack_ = true; | 327 is_waiting_for_unload_ack_ = true; |
| 346 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 328 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
| 347 | 329 |
| 330 ViewMsg_ClosePage_Params params; |
| 331 params.closing_process_id = process()->pid(); |
| 332 params.closing_route_id = routing_id(); |
| 333 params.for_cross_site_transition = for_cross_site_transition; |
| 334 params.new_render_process_host_id = new_render_process_host_id; |
| 335 params.new_request_id = new_request_id; |
| 348 if (IsRenderViewLive()) { | 336 if (IsRenderViewLive()) { |
| 349 Send(new ViewMsg_ClosePage(routing_id(), | 337 Send(new ViewMsg_ClosePage(routing_id(), params)); |
| 350 new_render_process_host_id, | |
| 351 new_request_id)); | |
| 352 } else { | 338 } else { |
| 353 // This RenderViewHost doesn't have a live renderer, so just skip closing | 339 // This RenderViewHost doesn't have a live renderer, so just skip closing |
| 354 // the page. We must notify the ResourceDispatcherHost on the IO thread, | 340 // the page. We must notify the ResourceDispatcherHost on the IO thread, |
| 355 // which we will do through the RenderProcessHost's widget helper. | 341 // which we will do through the RenderProcessHost's widget helper. |
| 356 process()->CrossSiteClosePageACK(new_render_process_host_id, | 342 process()->CrossSiteClosePageACK(params); |
| 357 new_request_id); | |
| 358 } | 343 } |
| 359 } | 344 } |
| 360 | 345 |
| 346 void RenderViewHost::ClosePageIgnoringUnloadEvents() { |
| 347 StopHangMonitorTimeout(); |
| 348 is_waiting_for_unload_ack_ = false; |
| 349 |
| 350 sudden_termination_allowed_ = true; |
| 351 delegate_->Close(this); |
| 352 } |
| 353 |
| 361 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, | 354 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, |
| 362 int request_id) { | 355 int request_id) { |
| 363 Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest( | 356 Singleton<CrossSiteRequestManager>()->SetHasPendingCrossSiteRequest( |
| 364 process()->pid(), routing_id(), has_pending_request); | 357 process()->pid(), routing_id(), has_pending_request); |
| 365 pending_request_id_ = request_id; | 358 pending_request_id_ = request_id; |
| 366 } | 359 } |
| 367 | 360 |
| 368 int RenderViewHost::GetPendingRequestId() { | 361 int RenderViewHost::GetPendingRequestId() { |
| 369 return pending_request_id_; | 362 return pending_request_id_; |
| 370 } | 363 } |
| (...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1576 | 1569 |
| 1577 void RenderViewHost::SignalModalDialogEvent() { | 1570 void RenderViewHost::SignalModalDialogEvent() { |
| 1578 if (modal_dialog_count_++ == 0) | 1571 if (modal_dialog_count_++ == 0) |
| 1579 modal_dialog_event_->Signal(); | 1572 modal_dialog_event_->Signal(); |
| 1580 } | 1573 } |
| 1581 | 1574 |
| 1582 void RenderViewHost::ResetModalDialogEvent() { | 1575 void RenderViewHost::ResetModalDialogEvent() { |
| 1583 if (--modal_dialog_count_ == 0) | 1576 if (--modal_dialog_count_ == 0) |
| 1584 modal_dialog_event_->Reset(); | 1577 modal_dialog_event_->Reset(); |
| 1585 } | 1578 } |
| OLD | NEW |