Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: content/browser/frame_host/navigation_controller_impl.cc

Issue 317703004: Simplify AreURLsInPageNavigation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/frame_host/navigation_controller_impl.h" 5 #include "content/browser/frame_host/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/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 for (size_t i = 0; i < entries->size(); ++i) { 97 for (size_t i = 0; i < entries->size(); ++i) {
98 // Use a transition type of reload so that we don't incorrectly increase 98 // Use a transition type of reload so that we don't incorrectly increase
99 // the typed count. 99 // the typed count.
100 (*entries)[i]->SetTransitionType(PAGE_TRANSITION_RELOAD); 100 (*entries)[i]->SetTransitionType(PAGE_TRANSITION_RELOAD);
101 (*entries)[i]->set_restore_type(ControllerRestoreTypeToEntryType(type)); 101 (*entries)[i]->set_restore_type(ControllerRestoreTypeToEntryType(type));
102 // NOTE(darin): This code is only needed for backwards compat. 102 // NOTE(darin): This code is only needed for backwards compat.
103 SetPageStateIfEmpty((*entries)[i].get()); 103 SetPageStateIfEmpty((*entries)[i].get());
104 } 104 }
105 } 105 }
106 106
107 // See NavigationController::IsURLInPageNavigation for how this works and why. 107 // See NavigationController::IsURLInPageNavigation for how this works and why.
nasko 2014/06/06 17:21:56 nit: I'll put the reasoning from the CL descriptio
108 bool AreURLsInPageNavigation(const GURL& existing_url, 108 bool AreURLsInPageNavigation(const GURL& existing_url,
109 const GURL& new_url, 109 const GURL& new_url,
110 bool renderer_says_in_page, 110 bool renderer_says_in_page) {
111 NavigationType navigation_type) { 111 return existing_url.GetOrigin() == new_url.GetOrigin() &&
112 if (existing_url.GetOrigin() == new_url.GetOrigin()) 112 renderer_says_in_page;
113 return renderer_says_in_page;
114
115 if (!new_url.has_ref()) {
116 // When going back from the ref URL to the non ref one the navigation type
117 // is IN_PAGE.
118 return navigation_type == NAVIGATION_TYPE_IN_PAGE;
119 }
120
121 url::Replacements<char> replacements;
122 replacements.ClearRef();
123 return existing_url.ReplaceComponents(replacements) ==
124 new_url.ReplaceComponents(replacements);
125 } 113 }
126 114
127 // Determines whether or not we should be carrying over a user agent override 115 // Determines whether or not we should be carrying over a user agent override
128 // between two NavigationEntries. 116 // between two NavigationEntries.
129 bool ShouldKeepOverride(const NavigationEntry* last_entry) { 117 bool ShouldKeepOverride(const NavigationEntry* last_entry) {
130 return last_entry && last_entry->GetIsOverridingUserAgent(); 118 return last_entry && last_entry->GetIsOverridingUserAgent();
131 } 119 }
132 120
133 } // namespace 121 } // namespace
134 122
(...skipping 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 // the pending entry and go back to where we were (the "existing entry"). 967 // the pending entry and go back to where we were (the "existing entry").
980 return NAVIGATION_TYPE_SAME_PAGE; 968 return NAVIGATION_TYPE_SAME_PAGE;
981 } 969 }
982 970
983 // Any toplevel navigations with the same base (minus the reference fragment) 971 // Any toplevel navigations with the same base (minus the reference fragment)
984 // are in-page navigations. We weeded out subframe navigations above. Most of 972 // are in-page navigations. We weeded out subframe navigations above. Most of
985 // the time this doesn't matter since WebKit doesn't tell us about subframe 973 // the time this doesn't matter since WebKit doesn't tell us about subframe
986 // navigations that don't actually navigate, but it can happen when there is 974 // navigations that don't actually navigate, but it can happen when there is
987 // an encoding override (it always sends a navigation request). 975 // an encoding override (it always sends a navigation request).
988 if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url, 976 if (AreURLsInPageNavigation(existing_entry->GetURL(), params.url,
989 params.was_within_same_page, 977 params.was_within_same_page)) {
990 NAVIGATION_TYPE_UNKNOWN)) {
991 return NAVIGATION_TYPE_IN_PAGE; 978 return NAVIGATION_TYPE_IN_PAGE;
992 } 979 }
993 980
994 // Since we weeded out "new" navigations above, we know this is an existing 981 // Since we weeded out "new" navigations above, we know this is an existing
995 // (back/forward) navigation. 982 // (back/forward) navigation.
996 return NAVIGATION_TYPE_EXISTING_PAGE; 983 return NAVIGATION_TYPE_EXISTING_PAGE;
997 } 984 }
998 985
999 void NavigationControllerImpl::RendererDidNavigateToNewPage( 986 void NavigationControllerImpl::RendererDidNavigateToNewPage(
1000 RenderFrameHost* rfh, 987 RenderFrameHost* rfh,
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1249 entry)); 1236 entry));
1250 return (i == entries_.end()) ? -1 : static_cast<int>(i - entries_.begin()); 1237 return (i == entries_.end()) ? -1 : static_cast<int>(i - entries_.begin());
1251 } 1238 }
1252 1239
1253 bool NavigationControllerImpl::IsURLInPageNavigation( 1240 bool NavigationControllerImpl::IsURLInPageNavigation(
1254 const GURL& url, 1241 const GURL& url,
1255 bool renderer_says_in_page, 1242 bool renderer_says_in_page,
1256 NavigationType navigation_type) const { 1243 NavigationType navigation_type) const {
1257 NavigationEntry* last_committed = GetLastCommittedEntry(); 1244 NavigationEntry* last_committed = GetLastCommittedEntry();
1258 return last_committed && AreURLsInPageNavigation( 1245 return last_committed && AreURLsInPageNavigation(
1259 last_committed->GetURL(), url, renderer_says_in_page, navigation_type); 1246 last_committed->GetURL(), url, renderer_says_in_page);
1260 } 1247 }
1261 1248
1262 void NavigationControllerImpl::CopyStateFrom( 1249 void NavigationControllerImpl::CopyStateFrom(
1263 const NavigationController& temp) { 1250 const NavigationController& temp) {
1264 const NavigationControllerImpl& source = 1251 const NavigationControllerImpl& source =
1265 static_cast<const NavigationControllerImpl&>(temp); 1252 static_cast<const NavigationControllerImpl&>(temp);
1266 // Verify that we look new. 1253 // Verify that we look new.
1267 DCHECK(GetEntryCount() == 0 && !GetPendingEntry()); 1254 DCHECK(GetEntryCount() == 0 && !GetPendingEntry());
1268 1255
1269 if (source.GetEntryCount() == 0) 1256 if (source.GetEntryCount() == 0)
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1770 } 1757 }
1771 } 1758 }
1772 } 1759 }
1773 1760
1774 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1761 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1775 const base::Callback<base::Time()>& get_timestamp_callback) { 1762 const base::Callback<base::Time()>& get_timestamp_callback) {
1776 get_timestamp_callback_ = get_timestamp_callback; 1763 get_timestamp_callback_ = get_timestamp_callback;
1777 } 1764 }
1778 1765
1779 } // namespace content 1766 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698