| 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 7ef302aca2e7d3b4b884097c154bf361e4abfebf..b071096c8c60580adbc7aea8e78f5cd6605d9f2a 100644
|
| --- a/components/history/core/browser/history_backend.cc
|
| +++ b/components/history/core/browser/history_backend.cc
|
| @@ -83,6 +83,19 @@ void RunUnlessCanceled(
|
| closure.Run();
|
| }
|
|
|
| +void ConcatMoveRedirectList(RedirectList* source, RedirectList* output) {
|
| + if (source->empty())
|
| + return;
|
| +
|
| + if (output->empty()) {
|
| + *output = std::move(*source);
|
| + } else {
|
| + output->reserve(output->size() + source->size());
|
| + for (GURL& redirect : *source)
|
| + output->push_back(std::move(redirect));
|
| + }
|
| +}
|
| +
|
| } // namespace
|
|
|
| // How long we'll wait to do a commit, so that things are batched together.
|
| @@ -491,6 +504,7 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
|
| }
|
|
|
| RedirectList extended_redirect_chain;
|
| + RedirectList redirects = request.redirects;
|
|
|
| if (!has_redirects) {
|
| // The single entry is both a chain start and end.
|
| @@ -516,8 +530,6 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
|
| // Redirect case. Add the redirect chain.
|
|
|
| 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
|
| @@ -549,7 +561,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(
|
| @@ -590,21 +602,24 @@ void HistoryBackend::AddPage(const HistoryAddPageArgs& request) {
|
| // redirects.
|
| redirect_info = ui::PAGE_TRANSITION_SERVER_REDIRECT;
|
| }
|
| + }
|
|
|
| - // Last, save this redirect chain for later so we can set titles & favicons
|
| - // on the redirected pages properly. For this we use the extended redirect
|
| - // chain, which includes URLs from concatenated redirects.
|
| - if (extended_redirect_chain.empty()) {
|
| - extended_redirect_chain = std::move(redirects);
|
| - } else {
|
| - extended_redirect_chain.reserve(extended_redirect_chain.size() +
|
| - redirects.size());
|
| - for (GURL& redirect : redirects)
|
| - extended_redirect_chain.push_back(std::move(redirect));
|
| - }
|
| - recent_redirects_.Put(request.url, extended_redirect_chain);
|
| + // If the page replaced another one in history, we treat is similarly as a
|
| + // redirect and propagate favicon and titles through.
|
| + if (request.replaced_entry_url.has_value()) {
|
| + RedirectList replaced_url_redirects;
|
| + GetCachedRecentRedirects(*request.replaced_entry_url,
|
| + &replaced_url_redirects);
|
| + ConcatMoveRedirectList(&replaced_url_redirects, &extended_redirect_chain);
|
| }
|
|
|
| + // Last, save this redirect chain for later so we can set titles & favicons
|
| + // on the redirected pages properly.
|
| + ConcatMoveRedirectList(&redirects, &extended_redirect_chain);
|
| +
|
| + if (extended_redirect_chain.size() > 1)
|
| + recent_redirects_.Put(request.url, extended_redirect_chain);
|
| +
|
| // TODO(brettw) bug 1140015: Add an "add page" notification so the history
|
| // views can keep in sync.
|
|
|
|
|