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

Unified Diff: chrome/browser/history/history_backend.cc

Issue 631253002: Refactor sending NOTIFICATION_HISTORY_URL_VISITED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests on Android Created 6 years, 2 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
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_backend_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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() {
« no previous file with comments | « chrome/browser/history/history_backend.h ('k') | chrome/browser/history/history_backend_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698