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

Unified Diff: chrome/browser/extensions/api/history/history_api.cc

Issue 651193002: Remove NOTIFICATION_HISTORY_URL_VISITED (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@373326.2
Patch Set: Address comments 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/extensions/api/history/history_api.h ('k') | chrome/browser/history/chrome_history_client.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/history/history_api.cc
diff --git a/chrome/browser/extensions/api/history/history_api.cc b/chrome/browser/extensions/api/history/history_api.cc
index 356373c9ceceb3ac463e286732150edad770a490..886d1a1d38431577acc55a899c2418741d389e5e 100644
--- a/chrome/browser/extensions/api/history/history_api.cc
+++ b/chrome/browser/extensions/api/history/history_api.cc
@@ -132,44 +132,36 @@ scoped_ptr<VisitItem> GetVisitItem(const history::VisitRow& row) {
} // namespace
-HistoryEventRouter::HistoryEventRouter(Profile* profile) {
- const content::Source<Profile> source = content::Source<Profile>(profile);
- registrar_.Add(this,
- chrome::NOTIFICATION_HISTORY_URL_VISITED,
- source);
+HistoryEventRouter::HistoryEventRouter(Profile* profile,
+ HistoryService* history_service)
+ : profile_(profile), history_service_observer_(this) {
+ DCHECK(profile);
registrar_.Add(this,
chrome::NOTIFICATION_HISTORY_URLS_DELETED,
- source);
+ content::Source<Profile>(profile));
+ history_service_observer_.Add(history_service);
}
-HistoryEventRouter::~HistoryEventRouter() {}
+HistoryEventRouter::~HistoryEventRouter() {
+}
void HistoryEventRouter::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
- switch (type) {
- case chrome::NOTIFICATION_HISTORY_URL_VISITED:
- HistoryUrlVisited(
- content::Source<Profile>(source).ptr(),
- content::Details<const history::URLVisitedDetails>(details).ptr());
- break;
- case chrome::NOTIFICATION_HISTORY_URLS_DELETED:
- HistoryUrlsRemoved(
- content::Source<Profile>(source).ptr(),
- content::Details<const history::URLsDeletedDetails>(details).ptr());
- break;
- default:
- NOTREACHED();
- }
-}
-
-void HistoryEventRouter::HistoryUrlVisited(
- Profile* profile,
- const history::URLVisitedDetails* details) {
- scoped_ptr<HistoryItem> history_item = GetHistoryItem(details->row);
+ DCHECK_EQ(type, chrome::NOTIFICATION_HISTORY_URLS_DELETED);
+ HistoryUrlsRemoved(
+ content::Source<Profile>(source).ptr(),
+ content::Details<const history::URLsDeletedDetails>(details).ptr());
+}
+
+void HistoryEventRouter::OnURLVisited(HistoryService* history_service,
+ ui::PageTransition transition,
+ const history::URLRow& row,
+ const history::RedirectList& redirects,
+ base::Time visit_time) {
+ scoped_ptr<HistoryItem> history_item = GetHistoryItem(row);
scoped_ptr<base::ListValue> args = OnVisited::Create(*history_item);
-
- DispatchEvent(profile, api::history::OnVisited::kEventName, args.Pass());
+ DispatchEvent(profile_, api::history::OnVisited::kEventName, args.Pass());
}
void HistoryEventRouter::HistoryUrlsRemoved(
@@ -235,8 +227,10 @@ void HistoryAPI::OnListenerAdded(const EventListenerInfo& details) {
tracked_objects::ScopedProfile tracking_profile(
FROM_HERE_WITH_EXPLICIT_FUNCTION("HistoryAPI::OnListenerAdded"));
- history_event_router_.reset(
- new HistoryEventRouter(Profile::FromBrowserContext(browser_context_)));
+ Profile* profile = Profile::FromBrowserContext(browser_context_);
+ history_event_router_.reset(new HistoryEventRouter(
+ profile,
+ HistoryServiceFactory::GetForProfile(profile, Profile::EXPLICIT_ACCESS)));
EventRouter::Get(browser_context_)->UnregisterObserver(this);
}
« no previous file with comments | « chrome/browser/extensions/api/history/history_api.h ('k') | chrome/browser/history/chrome_history_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698