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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 is_waiting_for_beforeunload_ack_ = true; | 286 is_waiting_for_beforeunload_ack_ = true; |
287 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; | 287 unload_ack_is_for_cross_site_transition_ = for_cross_site_transition; |
288 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 288 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
289 Send(new ViewMsg_ShouldClose(routing_id())); | 289 Send(new ViewMsg_ShouldClose(routing_id())); |
290 } | 290 } |
291 } | 291 } |
292 | 292 |
293 void RenderViewHost::ClosePage(bool for_cross_site_transition, | 293 void RenderViewHost::ClosePage(bool for_cross_site_transition, |
294 int new_render_process_host_id, | 294 int new_render_process_host_id, |
295 int new_request_id) { | 295 int new_request_id) { |
296 // In most cases, this will not be set to false afterward. Either the tab | 296 // This will be set back to false in OnClosePageACK, just before we close the |
297 // will be closed, or a pending RenderViewHost will replace this one. | 297 // tab or replace it with a pending RVH. There are some cases (such as 204 |
| 298 // errors) where we'll continue to show this RVH. |
298 is_waiting_for_unload_ack_ = true; | 299 is_waiting_for_unload_ack_ = true; |
299 // Start the hang monitor in case the renderer hangs in the unload handler. | 300 // Start the hang monitor in case the renderer hangs in the unload handler. |
300 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); | 301 StartHangMonitorTimeout(TimeDelta::FromMilliseconds(kUnloadTimeoutMS)); |
301 | 302 |
302 ViewMsg_ClosePage_Params params; | 303 ViewMsg_ClosePage_Params params; |
303 params.closing_process_id = process()->id(); | 304 params.closing_process_id = process()->id(); |
304 params.closing_route_id = routing_id(); | 305 params.closing_route_id = routing_id(); |
305 params.for_cross_site_transition = for_cross_site_transition; | 306 params.for_cross_site_transition = for_cross_site_transition; |
306 params.new_render_process_host_id = new_render_process_host_id; | 307 params.new_render_process_host_id = new_render_process_host_id; |
307 params.new_request_id = new_request_id; | 308 params.new_request_id = new_request_id; |
308 if (IsRenderViewLive()) { | 309 if (IsRenderViewLive()) { |
309 NotificationService::current()->Notify( | 310 NotificationService::current()->Notify( |
310 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, | 311 NotificationType::RENDER_VIEW_HOST_WILL_CLOSE_RENDER_VIEW, |
311 Source<RenderViewHost>(this), | 312 Source<RenderViewHost>(this), |
312 NotificationService::NoDetails()); | 313 NotificationService::NoDetails()); |
313 | 314 |
314 Send(new ViewMsg_ClosePage(routing_id(), params)); | 315 Send(new ViewMsg_ClosePage(routing_id(), params)); |
315 } else { | 316 } else { |
316 // This RenderViewHost doesn't have a live renderer, so just skip closing | 317 // This RenderViewHost doesn't have a live renderer, so just skip closing |
317 // the page. We must notify the ResourceDispatcherHost on the IO thread, | 318 // the page. We must notify the ResourceDispatcherHost on the IO thread, |
318 // which we will do through the RenderProcessHost's widget helper. | 319 // which we will do through the RenderProcessHost's widget helper. |
319 process()->CrossSiteClosePageACK(params); | 320 process()->CrossSiteClosePageACK(params); |
320 } | 321 } |
321 } | 322 } |
322 | 323 |
| 324 void RenderViewHost::OnClosePageACK(bool for_cross_site_transition) { |
| 325 StopHangMonitorTimeout(); |
| 326 is_waiting_for_unload_ack_ = false; |
| 327 |
| 328 // If this ClosePageACK is not for a cross-site transition, then it is for an |
| 329 // attempt to close the tab. We have now finished the unload handler and can |
| 330 // proceed with closing the tab. |
| 331 if (!for_cross_site_transition) { |
| 332 ClosePageIgnoringUnloadEvents(); |
| 333 } |
| 334 } |
| 335 |
323 void RenderViewHost::ClosePageIgnoringUnloadEvents() { | 336 void RenderViewHost::ClosePageIgnoringUnloadEvents() { |
324 StopHangMonitorTimeout(); | 337 StopHangMonitorTimeout(); |
325 is_waiting_for_beforeunload_ack_ = false; | 338 is_waiting_for_beforeunload_ack_ = false; |
326 is_waiting_for_unload_ack_ = false; | 339 is_waiting_for_unload_ack_ = false; |
327 | 340 |
328 sudden_termination_allowed_ = true; | 341 sudden_termination_allowed_ = true; |
329 delegate_->Close(this); | 342 delegate_->Close(this); |
330 } | 343 } |
331 | 344 |
332 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, | 345 void RenderViewHost::SetHasPendingCrossSiteRequest(bool has_pending_request, |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 LOG(DFATAL) << "Invalid checked state " << checked_state; | 1678 LOG(DFATAL) << "Invalid checked state " << checked_state; |
1666 return; | 1679 return; |
1667 } | 1680 } |
1668 | 1681 |
1669 CommandState state; | 1682 CommandState state; |
1670 state.is_enabled = is_enabled; | 1683 state.is_enabled = is_enabled; |
1671 state.checked_state = | 1684 state.checked_state = |
1672 static_cast<RenderViewCommandCheckedState>(checked_state); | 1685 static_cast<RenderViewCommandCheckedState>(checked_state); |
1673 command_states_[static_cast<RenderViewCommand>(command)] = state; | 1686 command_states_[static_cast<RenderViewCommand>(command)] = state; |
1674 } | 1687 } |
OLD | NEW |