| 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 3411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3422 } | 3422 } |
| 3423 | 3423 |
| 3424 void WebContentsImpl::UpdateState(RenderViewHost* rvh, | 3424 void WebContentsImpl::UpdateState(RenderViewHost* rvh, |
| 3425 int32 page_id, | 3425 int32 page_id, |
| 3426 const PageState& page_state) { | 3426 const PageState& page_state) { |
| 3427 // Ensure that this state update comes from either the active RVH or one of | 3427 // Ensure that this state update comes from either the active RVH or one of |
| 3428 // the swapped out RVHs. We don't expect to hear from any other RVHs. | 3428 // the swapped out RVHs. We don't expect to hear from any other RVHs. |
| 3429 // TODO(nasko): This should go through RenderFrameHost. | 3429 // TODO(nasko): This should go through RenderFrameHost. |
| 3430 // TODO(creis): We can't update state for cross-process subframes until we | 3430 // TODO(creis): We can't update state for cross-process subframes until we |
| 3431 // have FrameNavigationEntries. Once we do, this should be a DCHECK. | 3431 // have FrameNavigationEntries. Once we do, this should be a DCHECK. |
| 3432 LOG(ERROR) << "WCI::UpdateState: " |
| 3433 << rvh->GetProcess()->GetID() |
| 3434 << ":" << rvh->GetRoutingID() |
| 3435 << ":" << rvh->GetSiteInstance()->GetSiteURL() |
| 3436 << ":" << GetRenderManager(); |
| 3437 |
| 3432 if (rvh != GetRenderViewHost() && | 3438 if (rvh != GetRenderViewHost() && |
| 3433 !GetRenderManager()->IsRVHOnSwappedOutList( | 3439 !GetRenderManager()->IsRVHOnSwappedOutList( |
| 3434 static_cast<RenderViewHostImpl*>(rvh))) | 3440 static_cast<RenderViewHostImpl*>(rvh))) { |
| 3441 LOG(ERROR) << "WCI::UpdateState: rvh is not a match."; |
| 3435 return; | 3442 return; |
| 3443 } |
| 3436 | 3444 |
| 3437 // We must be prepared to handle state updates for any page, these occur | 3445 // We must be prepared to handle state updates for any page, these occur |
| 3438 // when the user is scrolling and entering form data, as well as when we're | 3446 // when the user is scrolling and entering form data, as well as when we're |
| 3439 // leaving a page, in which case our state may have already been moved to | 3447 // leaving a page, in which case our state may have already been moved to |
| 3440 // the next page. The navigation controller will look up the appropriate | 3448 // the next page. The navigation controller will look up the appropriate |
| 3441 // NavigationEntry and update it when it is notified via the delegate. | 3449 // NavigationEntry and update it when it is notified via the delegate. |
| 3442 | 3450 |
| 3443 int entry_index = controller_.GetEntryIndexWithPageID( | 3451 int entry_index = controller_.GetEntryIndexWithPageID( |
| 3444 rvh->GetSiteInstance(), page_id); | 3452 rvh->GetSiteInstance(), page_id); |
| 3445 if (entry_index < 0) | 3453 if (entry_index < 0) |
| (...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3710 // as it is deprecated and can be out of sync with GetRenderViewHost(). | 3718 // as it is deprecated and can be out of sync with GetRenderViewHost(). |
| 3711 GURL url = controller_.GetActiveEntry() | 3719 GURL url = controller_.GetActiveEntry() |
| 3712 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); | 3720 ? controller_.GetActiveEntry()->GetURL() : GURL::EmptyGURL(); |
| 3713 | 3721 |
| 3714 return GetRenderManager()->current_host()->GetWebkitPrefs(url); | 3722 return GetRenderManager()->current_host()->GetWebkitPrefs(url); |
| 3715 } | 3723 } |
| 3716 | 3724 |
| 3717 int WebContentsImpl::CreateSwappedOutRenderView( | 3725 int WebContentsImpl::CreateSwappedOutRenderView( |
| 3718 SiteInstance* instance) { | 3726 SiteInstance* instance) { |
| 3719 return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE, | 3727 return GetRenderManager()->CreateRenderFrame(instance, MSG_ROUTING_NONE, |
| 3720 true, true); | 3728 true, true, true); |
| 3721 } | 3729 } |
| 3722 | 3730 |
| 3723 void WebContentsImpl::OnUserGesture() { | 3731 void WebContentsImpl::OnUserGesture() { |
| 3724 // Notify observers. | 3732 // Notify observers. |
| 3725 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); | 3733 FOR_EACH_OBSERVER(WebContentsObserver, observers_, DidGetUserGesture()); |
| 3726 | 3734 |
| 3727 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); | 3735 ResourceDispatcherHostImpl* rdh = ResourceDispatcherHostImpl::Get(); |
| 3728 if (rdh) // NULL in unittests. | 3736 if (rdh) // NULL in unittests. |
| 3729 rdh->OnUserGesture(this); | 3737 rdh->OnUserGesture(this); |
| 3730 } | 3738 } |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3875 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); | 3883 return GetRenderManager()->pending_render_view_host()->GetRoutingID(); |
| 3876 | 3884 |
| 3877 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( | 3885 RenderViewHostImpl* rvh = GetRenderManager()->GetSwappedOutRenderViewHost( |
| 3878 instance); | 3886 instance); |
| 3879 if (rvh) | 3887 if (rvh) |
| 3880 return rvh->GetRoutingID(); | 3888 return rvh->GetRoutingID(); |
| 3881 | 3889 |
| 3882 // Create a swapped out RenderView in the given SiteInstance if none exists, | 3890 // Create a swapped out RenderView in the given SiteInstance if none exists, |
| 3883 // setting its opener to the given route_id. Return the new view's route_id. | 3891 // setting its opener to the given route_id. Return the new view's route_id. |
| 3884 return GetRenderManager()->CreateRenderFrame(instance, opener_route_id, | 3892 return GetRenderManager()->CreateRenderFrame(instance, opener_route_id, |
| 3885 true, true); | 3893 true, true, true); |
| 3886 } | 3894 } |
| 3887 | 3895 |
| 3888 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { | 3896 NavigationControllerImpl& WebContentsImpl::GetControllerForRenderManager() { |
| 3889 return GetController(); | 3897 return GetController(); |
| 3890 } | 3898 } |
| 3891 | 3899 |
| 3892 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { | 3900 WebUIImpl* WebContentsImpl::CreateWebUIForRenderManager(const GURL& url) { |
| 3893 return static_cast<WebUIImpl*>(CreateWebUI(url)); | 3901 return static_cast<WebUIImpl*>(CreateWebUI(url)); |
| 3894 } | 3902 } |
| 3895 | 3903 |
| 3896 NavigationEntry* | 3904 NavigationEntry* |
| 3897 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { | 3905 WebContentsImpl::GetLastCommittedNavigationEntryForRenderManager() { |
| 3898 return controller_.GetLastCommittedEntry(); | 3906 return controller_.GetLastCommittedEntry(); |
| 3899 } | 3907 } |
| 3900 | 3908 |
| 3901 bool WebContentsImpl::CreateRenderViewForRenderManager( | 3909 bool WebContentsImpl::CreateRenderViewForRenderManager( |
| 3902 RenderViewHost* render_view_host, | 3910 RenderViewHost* render_view_host, |
| 3903 int opener_route_id, | 3911 int opener_route_id, |
| 3904 int proxy_routing_id, | 3912 int proxy_routing_id, |
| 3905 bool for_main_frame) { | 3913 bool for_main_frame) { |
| 3906 TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderViewForRenderManager"); | 3914 TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderViewForRenderManager"); |
| 3915 LOG(ERROR) << "WC::CreateRenderViewForRenderManager: " |
| 3916 << "for_main_frame:" << for_main_frame; |
| 3907 // Can be NULL during tests. | 3917 // Can be NULL during tests. |
| 3908 RenderWidgetHostViewBase* rwh_view; | 3918 RenderWidgetHostViewBase* rwh_view; |
| 3909 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary | 3919 // TODO(kenrb): RenderWidgetHostViewChildFrame special casing is temporary |
| 3910 // until RenderWidgetHost is attached to RenderFrameHost. We need to special | 3920 // until RenderWidgetHost is attached to RenderFrameHost. We need to special |
| 3911 // case this because RWH is still a base class of RenderViewHost, and child | 3921 // case this because RWH is still a base class of RenderViewHost, and child |
| 3912 // frame RWHVs are unique in that they do not have their own WebContents. | 3922 // frame RWHVs are unique in that they do not have their own WebContents. |
| 3913 if (!for_main_frame) { | 3923 if (!for_main_frame) { |
| 3914 RenderWidgetHostViewChildFrame* rwh_view_child = | 3924 RenderWidgetHostViewChildFrame* rwh_view_child = |
| 3915 new RenderWidgetHostViewChildFrame(render_view_host); | 3925 new RenderWidgetHostViewChildFrame(render_view_host); |
| 3916 rwh_view = rwh_view_child; | 3926 rwh_view = rwh_view_child; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 3941 // linux. See crbug.com/83941. | 3951 // linux. See crbug.com/83941. |
| 3942 if (rwh_view) { | 3952 if (rwh_view) { |
| 3943 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) | 3953 if (RenderWidgetHost* render_widget_host = rwh_view->GetRenderWidgetHost()) |
| 3944 render_widget_host->WasResized(); | 3954 render_widget_host->WasResized(); |
| 3945 } | 3955 } |
| 3946 #endif | 3956 #endif |
| 3947 | 3957 |
| 3948 return true; | 3958 return true; |
| 3949 } | 3959 } |
| 3950 | 3960 |
| 3961 bool WebContentsImpl::CreateRenderFrameForRenderManager( |
| 3962 RenderFrameHost* render_frame_host, |
| 3963 int parent_routing_id) { |
| 3964 TRACE_EVENT0("browser", "WebContentsImpl::CreateRenderFrameForRenderManager"); |
| 3965 |
| 3966 RenderFrameHostImpl* rfh = |
| 3967 static_cast<RenderFrameHostImpl*>(render_frame_host); |
| 3968 if (!rfh->CreateRenderFrame(parent_routing_id)) |
| 3969 return false; |
| 3970 |
| 3971 // TODO(nasko): When RenderWidgetHost is owned by RenderFrameHost, the passed |
| 3972 // RenderFrameHost will have to be associated with the appropriate |
| 3973 // RenderWidgetHostView or a new one should be created here. |
| 3974 |
| 3975 return true; |
| 3976 } |
| 3977 |
| 3978 |
| 3951 #if defined(OS_ANDROID) | 3979 #if defined(OS_ANDROID) |
| 3952 | 3980 |
| 3953 base::android::ScopedJavaLocalRef<jobject> | 3981 base::android::ScopedJavaLocalRef<jobject> |
| 3954 WebContentsImpl::GetJavaWebContents() { | 3982 WebContentsImpl::GetJavaWebContents() { |
| 3955 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 3983 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 3956 | 3984 |
| 3957 WebContentsAndroid* web_contents_android = | 3985 WebContentsAndroid* web_contents_android = |
| 3958 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); | 3986 static_cast<WebContentsAndroid*>(GetUserData(kWebContentsAndroidKey)); |
| 3959 if (!web_contents_android) { | 3987 if (!web_contents_android) { |
| 3960 web_contents_android = new WebContentsAndroid(this); | 3988 web_contents_android = new WebContentsAndroid(this); |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4100 if (new_size != old_size) | 4128 if (new_size != old_size) |
| 4101 delegate_->UpdatePreferredSize(this, new_size); | 4129 delegate_->UpdatePreferredSize(this, new_size); |
| 4102 } | 4130 } |
| 4103 | 4131 |
| 4104 void WebContentsImpl::ResumeResponseDeferredAtStart() { | 4132 void WebContentsImpl::ResumeResponseDeferredAtStart() { |
| 4105 FrameTreeNode* node = frame_tree_.root(); | 4133 FrameTreeNode* node = frame_tree_.root(); |
| 4106 node->render_manager()->ResumeResponseDeferredAtStart(); | 4134 node->render_manager()->ResumeResponseDeferredAtStart(); |
| 4107 } | 4135 } |
| 4108 | 4136 |
| 4109 } // namespace content | 4137 } // namespace content |
| OLD | NEW |