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 faf00c6db8293356065862bd9fdc5e72a72ba4c8..2194c27d3cadc06573fd05ce6d0f716588563335 100644 |
--- a/components/history/core/browser/history_backend.cc |
+++ b/components/history/core/browser/history_backend.cc |
@@ -891,6 +891,58 @@ void HistoryBackend::SetPageTitle(const GURL& url, |
} |
} |
+void HistoryBackend::SetPageHistoryContext(const GURL& url, |
+ HistoryContext context) { |
+ if (!db_) |
+ return; |
+ |
+ // Search for recent redirects which should get the same title. We make a |
+ // dummy list containing the exact URL visited if there are no redirects so |
+ // the processing below can be the same. |
+ RedirectList dummy_list; |
+ RedirectList* redirects; |
+ RedirectCache::iterator iter = recent_redirects_.Get(url); |
+ if (iter != recent_redirects_.end()) { |
+ redirects = &iter->second; |
+ |
+ // This redirect chain should have the destination URL as the last item. |
+ DCHECK(!redirects->empty()); |
+ DCHECK(redirects->back() == url); |
+ } else { |
+ // No redirect chain stored, make up one containing the URL we want so we |
+ // can use the same logic below. |
+ dummy_list.push_back(url); |
+ redirects = &dummy_list; |
+ } |
+ |
+ URLRows changed_urls; |
+ for (size_t i = 0; i < redirects->size(); i++) { |
+ URLRow row; |
+ URLID row_id = db_->GetRowForURL(redirects->at(i), &row); |
+ VisitID cur_visit = db_->GetMostRecentVisitForURL(row_id, nullptr); |
+ if (row_id && row.context() != context) { |
+ row.set_context(context); |
+ |
+ VisitRow visit_row; |
+ if (db_->GetRowForVisit(cur_visit, &visit_row)) { |
+ visit_row.context = context; |
+ db_->UpdateVisitRow(visit_row); |
+ printf("\n1 HistoryBackend::SetPageHistoryContext %d\n", static_cast<int>(context)); |
+ } |
+ db_->UpdateURLRow(row_id, row); |
+ printf("\n2 HistoryBackend::SetPageHistoryContext %d\n", static_cast<int>(context)); |
+ changed_urls.push_back(row); |
+ } |
+ } |
+ |
+ // Broadcast notifications for any URLs that have changed. This will |
+ // update the in-memory database and the InMemoryURLIndex. |
+ if (!changed_urls.empty()) { |
+ NotifyURLsModified(changed_urls); |
+ ScheduleCommit(); |
+ } |
+} |
+ |
void HistoryBackend::AddPageNoVisitForBookmark(const GURL& url, |
const base::string16& title) { |
if (!db_) |