OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); | 624 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); |
625 } | 625 } |
626 } | 626 } |
627 | 627 |
628 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { | 628 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { |
629 RenderViewHostImpl* host = GetRenderManager()->current_host(); | 629 RenderViewHostImpl* host = GetRenderManager()->current_host(); |
630 return host ? host->GetProcess() : NULL; | 630 return host ? host->GetProcess() : NULL; |
631 } | 631 } |
632 | 632 |
633 RenderFrameHost* WebContentsImpl::GetMainFrame() { | 633 RenderFrameHost* WebContentsImpl::GetMainFrame() { |
634 return frame_tree_.root()->current_frame_host(); | 634 return frame_tree_.root()->render_frame_host(); |
635 } | 635 } |
636 | 636 |
637 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { | 637 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { |
638 return GetRenderManager()->current_host(); | 638 return GetRenderManager()->current_host(); |
639 } | 639 } |
640 | 640 |
641 void WebContentsImpl::GetRenderViewHostAtPosition( | 641 void WebContentsImpl::GetRenderViewHostAtPosition( |
642 int x, | 642 int x, |
643 int y, | 643 int y, |
644 const base::Callback<void(RenderViewHost*, int, int)>& callback) { | 644 const base::Callback<void(RenderViewHost*, int, int)>& callback) { |
(...skipping 2380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3025 } | 3025 } |
3026 } | 3026 } |
3027 DidNavigateAnyFramePostCommit(rvh, details, params); | 3027 DidNavigateAnyFramePostCommit(rvh, details, params); |
3028 } | 3028 } |
3029 | 3029 |
3030 void WebContentsImpl::UpdateState(RenderViewHost* rvh, | 3030 void WebContentsImpl::UpdateState(RenderViewHost* rvh, |
3031 int32 page_id, | 3031 int32 page_id, |
3032 const PageState& page_state) { | 3032 const PageState& page_state) { |
3033 // Ensure that this state update comes from either the active RVH or one of | 3033 // Ensure that this state update comes from either the active RVH or one of |
3034 // the swapped out RVHs. We don't expect to hear from any other RVHs. | 3034 // the swapped out RVHs. We don't expect to hear from any other RVHs. |
3035 // TODO(nasko): This should go through RenderFrameHost. | 3035 DCHECK(rvh == GetRenderViewHost() || |
3036 // TODO(creis): We can't update state for cross-process subframes until we | 3036 GetRenderManager()->IsOnSwappedOutList(rvh)); |
3037 // have FrameNavigationEntries. Once we do, this should be a DCHECK. | |
3038 if (rvh != GetRenderViewHost() && | |
3039 !GetRenderManager()->IsRVHOnSwappedOutList( | |
3040 static_cast<RenderViewHostImpl*>(rvh))) | |
3041 return; | |
3042 | 3037 |
3043 // We must be prepared to handle state updates for any page, these occur | 3038 // We must be prepared to handle state updates for any page, these occur |
3044 // when the user is scrolling and entering form data, as well as when we're | 3039 // when the user is scrolling and entering form data, as well as when we're |
3045 // leaving a page, in which case our state may have already been moved to | 3040 // leaving a page, in which case our state may have already been moved to |
3046 // the next page. The navigation controller will look up the appropriate | 3041 // the next page. The navigation controller will look up the appropriate |
3047 // NavigationEntry and update it when it is notified via the delegate. | 3042 // NavigationEntry and update it when it is notified via the delegate. |
3048 | 3043 |
3049 int entry_index = controller_.GetEntryIndexWithPageID( | 3044 int entry_index = controller_.GetEntryIndexWithPageID( |
3050 rvh->GetSiteInstance(), page_id); | 3045 rvh->GetSiteInstance(), page_id); |
3051 if (entry_index < 0) | 3046 if (entry_index < 0) |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3458 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, | 3453 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, |
3459 // as it is deprecated and can be out of sync with GetRenderViewHost(). | 3454 // as it is deprecated and can be out of sync with GetRenderViewHost(). |
3460 GURL url = controller_.GetActiveEntry() | 3455 GURL url = controller_.GetActiveEntry() |
3461 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3456 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
3462 | 3457 |
3463 return GetRenderManager()->current_host()->GetWebkitPrefs(url); | 3458 return GetRenderManager()->current_host()->GetWebkitPrefs(url); |
3464 } | 3459 } |
3465 | 3460 |
3466 int WebContentsImpl::CreateSwappedOutRenderView( | 3461 int WebContentsImpl::CreateSwappedOutRenderView( |
3467 SiteInstance* instance) { | 3462 SiteInstance* instance) { |
3468 return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE, | 3463 return GetRenderManager()->CreateRenderView(instance, MSG_ROUTING_NONE, |
3469 true, true); | 3464 true, true); |
3470 } | 3465 } |
3471 | 3466 |
3472 void WebContentsImpl::OnUserGesture() { | 3467 void WebContentsImpl::OnUserGesture() { |
3473 // Notify observers. | 3468 // Notify observers. |
3474 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3469 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
3475 | 3470 |
3476 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3471 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
3477 if (rdh) // NULL in unittests. | 3472 if (rdh) // NULL in unittests. |
3478 rdh->OnUserGesture(this); | 3473 rdh->OnUserGesture(this); |
3479 } | 3474 } |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3628 instance) | 3623 instance) |
3629 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); | 3624 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); |
3630 | 3625 |
3631 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( | 3626 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( |
3632 instance); | 3627 instance); |
3633 if (rvh) | 3628 if (rvh) |
3634 return rvh->GetRoutingID(); | 3629 return rvh->GetRoutingID(); |
3635 | 3630 |
3636 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3631 // Create a swapped out RenderView in the given SiteInstance if none exists, |
3637 // setting its opener to the given route_id. Return the new view's route_id. | 3632 // setting its opener to the given route_id. Return the new view's route_id. |
3638 return GetRenderManager()->CreateRenderFrame(instance, opener_route_id, | 3633 return GetRenderManager()->CreateRenderView(instance, opener_route_id, |
3639 true, true); | 3634 true, true); |
3640 } | 3635 } |
3641 | 3636 |
3642 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3637 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
3643 return GetController(); | 3638 return GetController(); |
3644 } | 3639 } |
3645 | 3640 |
3646 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3641 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
3647 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3642 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
3648 } | 3643 } |
3649 | 3644 |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3791 } | 3786 } |
3792 | 3787 |
3793 void WebContentsImpl::OnFrameRemoved( | 3788 void WebContentsImpl::OnFrameRemoved( |
3794 RenderViewHostImpl* render_view_host, | 3789 RenderViewHostImpl* render_view_host, |
3795 int64 frame_id) { | 3790 int64 frame_id) { |
3796 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3791 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
3797 FrameDetached(render_view_host, frame_id)); | 3792 FrameDetached(render_view_host, frame_id)); |
3798 } | 3793 } |
3799 | 3794 |
3800 } // namespace content | 3795 } // namespace content |
OLD | NEW |