| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/frame_host/render_frame_host_impl.h" | 5 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 6 | 6 |
| 7 #include "base/containers/hash_tables.h" | 7 #include "base/containers/hash_tables.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/metrics/user_metrics_action.h" | 9 #include "base/metrics/user_metrics_action.h" |
| 10 #include "content/browser/child_process_security_policy_impl.h" | 10 #include "content/browser/child_process_security_policy_impl.h" |
| 11 #include "content/browser/frame_host/cross_process_frame_connector.h" | 11 #include "content/browser/frame_host/cross_process_frame_connector.h" |
| 12 #include "content/browser/frame_host/cross_site_transferring_request.h" | 12 #include "content/browser/frame_host/cross_site_transferring_request.h" |
| 13 #include "content/browser/frame_host/frame_tree.h" | 13 #include "content/browser/frame_host/frame_tree.h" |
| 14 #include "content/browser/frame_host/frame_tree_node.h" | 14 #include "content/browser/frame_host/frame_tree_node.h" |
| 15 #include "content/browser/frame_host/navigator.h" | 15 #include "content/browser/frame_host/navigator.h" |
| 16 #include "content/browser/frame_host/render_frame_host_delegate.h" | 16 #include "content/browser/frame_host/render_frame_host_delegate.h" |
| 17 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 17 #include "content/browser/renderer_host/render_view_host_impl.h" | 18 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 18 #include "content/common/frame_messages.h" | 19 #include "content/common/frame_messages.h" |
| 19 #include "content/common/input_messages.h" | 20 #include "content/common/input_messages.h" |
| 20 #include "content/common/inter_process_time_ticks_converter.h" | 21 #include "content/common/inter_process_time_ticks_converter.h" |
| 21 #include "content/common/swapped_out_messages.h" | 22 #include "content/common/swapped_out_messages.h" |
| 22 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
| 23 #include "content/public/browser/content_browser_client.h" | 24 #include "content/public/browser/content_browser_client.h" |
| 24 #include "content/public/browser/render_process_host.h" | 25 #include "content/public/browser/render_process_host.h" |
| 25 #include "content/public/browser/render_widget_host_view.h" | 26 #include "content/public/browser/render_widget_host_view.h" |
| 26 #include "content/public/browser/user_metrics.h" | 27 #include "content/public/browser/user_metrics.h" |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 const Referrer& referrer, | 446 const Referrer& referrer, |
| 446 PageTransition page_transition, | 447 PageTransition page_transition, |
| 447 bool should_replace_current_entry) { | 448 bool should_replace_current_entry) { |
| 448 frame_tree_node_->render_manager()->OnCrossSiteResponse( | 449 frame_tree_node_->render_manager()->OnCrossSiteResponse( |
| 449 this, global_request_id, cross_site_transferring_request.Pass(), | 450 this, global_request_id, cross_site_transferring_request.Pass(), |
| 450 transfer_url_chain, referrer, page_transition, | 451 transfer_url_chain, referrer, page_transition, |
| 451 should_replace_current_entry); | 452 should_replace_current_entry); |
| 452 } | 453 } |
| 453 | 454 |
| 454 void RenderFrameHostImpl::SwapOut() { | 455 void RenderFrameHostImpl::SwapOut() { |
| 455 if (render_view_host_->IsRenderViewLive()) { | 456 // TODO(creis): Move swapped out state to RFH. Until then, only update it |
| 457 // when swapping out the main frame. |
| 458 if (!GetParent()) { |
| 459 render_view_host_->SetState( |
| 460 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); |
| 461 render_view_host_->unload_event_monitor_timeout_->Start( |
| 462 base::TimeDelta::FromMilliseconds( |
| 463 RenderViewHostImpl::kUnloadTimeoutMS)); |
| 464 } |
| 465 |
| 466 if (render_view_host_->IsRenderViewLive()) |
| 456 Send(new FrameMsg_SwapOut(routing_id_)); | 467 Send(new FrameMsg_SwapOut(routing_id_)); |
| 457 } else { | 468 |
| 458 // Our RenderViewHost doesn't have a live renderer, so just skip the unload | 469 if (!GetParent()) |
| 459 // event. | 470 delegate_->SwappedOut(this); |
| 460 OnSwappedOut(true); | 471 |
| 461 } | 472 // Allow the navigation to proceed. |
| 473 frame_tree_node_->render_manager()->SwappedOut(this); |
| 462 } | 474 } |
| 463 | 475 |
| 464 void RenderFrameHostImpl::OnDidStartLoading() { | 476 void RenderFrameHostImpl::OnDidStartLoading() { |
| 465 delegate_->DidStartLoading(this); | 477 delegate_->DidStartLoading(this); |
| 466 } | 478 } |
| 467 | 479 |
| 468 void RenderFrameHostImpl::OnDidStopLoading() { | 480 void RenderFrameHostImpl::OnDidStopLoading() { |
| 469 delegate_->DidStopLoading(this); | 481 delegate_->DidStopLoading(this); |
| 470 } | 482 } |
| 471 | 483 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 516 // If canceled, notify the delegate to cancel its pending navigation entry. | 528 // If canceled, notify the delegate to cancel its pending navigation entry. |
| 517 if (!proceed) | 529 if (!proceed) |
| 518 render_view_host_->GetDelegate()->DidCancelLoading(); | 530 render_view_host_->GetDelegate()->DidCancelLoading(); |
| 519 } | 531 } |
| 520 | 532 |
| 521 void RenderFrameHostImpl::OnSwapOutACK() { | 533 void RenderFrameHostImpl::OnSwapOutACK() { |
| 522 OnSwappedOut(false); | 534 OnSwappedOut(false); |
| 523 } | 535 } |
| 524 | 536 |
| 525 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { | 537 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { |
| 526 frame_tree_node_->render_manager()->SwappedOutFrame(this); | 538 // For now, we only need to update the RVH state machine for top-level swaps. |
| 539 // Subframe swaps (in --site-per-process) can just continue via RFHM. |
| 540 if (!GetParent()) |
| 541 render_view_host_->OnSwappedOut(timed_out); |
| 542 else |
| 543 frame_tree_node_->render_manager()->SwappedOut(this); |
| 527 } | 544 } |
| 528 | 545 |
| 529 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { | 546 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { |
| 530 // Validate the URLs in |params|. If the renderer can't request the URLs | 547 // Validate the URLs in |params|. If the renderer can't request the URLs |
| 531 // directly, don't show them in the context menu. | 548 // directly, don't show them in the context menu. |
| 532 ContextMenuParams validated_params(params); | 549 ContextMenuParams validated_params(params); |
| 533 RenderProcessHost* process = GetProcess(); | 550 RenderProcessHost* process = GetProcess(); |
| 534 | 551 |
| 535 // We don't validate |unfiltered_link_url| so that this field can be used | 552 // We don't validate |unfiltered_link_url| so that this field can be used |
| 536 // when users want to copy the original link URL. | 553 // when users want to copy the original link URL. |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 params.pending_history_list_offset = -1; | 646 params.pending_history_list_offset = -1; |
| 630 params.current_history_list_offset = -1; | 647 params.current_history_list_offset = -1; |
| 631 params.current_history_list_length = 0; | 648 params.current_history_list_length = 0; |
| 632 params.url = url; | 649 params.url = url; |
| 633 params.transition = PAGE_TRANSITION_LINK; | 650 params.transition = PAGE_TRANSITION_LINK; |
| 634 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 651 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 635 Navigate(params); | 652 Navigate(params); |
| 636 } | 653 } |
| 637 | 654 |
| 638 } // namespace content | 655 } // namespace content |
| OLD | NEW |