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

Unified Diff: components/history/core/browser/history_backend.cc

Issue 2949023002: [WIP] Fix history.replaceState() not propagating back favicons (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
Index: components/history/core/browser/history_backend.cc
diff --git a/components/history/core/browser/history_backend.cc b/components/history/core/browser/history_backend.cc
index 1c4aa6a0436526c8c33c228708c1e585b47a3127..c81501a9f2969fd8211b3963e806673df9e01f92 100644
--- a/components/history/core/browser/history_backend.cc
+++ b/components/history/core/browser/history_backend.cc
@@ -472,10 +472,19 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
bool is_keyword_generated = ui::PageTransitionCoreTypeIs(
request_transition, ui::PAGE_TRANSITION_KEYWORD_GENERATED);
+ RedirectList redirects = request.redirects;
sky 2017/06/22 15:26:39 This is worth a comment. Also, avoid the potential
+ if (request.replaced_entry_url.has_value()) {
+ RedirectList prior_redirects;
+ GetCachedRecentRedirects(*request.replaced_entry_url, &prior_redirects);
+ prior_redirects.insert(prior_redirects.end(), redirects.begin(),
+ redirects.end());
+ redirects = std::move(prior_redirects);
+ }
+
// If the user is navigating to a not-previously-typed intranet hostname,
// change the transition to TYPED so that the omnibox will learn that this is
// a known host.
- bool has_redirects = request.redirects.size() > 1;
+ bool has_redirects = redirects.size() > 1;
if (ui::PageTransitionIsMainFrame(request_transition) &&
!ui::PageTransitionCoreTypeIs(request_transition,
ui::PAGE_TRANSITION_TYPED) &&
@@ -483,7 +492,7 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
// Check both the start and end of a redirect chain, since the user will
// consider both to have been "navigated to".
if (IsUntypedIntranetHost(request.url) ||
- (has_redirects && IsUntypedIntranetHost(request.redirects[0]))) {
+ (has_redirects && IsUntypedIntranetHost(redirects[0]))) {
request_transition = ui::PageTransitionFromInt(
ui::PAGE_TRANSITION_TYPED |
ui::PageTransitionGetQualifier(request_transition));
@@ -515,7 +524,6 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
ui::PageTransition redirect_info = ui::PAGE_TRANSITION_CHAIN_START;
- RedirectList redirects = request.redirects;
if (redirects[0].SchemeIs(url::kAboutScheme)) {
// When the redirect source + referrer is "about" we skip it. This
// happens when a page opens a new frame/window to about:blank and then
@@ -547,7 +555,7 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
// can be called a lot, for example, the page cycler, and most of the
// time we won't have changed anything.
VisitRow visit_row;
- if (request.did_replace_entry &&
+ if (request.replaced_entry_url.has_value() &&
db_->GetRowForVisit(last_ids.second, &visit_row) &&
visit_row.transition & ui::PAGE_TRANSITION_CHAIN_END) {
visit_row.transition = ui::PageTransitionFromInt(
@@ -2086,20 +2094,8 @@ bool HistoryBackend::SetFaviconMappingsForPageAndRedirects(
// all the pages in the redirect chain if it redirected.
RedirectList redirects;
GetCachedRecentRedirects(page_url, &redirects);
- bool mappings_changed = SetFaviconMappingsForPages(redirects, icon_type,
- icon_ids);
- if (page_url.has_ref()) {
- // Refs often gets added by Javascript, but the redirect chain is keyed to
- // the URL without a ref.
- GURL::Replacements replacements;
- replacements.ClearRef();
- GURL page_url_without_ref = page_url.ReplaceComponents(replacements);
- GetCachedRecentRedirects(page_url_without_ref, &redirects);
- mappings_changed |= SetFaviconMappingsForPages(redirects, icon_type,
- icon_ids);
- }
- return mappings_changed;
+ return SetFaviconMappingsForPages(redirects, icon_type, icon_ids);
}
bool HistoryBackend::SetFaviconMappingsForPages(

Powered by Google App Engine
This is Rietveld 408576698