Chromium Code Reviews| 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..00cd87a49600310802f458d7ac3205fef6095ef3 100644 |
| --- a/chrome/browser/extensions/api/history/history_api.cc |
| +++ b/chrome/browser/extensions/api/history/history_api.cc |
| @@ -132,27 +132,26 @@ scoped_ptr<VisitItem> GetVisitItem(const history::VisitRow& row) { |
| } // namespace |
| -HistoryEventRouter::HistoryEventRouter(Profile* profile) { |
| +HistoryEventRouter::HistoryEventRouter(Profile* profile, |
| + HistoryService* history_service) |
| + : profile_(profile), history_service_(history_service) { |
| + DCHECK(profile); |
| + DCHECK(history_service); |
| const content::Source<Profile> source = content::Source<Profile>(profile); |
| registrar_.Add(this, |
| - chrome::NOTIFICATION_HISTORY_URL_VISITED, |
| - source); |
| - registrar_.Add(this, |
| chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
| source); |
| + history_service_->AddObserver(this); |
| } |
| -HistoryEventRouter::~HistoryEventRouter() {} |
| +HistoryEventRouter::~HistoryEventRouter() { |
| + history_service_->RemoveObserver(this); |
| +} |
| 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(), |
| @@ -163,13 +162,15 @@ void HistoryEventRouter::Observe(int type, |
| } |
| } |
| -void HistoryEventRouter::HistoryUrlVisited( |
| - Profile* profile, |
| - const history::URLVisitedDetails* details) { |
| - scoped_ptr<HistoryItem> history_item = GetHistoryItem(details->row); |
| +void HistoryEventRouter::OnURLVisited(HistoryService* history_service, |
| + ui::PageTransition transition, |
| + const history::URLRow& row, |
| + const history::RedirectList& redirects, |
| + base::Time visit_time) { |
| + DCHECK(history_service_ == history_service); |
|
droger
2014/10/14 15:15:24
DHCEK_EQ
sdefresne
2014/10/14 16:02:05
Done.
|
| + 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 +236,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); |
| } |