Index: chrome/browser/history/history_backend.cc |
diff --git a/chrome/browser/history/history_backend.cc b/chrome/browser/history/history_backend.cc |
index 7e199e64ca8906dfdba0e8231cfee6caecc86c34..89716ee444b9e1d5496e1927d0e5af50666799bc 100644 |
--- a/chrome/browser/history/history_backend.cc |
+++ b/chrome/browser/history/history_backend.cc |
@@ -38,6 +38,7 @@ |
#include "chrome/common/importer/imported_favicon_usage.h" |
#include "chrome/common/url_constants.h" |
#include "components/favicon_base/select_favicon_frames.h" |
+#include "components/history/core/browser/history_backend_observer.h" |
#include "components/history/core/browser/history_client.h" |
#include "components/history/core/browser/keyword_search_term.h" |
#include "components/history/core/browser/page_usage_data.h" |
@@ -806,15 +807,17 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( |
if (typed_url_syncable_service_.get()) |
typed_url_syncable_service_->OnUrlVisited(transition, &url_info); |
- scoped_ptr<URLVisitedDetails> details(new URLVisitedDetails); |
- details->transition = transition; |
- details->row = url_info; |
- details->visit_time = time; |
+ RedirectList redirects; |
// TODO(meelapshah) Disabled due to potential PageCycler regression. |
// Re-enable this. |
- // QueryRedirectsTo(url, &details->redirects); |
- BroadcastNotifications(chrome::NOTIFICATION_HISTORY_URL_VISITED, |
- details.PassAs<HistoryDetails>()); |
+ // QueryRedirectsTo(url, &redirects); |
+ NotifyAddVisit(transition, url_info, redirects, time); |
+ |
+ // TODO(sdefresne): turn HistoryBackend::Delegate from HistoryService into |
+ // an HistoryBackendObserver and register it so that we can remove this |
+ // method. |
+ if (delegate_) |
+ delegate_->NotifyURLVisited(transition, url_info, redirects, time); |
} else { |
VLOG(0) << "Failed to build visit insert statement: " |
<< "url_id = " << url_id; |
@@ -823,6 +826,16 @@ std::pair<URLID, VisitID> HistoryBackend::AddPageVisit( |
return std::make_pair(url_id, visit_id); |
} |
+void HistoryBackend::NotifyAddVisit(ui::PageTransition transition, |
+ const URLRow& row, |
+ const RedirectList& redirects, |
+ base::Time visit_time) { |
+ FOR_EACH_OBSERVER( |
+ HistoryBackendObserver, |
+ observers_, |
+ OnURLVisited(this, transition, row, redirects, visit_time)); |
+} |
+ |
void HistoryBackend::AddPagesWithDetails(const URLRows& urls, |
VisitSource visit_source) { |
if (!db_) |
@@ -1141,6 +1154,16 @@ void HistoryBackend::DeleteMatchingURLsForKeyword(KeywordID keyword_id, |
} |
} |
+// Observers ------------------------------------------------------------------- |
+ |
+void HistoryBackend::AddObserver(HistoryBackendObserver* observer) { |
+ observers_.AddObserver(observer); |
+} |
+ |
+void HistoryBackend::RemoveObserver(HistoryBackendObserver* observer) { |
+ observers_.RemoveObserver(observer); |
+} |
+ |
// Downloads ------------------------------------------------------------------- |
uint32 HistoryBackend::GetNextDownloadId() { |