OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_view_host.h" | 5 #include "content/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 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 is_waiting_for_beforeunload_ack_ = true; | 285 is_waiting_for_beforeunload_ack_ = true; |
286 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; | 286 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; |
287 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 287 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
288 Send(new ViewMsg_ShouldClose(routing_id())); | 288 Send(new ViewMsg_ShouldClose(routing_id())); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 void RenderViewHost::ClosePage(bool for_cross_site_transition, | 292 void RenderViewHost::ClosePage(bool for_cross_site_transition, |
293 int new_render_process_host_id, | 293 int new_render_process_host_id, |
294 int new_request_id) { | 294 int new_request_id) { |
295 // In most cases, this will not be set to false afterward. Either the tab | 295 // This will be set back to false in OnClosePageACK, just before we close the |
296 // will be closed, or a pending RenderViewHost will replace this one. | 296 // tab or replace it with a pending RVH. There are some cases (such as 204 |
297 // errors) where we'll continue to show this RVH. | |
297 is_waiting_for_unload_ack_ = true; | 298 is_waiting_for_unload_ack_ = true; |
298 // Start the hang monitor in case the renderer hangs in the unload handler. | 299 // Start the hang monitor in case the renderer hangs in the unload handler. |
299 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 300 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
300 | 301 |
301 ViewMsg_ClosePage_Params params; | 302 ViewMsg_ClosePage_Params params; |
302 params.closing_process_id = process()->id(); | 303 params.closing_process_id = process()->id(); |
303 params.closing_route_id = routing_id(); | 304 params.closing_route_id = routing_id(); |
304 params.for_cross_site_transition = for_cross_site_transition; | 305 params.for_cross_site_transition = for_cross_site_transition; |
305 params.new_render_process_host_id = new_render_process_host_id; | 306 params.new_render_process_host_id = new_render_process_host_id; |
306 params.new_request_id = new_request_id; | 307 params.new_request_id = new_request_id; |
307 if (IsRenderViewLive()) { | 308 if (IsRenderViewLive()) { |
308 NotificationService::current()->Notify( | 309 NotificationService::current()->Notify( |
309 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, | 310 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, |
310 Source<RenderViewHost>(this), | 311 Source<RenderViewHost>(this), |
311 NotificationService::NoDetails()); | 312 NotificationService::NoDetails()); |
312 | 313 |
313 Send(new ViewMsg_ClosePage(routing_id(), params)); | 314 Send(new ViewMsg_ClosePage(routing_id(), params)); |
314 } else { | 315 } else { |
315 // This RenderViewHost doesn't have a live renderer, so just skip closing | 316 // This RenderViewHost doesn't have a live renderer, so just skip closing |
316 // the page. We must notify the ResourceDispatcherHost on the IO thread, | 317 // the page. We must notify the ResourceDispatcherHost on the IO thread, |
317 // which we will do through the RenderProcessHost's widget helper. | 318 // which we will do through the RenderProcessHost's widget helper. |
318 process()->CrossSiteClosePageACK(params); | 319 process()->CrossSiteClosePageACK(params); |
319 } | 320 } |
320 } | 321 } |
321 | 322 |
323 void RenderViewHost::OnClosePageACK(bool for_cross_site_transition) { | |
324 StopHangMonitorTimeout(); | |
325 is_waiting_for_unload_ack_ = false; | |
326 | |
327 if (!for_cross_site_transition) { | |
brettw
2011/03/24 20:27:49
Can you add a comment here about why this conditio
Charlie Reis
2011/03/24 22:46:03
Done.
| |
328 ClosePageIgnoringUnloadEvents(); | |
329 } | |
330 } | |
331 | |
322 void RenderViewHost::ClosePageIgnoringUnloadEvents() { | 332 void RenderViewHost::ClosePageIgnoringUnloadEvents() { |
323 StopHangMonitorTimeout(); | 333 StopHangMonitorTimeout(); |
324 is_waiting_for_beforeunload_ack_ = false; | 334 is_waiting_for_beforeunload_ack_ = false; |
325 is_waiting_for_unload_ack_ = false; | 335 is_waiting_for_unload_ack_ = false; |
326 | 336 |
327 sudden_termination_allowed_ = true; | 337 sudden_termination_allowed_ = true; |
328 delegate_->Close(this); | 338 delegate_->Close(this); |
329 } | 339 } |
330 | 340 |
331 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, | 341 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, |
(...skipping 1346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1678 LOG(DFATAL) << "Invalid checked state " << checked_state; | 1688 LOG(DFATAL) << "Invalid checked state " << checked_state; |
1679 return; | 1689 return; |
1680 } | 1690 } |
1681 | 1691 |
1682 CommandState state; | 1692 CommandState state; |
1683 state.is_enabled = is_enabled; | 1693 state.is_enabled = is_enabled; |
1684 state.checked_state = | 1694 state.checked_state = |
1685 static_cast<RenderViewCommandCheckedState>(checked_state); | 1695 static_cast<RenderViewCommandCheckedState>(checked_state); |
1686 command_states_[static_cast<RenderViewCommand>(command)] = state; | 1696 command_states_[static_cast<RenderViewCommand>(command)] = state; |
1687 } | 1697 } |
OLD | NEW |