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

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

Issue 917043004: Mark error pages as such on Ctrl-Shift-T reload. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 10 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
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/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1043 NavigationEntryImpl* new_entry; 1043 NavigationEntryImpl* new_entry;
1044 bool update_virtual_url; 1044 bool update_virtual_url;
1045 // Only make a copy of the pending entry if it is appropriate for the new page 1045 // Only make a copy of the pending entry if it is appropriate for the new page
1046 // that was just loaded. We verify this at a coarse grain by checking that 1046 // that was just loaded. We verify this at a coarse grain by checking that
1047 // the SiteInstance hasn't been assigned to something else. 1047 // the SiteInstance hasn't been assigned to something else.
1048 if (pending_entry_ && 1048 if (pending_entry_ &&
1049 (!pending_entry_->site_instance() || 1049 (!pending_entry_->site_instance() ||
1050 pending_entry_->site_instance() == rfh->GetSiteInstance())) { 1050 pending_entry_->site_instance() == rfh->GetSiteInstance())) {
1051 new_entry = new NavigationEntryImpl(*pending_entry_); 1051 new_entry = new NavigationEntryImpl(*pending_entry_);
1052 1052
1053 // Don't use the page type from the pending entry. Some interstitial page
1054 // may have set the type to interstitial. Once we commit, however, the page
1055 // type must always be normal.
1056 new_entry->set_page_type(PAGE_TYPE_NORMAL);
1057 update_virtual_url = new_entry->update_virtual_url_with_url(); 1053 update_virtual_url = new_entry->update_virtual_url_with_url();
1058 } else { 1054 } else {
1059 new_entry = new NavigationEntryImpl; 1055 new_entry = new NavigationEntryImpl;
1060 1056
1061 // Find out whether the new entry needs to update its virtual URL on URL 1057 // Find out whether the new entry needs to update its virtual URL on URL
1062 // change and set up the entry accordingly. This is needed to correctly 1058 // change and set up the entry accordingly. This is needed to correctly
1063 // update the virtual URL when replaceState is called after a pushState. 1059 // update the virtual URL when replaceState is called after a pushState.
1064 GURL url = params.url; 1060 GURL url = params.url;
1065 bool needs_update = false; 1061 bool needs_update = false;
1066 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary( 1062 BrowserURLHandlerImpl::GetInstance()->RewriteURLIfNecessary(
1067 &url, browser_context_, &needs_update); 1063 &url, browser_context_, &needs_update);
1068 new_entry->set_update_virtual_url_with_url(needs_update); 1064 new_entry->set_update_virtual_url_with_url(needs_update);
1069 1065
1070 // When navigating to a new page, give the browser URL handler a chance to 1066 // When navigating to a new page, give the browser URL handler a chance to
1071 // update the virtual URL based on the new URL. For example, this is needed 1067 // update the virtual URL based on the new URL. For example, this is needed
1072 // to show chrome://bookmarks/#1 when the bookmarks webui extension changes 1068 // to show chrome://bookmarks/#1 when the bookmarks webui extension changes
1073 // the URL. 1069 // the URL.
1074 update_virtual_url = needs_update; 1070 update_virtual_url = needs_update;
1075 } 1071 }
1076 1072
1077 if (params.url_is_unreachable) 1073 // Don't use the page type from the pending entry. Some interstitial page
1078 new_entry->set_page_type(PAGE_TYPE_ERROR); 1074 // may have set the type to interstitial. Once we commit, however, the page
1075 // type must always be normal or error.
1076 new_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1077 : PAGE_TYPE_NORMAL);
1079 new_entry->SetURL(params.url); 1078 new_entry->SetURL(params.url);
1080 if (update_virtual_url) 1079 if (update_virtual_url)
1081 UpdateVirtualURLToURL(new_entry, params.url); 1080 UpdateVirtualURLToURL(new_entry, params.url);
1082 new_entry->SetReferrer(params.referrer); 1081 new_entry->SetReferrer(params.referrer);
1083 new_entry->SetPageID(params.page_id); 1082 new_entry->SetPageID(params.page_id);
1084 new_entry->SetTransitionType(params.transition); 1083 new_entry->SetTransitionType(params.transition);
1085 new_entry->set_site_instance( 1084 new_entry->set_site_instance(
1086 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); 1085 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1087 new_entry->SetHasPostData(params.is_post); 1086 new_entry->SetHasPostData(params.is_post);
1088 new_entry->SetPostID(params.post_id); 1087 new_entry->SetPostID(params.post_id);
(...skipping 30 matching lines...) Expand all
1119 // This is a back/forward navigation. The existing page for the ID is 1118 // This is a back/forward navigation. The existing page for the ID is
1120 // guaranteed to exist by ClassifyNavigation, and we just need to update it 1119 // guaranteed to exist by ClassifyNavigation, and we just need to update it
1121 // with new information from the renderer. 1120 // with new information from the renderer.
1122 int entry_index = GetEntryIndexWithPageID(rfh->GetSiteInstance(), 1121 int entry_index = GetEntryIndexWithPageID(rfh->GetSiteInstance(),
1123 params.page_id); 1122 params.page_id);
1124 DCHECK(entry_index >= 0 && 1123 DCHECK(entry_index >= 0 &&
1125 entry_index < static_cast<int>(entries_.size())); 1124 entry_index < static_cast<int>(entries_.size()));
1126 NavigationEntryImpl* entry = entries_[entry_index].get(); 1125 NavigationEntryImpl* entry = entries_[entry_index].get();
1127 1126
1128 // The URL may have changed due to redirects. 1127 // The URL may have changed due to redirects.
1128 entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1129 : PAGE_TYPE_NORMAL);
1129 entry->SetURL(params.url); 1130 entry->SetURL(params.url);
1130 entry->SetReferrer(params.referrer); 1131 entry->SetReferrer(params.referrer);
1131 if (entry->update_virtual_url_with_url()) 1132 if (entry->update_virtual_url_with_url())
1132 UpdateVirtualURLToURL(entry, params.url); 1133 UpdateVirtualURLToURL(entry, params.url);
1133 1134
1134 // The redirected to page should not inherit the favicon from the previous 1135 // The redirected to page should not inherit the favicon from the previous
1135 // page. 1136 // page.
1136 if (ui::PageTransitionIsRedirect(params.transition)) 1137 if (ui::PageTransitionIsRedirect(params.transition))
1137 entry->GetFavicon() = FaviconStatus(); 1138 entry->GetFavicon() = FaviconStatus();
1138 1139
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 // ClassifyNavigation. All we need to do is update the existing entry. 1172 // ClassifyNavigation. All we need to do is update the existing entry.
1172 NavigationEntryImpl* existing_entry = GetEntryWithPageID( 1173 NavigationEntryImpl* existing_entry = GetEntryWithPageID(
1173 rfh->GetSiteInstance(), params.page_id); 1174 rfh->GetSiteInstance(), params.page_id);
1174 1175
1175 // We assign the entry's unique ID to be that of the new one. Since this is 1176 // We assign the entry's unique ID to be that of the new one. Since this is
1176 // always the result of a user action, we want to dismiss infobars, etc. like 1177 // always the result of a user action, we want to dismiss infobars, etc. like
1177 // a regular user-initiated navigation. 1178 // a regular user-initiated navigation.
1178 existing_entry->set_unique_id(pending_entry_->GetUniqueID()); 1179 existing_entry->set_unique_id(pending_entry_->GetUniqueID());
1179 1180
1180 // The URL may have changed due to redirects. 1181 // The URL may have changed due to redirects.
1182 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1183 : PAGE_TYPE_NORMAL);
1181 if (existing_entry->update_virtual_url_with_url()) 1184 if (existing_entry->update_virtual_url_with_url())
1182 UpdateVirtualURLToURL(existing_entry, params.url); 1185 UpdateVirtualURLToURL(existing_entry, params.url);
1183 existing_entry->SetURL(params.url); 1186 existing_entry->SetURL(params.url);
1184 existing_entry->SetReferrer(params.referrer); 1187 existing_entry->SetReferrer(params.referrer);
1185 1188
1186 // The page may have been requested with a different HTTP method. 1189 // The page may have been requested with a different HTTP method.
1187 existing_entry->SetHasPostData(params.is_post); 1190 existing_entry->SetHasPostData(params.is_post);
1188 existing_entry->SetPostID(params.post_id); 1191 existing_entry->SetPostID(params.post_id);
1189 1192
1190 DiscardNonCommittedEntries(); 1193 DiscardNonCommittedEntries();
1191 } 1194 }
1192 1195
1193 void NavigationControllerImpl::RendererDidNavigateInPage( 1196 void NavigationControllerImpl::RendererDidNavigateInPage(
1194 RenderFrameHost* rfh, 1197 RenderFrameHost* rfh,
1195 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1198 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1196 bool* did_replace_entry) { 1199 bool* did_replace_entry) {
1197 DCHECK(ui::PageTransitionIsMainFrame(params.transition)) << 1200 DCHECK(ui::PageTransitionIsMainFrame(params.transition)) <<
1198 "WebKit should only tell us about in-page navs for the main frame."; 1201 "WebKit should only tell us about in-page navs for the main frame.";
1199 // We're guaranteed to have an entry for this one. 1202 // We're guaranteed to have an entry for this one.
1200 NavigationEntryImpl* existing_entry = GetEntryWithPageID( 1203 NavigationEntryImpl* existing_entry = GetEntryWithPageID(
1201 rfh->GetSiteInstance(), params.page_id); 1204 rfh->GetSiteInstance(), params.page_id);
1202 1205
1203 // Reference fragment navigation. We're guaranteed to have the last_committed 1206 // Reference fragment navigation. We're guaranteed to have the last_committed
1204 // entry and it will be the same page as the new navigation (minus the 1207 // entry and it will be the same page as the new navigation (minus the
1205 // reference fragments, of course). We'll update the URL of the existing 1208 // reference fragments, of course). We'll update the URL of the existing
1206 // entry without pruning the forward history. 1209 // entry without pruning the forward history.
1210 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1211 : PAGE_TYPE_NORMAL);
1207 existing_entry->SetURL(params.url); 1212 existing_entry->SetURL(params.url);
1208 if (existing_entry->update_virtual_url_with_url()) 1213 if (existing_entry->update_virtual_url_with_url())
1209 UpdateVirtualURLToURL(existing_entry, params.url); 1214 UpdateVirtualURLToURL(existing_entry, params.url);
1210 1215
1211 existing_entry->SetHasPostData(params.is_post); 1216 existing_entry->SetHasPostData(params.is_post);
1212 existing_entry->SetPostID(params.post_id); 1217 existing_entry->SetPostID(params.post_id);
1213 1218
1214 // This replaces the existing entry since the page ID didn't change. 1219 // This replaces the existing entry since the page ID didn't change.
1215 *did_replace_entry = true; 1220 *did_replace_entry = true;
1216 1221
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 } 1795 }
1791 } 1796 }
1792 } 1797 }
1793 1798
1794 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1799 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1795 const base::Callback<base::Time()>& get_timestamp_callback) { 1800 const base::Callback<base::Time()>& get_timestamp_callback) {
1796 get_timestamp_callback_ = get_timestamp_callback; 1801 get_timestamp_callback_ = get_timestamp_callback;
1797 } 1802 }
1798 1803
1799 } // namespace content 1804 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698