| 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 606 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); | 617 view_->SetOverscrollControllerEnabled(delegate->CanOverscrollContent()); |
| 618 } | 618 } |
| 619 } | 619 } |
| 620 | 620 |
| 621 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { | 621 RenderProcessHost* WebContentsImpl::GetRenderProcessHost() const { |
| 622 RenderViewHostImpl* host = GetRenderManager()->current_host(); | 622 RenderViewHostImpl* host = GetRenderManager()->current_host(); |
| 623 return host ? host->GetProcess() : NULL; | 623 return host ? host->GetProcess() : NULL; |
| 624 } | 624 } |
| 625 | 625 |
| 626 RenderFrameHost* WebContentsImpl::GetMainFrame() { | 626 RenderFrameHost* WebContentsImpl::GetMainFrame() { |
| 627 return frame_tree_.root()->render_frame_host(); | 627 return frame_tree_.root()->current_render_frame_host(); |
| 628 } | 628 } |
| 629 | 629 |
| 630 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { | 630 RenderViewHost* WebContentsImpl::GetRenderViewHost() const { |
| 631 return GetRenderManager()->current_host(); | 631 return GetRenderManager()->current_host(); |
| 632 } | 632 } |
| 633 | 633 |
| 634 void WebContentsImpl::GetRenderViewHostAtPosition( | 634 void WebContentsImpl::GetRenderViewHostAtPosition( |
| 635 int x, | 635 int x, |
| 636 int y, | 636 int y, |
| 637 const base::Callback<void(RenderViewHost*, int, int)>& callback) { | 637 const base::Callback<void(RenderViewHost*, int, int)>& callback) { |
| (...skipping 2360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2998 } | 2998 } |
| 2999 } | 2999 } |
| 3000 DidNavigateAnyFramePostCommit(rvh, details, params); | 3000 DidNavigateAnyFramePostCommit(rvh, details, params); |
| 3001 } | 3001 } |
| 3002 | 3002 |
| 3003 void WebContentsImpl::UpdateState(RenderViewHost* rvh, | 3003 void WebContentsImpl::UpdateState(RenderViewHost* rvh, |
| 3004 int32 page_id, | 3004 int32 page_id, |
| 3005 const PageState& page_state) { | 3005 const PageState& page_state) { |
| 3006 // Ensure that this state update comes from either the active RVH or one of | 3006 // Ensure that this state update comes from either the active RVH or one of |
| 3007 // the swapped out RVHs. We don't expect to hear from any other RVHs. | 3007 // the swapped out RVHs. We don't expect to hear from any other RVHs. |
| 3008 DCHECK(rvh == GetRenderViewHost() || | 3008 // TODO(nasko): This should go through RenderFrameHost. |
| 3009 GetRenderManager()->IsOnSwappedOutList(rvh)); | 3009 // TODO(creis): We can't update state for cross-process subframes until we |
| 3010 // have FrameNavigationEntries. Once we do, this should be a DCHECK. |
| 3011 if (rvh != GetRenderViewHost() && |
| 3012 !GetRenderManager()->IsRVHOnSwappedOutList( |
| 3013 static_cast<RenderViewHostImpl*>(rvh))) |
| 3014 return; |
| 3010 | 3015 |
| 3011 // We must be prepared to handle state updates for any page, these occur | 3016 // We must be prepared to handle state updates for any page, these occur |
| 3012 // when the user is scrolling and entering form data, as well as when we're | 3017 // when the user is scrolling and entering form data, as well as when we're |
| 3013 // leaving a page, in which case our state may have already been moved to | 3018 // leaving a page, in which case our state may have already been moved to |
| 3014 // the next page. The navigation controller will look up the appropriate | 3019 // the next page. The navigation controller will look up the appropriate |
| 3015 // NavigationEntry and update it when it is notified via the delegate. | 3020 // NavigationEntry and update it when it is notified via the delegate. |
| 3016 | 3021 |
| 3017 int entry_index = controller_.GetEntryIndexWithPageID( | 3022 int entry_index = controller_.GetEntryIndexWithPageID( |
| 3018 rvh->GetSiteInstance(), page_id); | 3023 rvh->GetSiteInstance(), page_id); |
| 3019 if (entry_index < 0) | 3024 if (entry_index < 0) |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3426 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, | 3431 // TODO(nasko): Investigate how to remove the GetActiveEntry usage here, |
| 3427 // as it is deprecated and can be out of sync with GetRenderViewHost(). | 3432 // as it is deprecated and can be out of sync with GetRenderViewHost(). |
| 3428 GURL url = controller_.GetActiveEntry() | 3433 GURL url = controller_.GetActiveEntry() |
| 3429 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3434 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
| 3430 | 3435 |
| 3431 return GetRenderManager()->current_host()->GetWebkitPrefs(url); | 3436 return GetRenderManager()->current_host()->GetWebkitPrefs(url); |
| 3432 } | 3437 } |
| 3433 | 3438 |
| 3434 int WebContentsImpl::CreateSwappedOutRenderView( | 3439 int WebContentsImpl::CreateSwappedOutRenderView( |
| 3435 SiteInstance* instance) { | 3440 SiteInstance* instance) { |
| 3436 return GetRenderManager()->CreateRenderView(instance, MSG_ROUTING_NONE, | 3441 return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE, |
| 3437 true, true); | 3442 true, true); |
| 3438 } | 3443 } |
| 3439 | 3444 |
| 3440 void WebContentsImpl::OnUserGesture() { | 3445 void WebContentsImpl::OnUserGesture() { |
| 3441 // Notify observers. | 3446 // Notify observers. |
| 3442 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3447 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
| 3443 | 3448 |
| 3444 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3449 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 3445 if (rdh) // NULL in unittests. | 3450 if (rdh) // NULL in unittests. |
| 3446 rdh->OnUserGesture(this); | 3451 rdh->OnUserGesture(this); |
| 3447 } | 3452 } |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3596 instance) | 3601 instance) |
| 3597 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); | 3602 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); |
| 3598 | 3603 |
| 3599 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( | 3604 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( |
| 3600 instance); | 3605 instance); |
| 3601 if (rvh) | 3606 if (rvh) |
| 3602 return rvh->GetRoutingID(); | 3607 return rvh->GetRoutingID(); |
| 3603 | 3608 |
| 3604 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3609 // Create a swapped out RenderView in the given SiteInstance if none exists, |
| 3605 // setting its opener to the given route_id. Return the new view's route_id. | 3610 // setting its opener to the given route_id. Return the new view's route_id. |
| 3606 return GetRenderManager()->CreateRenderView(instance, opener_route_id, | 3611 return GetRenderManager()->CreateRenderFrame(instance, opener_route_id, |
| 3607 true, true); | 3612 true, true); |
| 3608 } | 3613 } |
| 3609 | 3614 |
| 3610 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3615 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
| 3611 return GetController(); | 3616 return GetController(); |
| 3612 } | 3617 } |
| 3613 | 3618 |
| 3614 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3619 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
| 3615 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3620 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
| 3616 } | 3621 } |
| 3617 | 3622 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3759 } | 3764 } |
| 3760 | 3765 |
| 3761 void WebContentsImpl::OnFrameRemoved( | 3766 void WebContentsImpl::OnFrameRemoved( |
| 3762 RenderViewHostImpl* render_view_host, | 3767 RenderViewHostImpl* render_view_host, |
| 3763 int64 frame_id) { | 3768 int64 frame_id) { |
| 3764 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 3769 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 3765 FrameDetached(render_view_host, frame_id)); | 3770 FrameDetached(render_view_host, frame_id)); |
| 3766 } | 3771 } |
| 3767 | 3772 |
| 3768 } // namespace content | 3773 } // namespace content |
| OLD | NEW |