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/navigation_controller_impl.h" | 5 #include "content/browser/web_contents/navigation_controller_impl.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 // At this point, we know that the navigation has just completed, so | 901 // At this point, we know that the navigation has just completed, so |
902 // record the time. | 902 // record the time. |
903 // | 903 // |
904 // TODO(akalin): Use "sane time" as described in | 904 // TODO(akalin): Use "sane time" as described in |
905 // http://www.chromium.org/developers/design-documents/sane-time . | 905 // http://www.chromium.org/developers/design-documents/sane-time . |
906 base::Time timestamp = | 906 base::Time timestamp = |
907 time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); | 907 time_smoother_.GetSmoothedTime(get_timestamp_callback_.Run()); |
908 DVLOG(1) << "Navigation finished at (smoothed) timestamp " | 908 DVLOG(1) << "Navigation finished at (smoothed) timestamp " |
909 << timestamp.ToInternalValue(); | 909 << timestamp.ToInternalValue(); |
910 | 910 |
911 // We should not have a pending entry anymore. Clear it again in case any | |
912 // error cases above forgot to do so. | |
913 DiscardNonCommittedEntriesInternal(); | |
914 | |
911 // All committed entries should have nonempty content state so WebKit doesn't | 915 // All committed entries should have nonempty content state so WebKit doesn't |
912 // get confused when we go back to them (see the function for details). | 916 // get confused when we go back to them (see the function for details). |
913 DCHECK(!params.content_state.empty()); | 917 DCHECK(!params.content_state.empty()); |
914 NavigationEntryImpl* active_entry = | 918 NavigationEntryImpl* active_entry = |
915 NavigationEntryImpl::FromNavigationEntry(GetActiveEntry()); | 919 NavigationEntryImpl::FromNavigationEntry(GetLastCommittedEntry()); |
Charlie Reis
2013/02/22 21:30:23
This was the source of the bug, since we were usin
| |
916 active_entry->SetTimestamp(timestamp); | 920 active_entry->SetTimestamp(timestamp); |
917 active_entry->SetContentState(params.content_state); | 921 active_entry->SetContentState(params.content_state); |
918 // No longer needed since content state will hold the post data if any. | 922 // No longer needed since content state will hold the post data if any. |
919 active_entry->SetBrowserInitiatedPostData(NULL); | 923 active_entry->SetBrowserInitiatedPostData(NULL); |
920 | 924 |
921 // Once committed, we do not need to track if the entry was initiated by | 925 // Once committed, we do not need to track if the entry was initiated by |
922 // the renderer. | 926 // the renderer. |
923 active_entry->set_is_renderer_initiated(false); | 927 active_entry->set_is_renderer_initiated(false); |
924 | 928 |
925 // The active entry's SiteInstance should match our SiteInstance. | 929 // The active entry's SiteInstance should match our SiteInstance. |
926 DCHECK(active_entry->site_instance() == web_contents_->GetSiteInstance()); | 930 CHECK(active_entry->site_instance() == web_contents_->GetSiteInstance()); |
Charlie Reis
2013/02/22 21:30:23
This DCHECK would have caught the bug, so I'd like
| |
927 | 931 |
928 // Now prep the rest of the details for the notification and broadcast. | 932 // Now prep the rest of the details for the notification and broadcast. |
929 details->entry = active_entry; | 933 details->entry = active_entry; |
930 details->is_main_frame = | 934 details->is_main_frame = |
931 PageTransitionIsMainFrame(params.transition); | 935 PageTransitionIsMainFrame(params.transition); |
932 details->serialized_security_info = params.security_info; | 936 details->serialized_security_info = params.security_info; |
933 details->http_status_code = params.http_status_code; | 937 details->http_status_code = params.http_status_code; |
934 NotifyNavigationEntryCommitted(details); | 938 NotifyNavigationEntryCommitted(details); |
935 | 939 |
936 return true; | 940 return true; |
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1222 // have to query the entry index again. | 1226 // have to query the entry index again. |
1223 last_committed_entry_index_ = | 1227 last_committed_entry_index_ = |
1224 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); | 1228 GetEntryIndexWithPageID(web_contents_->GetSiteInstance(), params.page_id); |
1225 } | 1229 } |
1226 | 1230 |
1227 void NavigationControllerImpl::RendererDidNavigateNewSubframe( | 1231 void NavigationControllerImpl::RendererDidNavigateNewSubframe( |
1228 const ViewHostMsg_FrameNavigate_Params& params) { | 1232 const ViewHostMsg_FrameNavigate_Params& params) { |
1229 if (PageTransitionStripQualifier(params.transition) == | 1233 if (PageTransitionStripQualifier(params.transition) == |
1230 PAGE_TRANSITION_AUTO_SUBFRAME) { | 1234 PAGE_TRANSITION_AUTO_SUBFRAME) { |
1231 // This is not user-initiated. Ignore. | 1235 // This is not user-initiated. Ignore. |
1236 DiscardNonCommittedEntriesInternal(); | |
1232 return; | 1237 return; |
1233 } | 1238 } |
1234 | 1239 |
1235 // Manual subframe navigations just get the current entry cloned so the user | 1240 // Manual subframe navigations just get the current entry cloned so the user |
1236 // can go back or forward to it. The actual subframe information will be | 1241 // can go back or forward to it. The actual subframe information will be |
1237 // stored in the page state for each of those entries. This happens out of | 1242 // stored in the page state for each of those entries. This happens out of |
1238 // band with the actual navigations. | 1243 // band with the actual navigations. |
1239 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " | 1244 DCHECK(GetLastCommittedEntry()) << "ClassifyNavigation should guarantee " |
1240 << "that a last committed entry exists."; | 1245 << "that a last committed entry exists."; |
1241 NavigationEntryImpl* new_entry = new NavigationEntryImpl( | 1246 NavigationEntryImpl* new_entry = new NavigationEntryImpl( |
(...skipping 16 matching lines...) Expand all Loading... | |
1258 params.page_id); | 1263 params.page_id); |
1259 if (entry_index < 0 || | 1264 if (entry_index < 0 || |
1260 entry_index >= static_cast<int>(entries_.size())) { | 1265 entry_index >= static_cast<int>(entries_.size())) { |
1261 NOTREACHED(); | 1266 NOTREACHED(); |
1262 return false; | 1267 return false; |
1263 } | 1268 } |
1264 | 1269 |
1265 // Update the current navigation entry in case we're going back/forward. | 1270 // Update the current navigation entry in case we're going back/forward. |
1266 if (entry_index != last_committed_entry_index_) { | 1271 if (entry_index != last_committed_entry_index_) { |
1267 last_committed_entry_index_ = entry_index; | 1272 last_committed_entry_index_ = entry_index; |
1273 DiscardNonCommittedEntriesInternal(); | |
1268 return true; | 1274 return true; |
1269 } | 1275 } |
1276 | |
1277 // We do not need to discard the pending entry in this case, since we will | |
1278 // not generate commit notifications for this auto-subframe navigation. | |
1270 return false; | 1279 return false; |
1271 } | 1280 } |
1272 | 1281 |
1273 int NavigationControllerImpl::GetIndexOfEntry( | 1282 int NavigationControllerImpl::GetIndexOfEntry( |
1274 const NavigationEntryImpl* entry) const { | 1283 const NavigationEntryImpl* entry) const { |
1275 const NavigationEntries::const_iterator i(std::find( | 1284 const NavigationEntries::const_iterator i(std::find( |
1276 entries_.begin(), | 1285 entries_.begin(), |
1277 entries_.end(), | 1286 entries_.end(), |
1278 entry)); | 1287 entry)); |
1279 return (i == entries_.end()) ? -1 : static_cast<int>(i - entries_.begin()); | 1288 return (i == entries_.end()) ? -1 : static_cast<int>(i - entries_.begin()); |
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1781 const base::Callback<base::Time()>& get_timestamp_callback) { | 1790 const base::Callback<base::Time()>& get_timestamp_callback) { |
1782 get_timestamp_callback_ = get_timestamp_callback; | 1791 get_timestamp_callback_ = get_timestamp_callback; |
1783 } | 1792 } |
1784 | 1793 |
1785 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( | 1794 void NavigationControllerImpl::SetTakeScreenshotCallbackForTest( |
1786 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { | 1795 const base::Callback<void(RenderViewHost*)>& take_screenshot_callback) { |
1787 take_screenshot_callback_ = take_screenshot_callback; | 1796 take_screenshot_callback_ = take_screenshot_callback; |
1788 } | 1797 } |
1789 | 1798 |
1790 } // namespace content | 1799 } // namespace content |
OLD | NEW |