| 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/input_router.h" | 17 #include "content/browser/renderer_host/input/input_router.h" |
| 18 #include "content/browser/renderer_host/input/timeout_monitor.h" |
| 18 #include "content/browser/renderer_host/render_view_host_impl.h" | 19 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 19 #include "content/common/frame_messages.h" | 20 #include "content/common/frame_messages.h" |
| 20 #include "content/common/input_messages.h" | 21 #include "content/common/input_messages.h" |
| 21 #include "content/common/inter_process_time_ticks_converter.h" | 22 #include "content/common/inter_process_time_ticks_converter.h" |
| 22 #include "content/common/swapped_out_messages.h" | 23 #include "content/common/swapped_out_messages.h" |
| 23 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
| 24 #include "content/public/browser/content_browser_client.h" | 25 #include "content/public/browser/content_browser_client.h" |
| 25 #include "content/public/browser/render_process_host.h" | 26 #include "content/public/browser/render_process_host.h" |
| 26 #include "content/public/browser/render_widget_host_view.h" | 27 #include "content/public/browser/render_widget_host_view.h" |
| 27 #include "content/public/browser/user_metrics.h" | 28 #include "content/public/browser/user_metrics.h" |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 const Referrer& referrer, | 490 const Referrer& referrer, |
| 490 PageTransition page_transition, | 491 PageTransition page_transition, |
| 491 bool should_replace_current_entry) { | 492 bool should_replace_current_entry) { |
| 492 frame_tree_node_->render_manager()->OnCrossSiteResponse( | 493 frame_tree_node_->render_manager()->OnCrossSiteResponse( |
| 493 this, global_request_id, cross_site_transferring_request.Pass(), | 494 this, global_request_id, cross_site_transferring_request.Pass(), |
| 494 transfer_url_chain, referrer, page_transition, | 495 transfer_url_chain, referrer, page_transition, |
| 495 should_replace_current_entry); | 496 should_replace_current_entry); |
| 496 } | 497 } |
| 497 | 498 |
| 498 void RenderFrameHostImpl::SwapOut() { | 499 void RenderFrameHostImpl::SwapOut() { |
| 499 if (render_view_host_->IsRenderViewLive()) { | 500 // TODO(creis): Move swapped out state to RFH. Until then, only update it |
| 501 // when swapping out the main frame. |
| 502 if (!GetParent()) { |
| 503 render_view_host_->SetState( |
| 504 RenderViewHostImpl::STATE_WAITING_FOR_UNLOAD_ACK); |
| 505 render_view_host_->unload_event_monitor_timeout_->Start( |
| 506 base::TimeDelta::FromMilliseconds( |
| 507 RenderViewHostImpl::kUnloadTimeoutMS)); |
| 508 } |
| 509 |
| 510 if (render_view_host_->IsRenderViewLive()) |
| 500 Send(new FrameMsg_SwapOut(routing_id_)); | 511 Send(new FrameMsg_SwapOut(routing_id_)); |
| 501 } else { | 512 |
| 502 // Our RenderViewHost doesn't have a live renderer, so just skip the unload | 513 if (!GetParent()) |
| 503 // event. | 514 delegate_->SwappedOut(this); |
| 504 OnSwappedOut(true); | 515 |
| 505 } | 516 // Allow the navigation to proceed. |
| 517 frame_tree_node_->render_manager()->SwappedOut(this); |
| 506 } | 518 } |
| 507 | 519 |
| 508 void RenderFrameHostImpl::OnDidStartLoading() { | 520 void RenderFrameHostImpl::OnDidStartLoading() { |
| 509 delegate_->DidStartLoading(this); | 521 delegate_->DidStartLoading(this); |
| 510 } | 522 } |
| 511 | 523 |
| 512 void RenderFrameHostImpl::OnDidStopLoading() { | 524 void RenderFrameHostImpl::OnDidStopLoading() { |
| 513 delegate_->DidStopLoading(this); | 525 delegate_->DidStopLoading(this); |
| 514 } | 526 } |
| 515 | 527 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 // If canceled, notify the delegate to cancel its pending navigation entry. | 572 // If canceled, notify the delegate to cancel its pending navigation entry. |
| 561 if (!proceed) | 573 if (!proceed) |
| 562 render_view_host_->GetDelegate()->DidCancelLoading(); | 574 render_view_host_->GetDelegate()->DidCancelLoading(); |
| 563 } | 575 } |
| 564 | 576 |
| 565 void RenderFrameHostImpl::OnSwapOutACK() { | 577 void RenderFrameHostImpl::OnSwapOutACK() { |
| 566 OnSwappedOut(false); | 578 OnSwappedOut(false); |
| 567 } | 579 } |
| 568 | 580 |
| 569 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { | 581 void RenderFrameHostImpl::OnSwappedOut(bool timed_out) { |
| 570 frame_tree_node_->render_manager()->SwappedOutFrame(this); | 582 // For now, we only need to update the RVH state machine for top-level swaps. |
| 583 // Subframe swaps (in --site-per-process) can just continue via RFHM. |
| 584 if (!GetParent()) |
| 585 render_view_host_->OnSwappedOut(timed_out); |
| 586 else |
| 587 frame_tree_node_->render_manager()->SwappedOut(this); |
| 571 } | 588 } |
| 572 | 589 |
| 573 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { | 590 void RenderFrameHostImpl::OnContextMenu(const ContextMenuParams& params) { |
| 574 // Validate the URLs in |params|. If the renderer can't request the URLs | 591 // Validate the URLs in |params|. If the renderer can't request the URLs |
| 575 // directly, don't show them in the context menu. | 592 // directly, don't show them in the context menu. |
| 576 ContextMenuParams validated_params(params); | 593 ContextMenuParams validated_params(params); |
| 577 RenderProcessHost* process = GetProcess(); | 594 RenderProcessHost* process = GetProcess(); |
| 578 | 595 |
| 579 // We don't validate |unfiltered_link_url| so that this field can be used | 596 // We don't validate |unfiltered_link_url| so that this field can be used |
| 580 // when users want to copy the original link URL. | 597 // when users want to copy the original link URL. |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; | 695 params.navigation_type = FrameMsg_Navigate_Type::NORMAL; |
| 679 Navigate(params); | 696 Navigate(params); |
| 680 } | 697 } |
| 681 | 698 |
| 682 void RenderFrameHostImpl::SelectRange(const gfx::Point& start, | 699 void RenderFrameHostImpl::SelectRange(const gfx::Point& start, |
| 683 const gfx::Point& end) { | 700 const gfx::Point& end) { |
| 684 Send(new InputMsg_SelectRange(routing_id_, start, end)); | 701 Send(new InputMsg_SelectRange(routing_id_, start, end)); |
| 685 } | 702 } |
| 686 | 703 |
| 687 } // namespace content | 704 } // namespace content |
| OLD | NEW |