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/crash_logging.h" | |
11 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
12 #include "base/location.h" | 11 #include "base/location.h" |
13 #include "base/logging.h" | 12 #include "base/logging.h" |
14 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
15 #include "base/process/process.h" | 14 #include "base/process/process.h" |
16 #include "base/profiler/scoped_tracker.h" | 15 #include "base/profiler/scoped_tracker.h" |
17 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
18 #include "base/strings/string16.h" | 17 #include "base/strings/string16.h" |
19 #include "base/strings/string_number_conversions.h" | 18 #include "base/strings/string_number_conversions.h" |
20 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
(...skipping 3861 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3882 return; | 3881 return; |
3883 | 3882 |
3884 // 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 |
3885 // 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 |
3886 // 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 |
3887 // the next page. The navigation controller will look up the appropriate | 3886 // the next page. The navigation controller will look up the appropriate |
3888 // NavigationEntry and update it when it is notified via the delegate. | 3887 // NavigationEntry and update it when it is notified via the delegate. |
3889 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); | 3888 RenderViewHostImpl* rvhi = static_cast<RenderViewHostImpl*>(rvh); |
3890 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( | 3889 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( |
3891 rvhi->GetSiteInstance(), page_id); | 3890 rvhi->GetSiteInstance(), page_id); |
3892 | |
3893 int nav_entry_id = | |
3894 static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame())->nav_entry_id(); | |
3895 NavigationEntryImpl* new_entry = | |
3896 controller_.GetEntryWithUniqueID(nav_entry_id); | |
3897 | |
3898 base::debug::SetCrashKeyValue("pageid", base::IntToString(page_id)); | |
3899 base::debug::SetCrashKeyValue("navuniqueid", base::IntToString(nav_entry_id)); | |
3900 base::debug::SetCrashKeyValue( | |
3901 "oldindex", base::IntToString(controller_.GetIndexOfEntry(entry))); | |
3902 base::debug::SetCrashKeyValue( | |
3903 "newindex", base::IntToString(controller_.GetIndexOfEntry(new_entry))); | |
3904 base::debug::SetCrashKeyValue( | |
3905 "lastcommittedindex", | |
3906 base::IntToString(controller_.GetLastCommittedEntryIndex())); | |
3907 base::debug::SetCrashKeyValue("oldurl", | |
3908 entry ? entry->GetURL().spec() : "-nullptr-"); | |
3909 base::debug::SetCrashKeyValue( | |
3910 "newurl", new_entry ? new_entry->GetURL().spec() : "-nullptr-"); | |
3911 base::debug::SetCrashKeyValue( | |
3912 "updatedvalue", page_state.GetTopLevelUrlStringTemporaryForBug369661()); | |
3913 base::debug::SetCrashKeyValue( | |
3914 "oldvalue", entry ? entry->GetURL().spec() : "-nullptr-"); | |
3915 base::debug::SetCrashKeyValue( | |
3916 "newvalue", | |
3917 new_entry ? new_entry->GetURL().spec() : "-nullptr-"); | |
3918 CHECK_EQ(entry, new_entry); | |
3919 | |
3920 if (!entry) | 3891 if (!entry) |
3921 return; | 3892 return; |
3922 | 3893 |
| 3894 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID( |
| 3895 static_cast<RenderFrameHostImpl*>(rvhi->GetMainFrame())->nav_entry_id()); |
| 3896 |
| 3897 DCHECK_EQ(entry, new_entry); |
| 3898 |
3923 if (page_state == entry->GetPageState()) | 3899 if (page_state == entry->GetPageState()) |
3924 return; // Nothing to update. | 3900 return; // Nothing to update. |
3925 entry->SetPageState(page_state); | 3901 entry->SetPageState(page_state); |
3926 controller_.NotifyEntryChanged(entry); | 3902 controller_.NotifyEntryChanged(entry); |
3927 } | 3903 } |
3928 | 3904 |
3929 void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host, | 3905 void WebContentsImpl::UpdateTargetURL(RenderViewHost* render_view_host, |
3930 const GURL& url) { | 3906 const GURL& url) { |
3931 if (fullscreen_widget_routing_id_ != MSG_ROUTING_NONE) { | 3907 if (fullscreen_widget_routing_id_ != MSG_ROUTING_NONE) { |
3932 // If we're fullscreen only update the url if it's from the fullscreen | 3908 // If we're fullscreen only update the url if it's from the fullscreen |
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4114 base::i18n::TextDirection title_direction) { | 4090 base::i18n::TextDirection title_direction) { |
4115 // 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 |
4116 // getting useful data. | 4092 // getting useful data. |
4117 SetNotWaitingForResponse(); | 4093 SetNotWaitingForResponse(); |
4118 | 4094 |
4119 // 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. |
4120 // For example, it might be from a recently swapped out RFH. | 4096 // For example, it might be from a recently swapped out RFH. |
4121 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( | 4097 NavigationEntryImpl* entry = controller_.GetEntryWithPageID( |
4122 render_frame_host->GetSiteInstance(), page_id); | 4098 render_frame_host->GetSiteInstance(), page_id); |
4123 | 4099 |
4124 int nav_entry_id = | 4100 NavigationEntryImpl* new_entry = controller_.GetEntryWithUniqueID( |
4125 static_cast<RenderFrameHostImpl*>(render_frame_host)->nav_entry_id(); | 4101 static_cast<RenderFrameHostImpl*>(render_frame_host)->nav_entry_id()); |
4126 NavigationEntryImpl* new_entry = | 4102 DCHECK_EQ(entry, new_entry); |
4127 controller_.GetEntryWithUniqueID(nav_entry_id); | |
4128 | |
4129 base::debug::SetCrashKeyValue("pageid", base::IntToString(page_id)); | |
4130 base::debug::SetCrashKeyValue("navuniqueid", base::IntToString(nav_entry_id)); | |
4131 base::debug::SetCrashKeyValue( | |
4132 "oldindex", base::IntToString(controller_.GetIndexOfEntry(entry))); | |
4133 base::debug::SetCrashKeyValue( | |
4134 "newindex", base::IntToString(controller_.GetIndexOfEntry(new_entry))); | |
4135 base::debug::SetCrashKeyValue( | |
4136 "lastcommittedindex", | |
4137 base::IntToString(controller_.GetLastCommittedEntryIndex())); | |
4138 base::debug::SetCrashKeyValue("oldurl", | |
4139 entry ? entry->GetURL().spec() : "-nullptr-"); | |
4140 base::debug::SetCrashKeyValue( | |
4141 "newurl", new_entry ? new_entry->GetURL().spec() : "-nullptr-"); | |
4142 base::debug::SetCrashKeyValue("updatedvalue", base::UTF16ToUTF8(title)); | |
4143 base::debug::SetCrashKeyValue( | |
4144 "oldvalue", entry ? base::UTF16ToUTF8(entry->GetTitle()) : "-nullptr-"); | |
4145 base::debug::SetCrashKeyValue( | |
4146 "newvalue", | |
4147 new_entry ? base::UTF16ToUTF8(new_entry->GetTitle()) : "-nullptr-"); | |
4148 CHECK_EQ(entry, new_entry); | |
4149 | 4103 |
4150 // We can handle title updates when we don't have an entry in | 4104 // We can handle title updates when we don't have an entry in |
4151 // UpdateTitleForEntry, but only if the update is from the current RVH. | 4105 // UpdateTitleForEntry, but only if the update is from the current RVH. |
4152 // TODO(avi): Change to make decisions based on the RenderFrameHost. | 4106 // TODO(avi): Change to make decisions based on the RenderFrameHost. |
4153 if (!entry && render_frame_host != GetMainFrame()) | 4107 if (!entry && render_frame_host != GetMainFrame()) |
4154 return; | 4108 return; |
4155 | 4109 |
4156 // TODO(evan): make use of title_direction. | 4110 // TODO(evan): make use of title_direction. |
4157 // http://code.google.com/p/chromium/issues/detail?id=27094 | 4111 // http://code.google.com/p/chromium/issues/detail?id=27094 |
4158 if (!UpdateTitleForEntry(entry, title)) | 4112 if (!UpdateTitleForEntry(entry, title)) |
(...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4722 return NULL; | 4676 return NULL; |
4723 } | 4677 } |
4724 | 4678 |
4725 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { | 4679 void WebContentsImpl::SetForceDisableOverscrollContent(bool force_disable) { |
4726 force_disable_overscroll_content_ = force_disable; | 4680 force_disable_overscroll_content_ = force_disable; |
4727 if (view_) | 4681 if (view_) |
4728 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); | 4682 view_->SetOverscrollControllerEnabled(CanOverscrollContent()); |
4729 } | 4683 } |
4730 | 4684 |
4731 } // namespace content | 4685 } // namespace content |
OLD | NEW |