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

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: Remove stale comment. 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 1057 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 new_entry->set_update_virtual_url_with_url(needs_update); 1068 new_entry->set_update_virtual_url_with_url(needs_update);
1069 1069
1070 // When navigating to a new page, give the browser URL handler a chance to 1070 // 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 1071 // 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 1072 // to show chrome://bookmarks/#1 when the bookmarks webui extension changes
1073 // the URL. 1073 // the URL.
1074 update_virtual_url = needs_update; 1074 update_virtual_url = needs_update;
1075 } 1075 }
1076 1076
1077 if (params.url_is_unreachable) 1077 if (params.url_is_unreachable)
1078 new_entry->set_page_type(PAGE_TYPE_ERROR); 1078 new_entry->set_page_type(PAGE_TYPE_ERROR);
Charlie Reis 2015/02/18 23:53:04 It looks like this will behave the same as the cas
wjmaclean 2015/02/19 13:24:38 Done.
1079 new_entry->SetURL(params.url); 1079 new_entry->SetURL(params.url);
1080 if (update_virtual_url) 1080 if (update_virtual_url)
1081 UpdateVirtualURLToURL(new_entry, params.url); 1081 UpdateVirtualURLToURL(new_entry, params.url);
1082 new_entry->SetReferrer(params.referrer); 1082 new_entry->SetReferrer(params.referrer);
1083 new_entry->SetPageID(params.page_id); 1083 new_entry->SetPageID(params.page_id);
1084 new_entry->SetTransitionType(params.transition); 1084 new_entry->SetTransitionType(params.transition);
1085 new_entry->set_site_instance( 1085 new_entry->set_site_instance(
1086 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance())); 1086 static_cast<SiteInstanceImpl*>(rfh->GetSiteInstance()));
1087 new_entry->SetHasPostData(params.is_post); 1087 new_entry->SetHasPostData(params.is_post);
1088 new_entry->SetPostID(params.post_id); 1088 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 1119 // 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 1120 // guaranteed to exist by ClassifyNavigation, and we just need to update it
1121 // with new information from the renderer. 1121 // with new information from the renderer.
1122 int entry_index = GetEntryIndexWithPageID(rfh->GetSiteInstance(), 1122 int entry_index = GetEntryIndexWithPageID(rfh->GetSiteInstance(),
1123 params.page_id); 1123 params.page_id);
1124 DCHECK(entry_index >= 0 && 1124 DCHECK(entry_index >= 0 &&
1125 entry_index < static_cast<int>(entries_.size())); 1125 entry_index < static_cast<int>(entries_.size()));
1126 NavigationEntryImpl* entry = entries_[entry_index].get(); 1126 NavigationEntryImpl* entry = entries_[entry_index].get();
1127 1127
1128 // The URL may have changed due to redirects. 1128 // The URL may have changed due to redirects.
1129 entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1130 : PAGE_TYPE_NORMAL);
1129 entry->SetURL(params.url); 1131 entry->SetURL(params.url);
1130 entry->SetReferrer(params.referrer); 1132 entry->SetReferrer(params.referrer);
1131 if (entry->update_virtual_url_with_url()) 1133 if (entry->update_virtual_url_with_url())
1132 UpdateVirtualURLToURL(entry, params.url); 1134 UpdateVirtualURLToURL(entry, params.url);
1133 1135
1134 // The redirected to page should not inherit the favicon from the previous 1136 // The redirected to page should not inherit the favicon from the previous
1135 // page. 1137 // page.
1136 if (ui::PageTransitionIsRedirect(params.transition)) 1138 if (ui::PageTransitionIsRedirect(params.transition))
1137 entry->GetFavicon() = FaviconStatus(); 1139 entry->GetFavicon() = FaviconStatus();
1138 1140
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 // ClassifyNavigation. All we need to do is update the existing entry. 1173 // ClassifyNavigation. All we need to do is update the existing entry.
1172 NavigationEntryImpl* existing_entry = GetEntryWithPageID( 1174 NavigationEntryImpl* existing_entry = GetEntryWithPageID(
1173 rfh->GetSiteInstance(), params.page_id); 1175 rfh->GetSiteInstance(), params.page_id);
1174 1176
1175 // We assign the entry's unique ID to be that of the new one. Since this is 1177 // 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 1178 // always the result of a user action, we want to dismiss infobars, etc. like
1177 // a regular user-initiated navigation. 1179 // a regular user-initiated navigation.
1178 existing_entry->set_unique_id(pending_entry_->GetUniqueID()); 1180 existing_entry->set_unique_id(pending_entry_->GetUniqueID());
1179 1181
1180 // The URL may have changed due to redirects. 1182 // The URL may have changed due to redirects.
1183 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1184 : PAGE_TYPE_NORMAL);
1181 if (existing_entry->update_virtual_url_with_url()) 1185 if (existing_entry->update_virtual_url_with_url())
1182 UpdateVirtualURLToURL(existing_entry, params.url); 1186 UpdateVirtualURLToURL(existing_entry, params.url);
1183 existing_entry->SetURL(params.url); 1187 existing_entry->SetURL(params.url);
1184 existing_entry->SetReferrer(params.referrer); 1188 existing_entry->SetReferrer(params.referrer);
1185 1189
1186 // The page may have been requested with a different HTTP method. 1190 // The page may have been requested with a different HTTP method.
1187 existing_entry->SetHasPostData(params.is_post); 1191 existing_entry->SetHasPostData(params.is_post);
1188 existing_entry->SetPostID(params.post_id); 1192 existing_entry->SetPostID(params.post_id);
1189 1193
1190 DiscardNonCommittedEntries(); 1194 DiscardNonCommittedEntries();
1191 } 1195 }
1192 1196
1193 void NavigationControllerImpl::RendererDidNavigateInPage( 1197 void NavigationControllerImpl::RendererDidNavigateInPage(
1194 RenderFrameHost* rfh, 1198 RenderFrameHost* rfh,
1195 const FrameHostMsg_DidCommitProvisionalLoad_Params& params, 1199 const FrameHostMsg_DidCommitProvisionalLoad_Params& params,
1196 bool* did_replace_entry) { 1200 bool* did_replace_entry) {
1197 DCHECK(ui::PageTransitionIsMainFrame(params.transition)) << 1201 DCHECK(ui::PageTransitionIsMainFrame(params.transition)) <<
1198 "WebKit should only tell us about in-page navs for the main frame."; 1202 "WebKit should only tell us about in-page navs for the main frame.";
1199 // We're guaranteed to have an entry for this one. 1203 // We're guaranteed to have an entry for this one.
1200 NavigationEntryImpl* existing_entry = GetEntryWithPageID( 1204 NavigationEntryImpl* existing_entry = GetEntryWithPageID(
1201 rfh->GetSiteInstance(), params.page_id); 1205 rfh->GetSiteInstance(), params.page_id);
1202 1206
1203 // Reference fragment navigation. We're guaranteed to have the last_committed 1207 // 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 1208 // 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 1209 // reference fragments, of course). We'll update the URL of the existing
1206 // entry without pruning the forward history. 1210 // entry without pruning the forward history.
1211 existing_entry->set_page_type(params.url_is_unreachable ? PAGE_TYPE_ERROR
1212 : PAGE_TYPE_NORMAL);
1213
Charlie Reis 2015/02/18 23:53:04 nit: No blank line.
wjmaclean 2015/02/19 13:24:38 Done.
1207 existing_entry->SetURL(params.url); 1214 existing_entry->SetURL(params.url);
1208 if (existing_entry->update_virtual_url_with_url()) 1215 if (existing_entry->update_virtual_url_with_url())
1209 UpdateVirtualURLToURL(existing_entry, params.url); 1216 UpdateVirtualURLToURL(existing_entry, params.url);
1210 1217
1211 existing_entry->SetHasPostData(params.is_post); 1218 existing_entry->SetHasPostData(params.is_post);
1212 existing_entry->SetPostID(params.post_id); 1219 existing_entry->SetPostID(params.post_id);
1213 1220
1214 // This replaces the existing entry since the page ID didn't change. 1221 // This replaces the existing entry since the page ID didn't change.
1215 *did_replace_entry = true; 1222 *did_replace_entry = true;
1216 1223
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 } 1797 }
1791 } 1798 }
1792 } 1799 }
1793 1800
1794 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1801 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1795 const base::Callback<base::Time()>& get_timestamp_callback) { 1802 const base::Callback<base::Time()>& get_timestamp_callback) {
1796 get_timestamp_callback_ = get_timestamp_callback; 1803 get_timestamp_callback_ = get_timestamp_callback;
1797 } 1804 }
1798 1805
1799 } // namespace content 1806 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698