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

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, add unit tests. 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 1108 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (params.url_is_unreachable)
1130 entry->set_page_type(PAGE_TYPE_ERROR);
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 if (params.url_is_unreachable)
1184 existing_entry->set_page_type(PAGE_TYPE_ERROR);
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 // TODO(wjmaclean): do we need an else-clause here to clear the entry, since
1212 // it is persisted between navigations?
Charlie Reis 2015/02/18 01:01:53 This is a good question. Can you test this manual
wjmaclean 2015/02/18 19:10:11 After a manual test, there doesn't seem to be a di
Charlie Reis 2015/02/18 23:53:04 I think that's the right thing to do. Thanks for
1213 if (params.url_is_unreachable)
1214 existing_entry->set_page_type(PAGE_TYPE_ERROR);
1207 existing_entry->SetURL(params.url); 1215 existing_entry->SetURL(params.url);
1208 if (existing_entry->update_virtual_url_with_url()) 1216 if (existing_entry->update_virtual_url_with_url())
1209 UpdateVirtualURLToURL(existing_entry, params.url); 1217 UpdateVirtualURLToURL(existing_entry, params.url);
1210 1218
1211 existing_entry->SetHasPostData(params.is_post); 1219 existing_entry->SetHasPostData(params.is_post);
1212 existing_entry->SetPostID(params.post_id); 1220 existing_entry->SetPostID(params.post_id);
1213 1221
1214 // This replaces the existing entry since the page ID didn't change. 1222 // This replaces the existing entry since the page ID didn't change.
1215 *did_replace_entry = true; 1223 *did_replace_entry = true;
1216 1224
(...skipping 573 matching lines...) Expand 10 before | Expand all | Expand 10 after
1790 } 1798 }
1791 } 1799 }
1792 } 1800 }
1793 1801
1794 void NavigationControllerImpl::SetGetTimestampCallbackForTest( 1802 void NavigationControllerImpl::SetGetTimestampCallbackForTest(
1795 const base::Callback<base::Time()>& get_timestamp_callback) { 1803 const base::Callback<base::Time()>& get_timestamp_callback) {
1796 get_timestamp_callback_ = get_timestamp_callback; 1804 get_timestamp_callback_ = get_timestamp_callback;
1797 } 1805 }
1798 1806
1799 } // namespace content 1807 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698