| 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/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| (...skipping 3854 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3865 RenderProcessGone(GetCrashedStatus())); | 3865 RenderProcessGone(GetCrashedStatus())); |
| 3866 } | 3866 } |
| 3867 | 3867 |
| 3868 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { | 3868 void WebContentsImpl::RenderViewDeleted(RenderViewHost* rvh) { |
| 3869 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); | 3869 FOR_EACH_OBSERVER(WebContentsObserver, observers_, RenderViewDeleted(rvh)); |
| 3870 } | 3870 } |
| 3871 | 3871 |
| 3872 void WebContentsImpl::UpdateState(RenderViewHost* rvh, | 3872 void WebContentsImpl::UpdateState(RenderViewHost* rvh, |
| 3873 int32 page_id, | 3873 int32 page_id, |
| 3874 const PageState& page_state) { | 3874 const PageState& page_state) { |
| 3875 DCHECK(!SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 3876 |
| 3875 // Ensure that this state update comes from a RenderViewHost that belongs to | 3877 // Ensure that this state update comes from a RenderViewHost that belongs to |
| 3876 // this WebContents. | 3878 // this WebContents. |
| 3877 // TODO(nasko): This should go through RenderFrameHost. | 3879 // TODO(nasko): This should go through RenderFrameHost. |
| 3878 if (rvh->GetDelegate()->GetAsWebContents() != this) | 3880 if (rvh->GetDelegate()->GetAsWebContents() != this) |
| 3879 return; | 3881 return; |
| 3880 | 3882 |
| 3881 // We must be prepared to handle state updates for any page. They occur | 3883 // We must be prepared to handle state updates for any page. They occur |
| 3882 // when the user is scrolling and entering form data, as well as when we're | 3884 // when the user is scrolling and entering form data, as well as when we're |
| 3883 // leaving a page, in which case our state may have already been moved to | 3885 // leaving a page, in which case our state may have already been moved to |
| 3884 // the next page. The navigation controller will look up the appropriate | 3886 // the next page. The navigation controller will look up the appropriate |
| 3885 // NavigationEntry and update it when it is notified via the delegate. | 3887 // NavigationEntry and update it when it is notified via the delegate. |
| 3886 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); | 3888 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
| 3887 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( | 3889 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( |
| 3888 rvhi->GetSiteInstance(), page_id); | 3890 rvhi->GetSiteInstance(), page_id); |
| 3889 if (!entry) | 3891 if (!entry) |
| 3890 return; | 3892 return; |
| 3891 | 3893 |
| 3892 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID( | 3894 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID( |
| 3893 static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame())->nav_entry_id()); | 3895 static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame())->nav_entry_id()); |
| 3894 | 3896 |
| 3895 if (SiteIsolationPolicy::UseSubframeNavigationEntries()) { | 3897 DCHECK_EQ(entry, new_entry); |
| 3896 // TODO(creis): We can't properly update state for cross-process subframes | |
| 3897 // until PageState is decomposed into FrameStates. Until then, use the new | |
| 3898 // method. | |
| 3899 entry = new_entry; | |
| 3900 } else { | |
| 3901 DCHECK_EQ(entry, new_entry); | |
| 3902 } | |
| 3903 | 3898 |
| 3904 if (page_state == entry->GetPageState()) | 3899 if (page_state == entry->GetPageState()) |
| 3905 return; // Nothing to update. | 3900 return; // Nothing to update. |
| 3906 entry->SetPageState(page_state); | 3901 entry->SetPageState(page_state); |
| 3907 controller_.NotifyEntryChanged(entry); | 3902 controller_.NotifyEntryChanged(entry); |
| 3908 } | 3903 } |
| 3909 | 3904 |
| 3910 void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host, | 3905 void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host, |
| 3911 const GURL& url) { | 3906 const GURL& url) { |
| 3912 if (fullscreen_widget_routing_id_ != MSG_ROUTING_NONE) { | 3907 if (fullscreen_widget_routing_id_ != MSG_ROUTING_NONE) { |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4054 FOR_EACH_OBSERVER(WebContentsObserver, observers_, | 4049 FOR_EACH_OBSERVER(WebContentsObserver, observers_, |
| 4055 DocumentOnLoadCompletedInMainFrame()); | 4050 DocumentOnLoadCompletedInMainFrame()); |
| 4056 | 4051 |
| 4057 // TODO(avi): Remove. http://crbug.com/170921 | 4052 // TODO(avi): Remove. http://crbug.com/170921 |
| 4058 NotificationService::current()->Notify( | 4053 NotificationService::current()->Notify( |
| 4059 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, | 4054 NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
| 4060 Source<WebContents>(this), | 4055 Source<WebContents>(this), |
| 4061 NotificationService::NoDetails()); | 4056 NotificationService::NoDetails()); |
| 4062 } | 4057 } |
| 4063 | 4058 |
| 4059 void WebContentsImpl::UpdateStateForFrame(RenderFrameHost* render_frame_host, |
| 4060 const PageState& page_state) { |
| 4061 DCHECK(SiteIsolationPolicy::UseSubframeNavigationEntries()); |
| 4062 |
| 4063 // The state update affects the last NavigationEntry associated with the given |
| 4064 // |render_frame_host|. This may not be the last committed NavigationEntry (as |
| 4065 // in the case of an UpdateState from a frame being swapped out). We track |
| 4066 // which entry this is in the RenderFrameHost's nav_entry_id. |
| 4067 RenderFrameHostImpl* rfhi = |
| 4068 static_cast<RenderFrameHostImpl*>(render_frame_host); |
| 4069 NavigationEntryImpl* entry = |
| 4070 controller_.GetEntryWithUniqueID(rfhi->nav_entry_id()); |
| 4071 if (!entry) |
| 4072 return; |
| 4073 |
| 4074 FrameNavigationEntry* frame_entry = |
| 4075 entry->GetFrameEntry(rfhi->frame_tree_node()); |
| 4076 if (!frame_entry) |
| 4077 return; |
| 4078 |
| 4079 CHECK_EQ(frame_entry->site_instance(), rfhi->GetSiteInstance()); |
| 4080 if (page_state == frame_entry->page_state()) |
| 4081 return; // Nothing to update. |
| 4082 |
| 4083 frame_entry->set_page_state(page_state); |
| 4084 controller_.NotifyEntryChanged(entry); |
| 4085 } |
| 4086 |
| 4064 void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host, | 4087 void WebContentsImpl::UpdateTitle(RenderFrameHost* render_frame_host, |
| 4065 int32 page_id, | 4088 int32 page_id, |
| 4066 const base::string16& title, | 4089 const base::string16& title, |
| 4067 base::i18n::TextDirection title_direction) { | 4090 base::i18n::TextDirection title_direction) { |
| 4068 // If we have a title, that's a pretty good indication that we've started | 4091 // If we have a title, that's a pretty good indication that we've started |
| 4069 // getting useful data. | 4092 // getting useful data. |
| 4070 SetNotWaitingForResponse(); | 4093 SetNotWaitingForResponse(); |
| 4071 | 4094 |
| 4072 // Try to find the navigation entry, which might not be the current one. | 4095 // Try to find the navigation entry, which might not be the current one. |
| 4073 // For example, it might be from a recently swapped out RFH. | 4096 // For example, it might be from a recently swapped out RFH. |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4653 return NULL; | 4676 return NULL; |
| 4654 } | 4677 } |
| 4655 | 4678 |
| 4656 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4679 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
| 4657 force_disable_overscroll_content_ = force_disable; | 4680 force_disable_overscroll_content_ = force_disable; |
| 4658 if (view_) | 4681 if (view_) |
| 4659 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4682 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
| 4660 } | 4683 } |
| 4661 | 4684 |
| 4662 } // namespace content | 4685 } // namespace content |
| OLD | NEW |