Index: chrome/browser/history/chrome_history_client.cc |
diff --git a/chrome/browser/history/chrome_history_client.cc b/chrome/browser/history/chrome_history_client.cc |
index ea979be370bd4b1b531ab34ba7b888559f0cacec..40b5cac8feb8f2035280b982653d402a75cd5587 100644 |
--- a/chrome/browser/history/chrome_history_client.cc |
+++ b/chrome/browser/history/chrome_history_client.cc |
@@ -7,6 +7,7 @@ |
#include "base/logging.h" |
#include "chrome/browser/chrome_notification_types.h" |
#include "chrome/browser/history/history_notifications.h" |
+#include "chrome/browser/history/history_service.h" |
#include "chrome/browser/history/top_sites.h" |
#include "chrome/browser/ui/profile_error_dialog.h" |
#include "chrome/common/chrome_version_info.h" |
@@ -20,6 +21,7 @@ ChromeHistoryClient::ChromeHistoryClient(BookmarkModel* bookmark_model, |
history::TopSites* top_sites) |
: bookmark_model_(bookmark_model), |
profile_(profile), |
+ history_service_(nullptr), |
top_sites_(top_sites) { |
DCHECK(bookmark_model_); |
if (top_sites_) |
@@ -31,6 +33,12 @@ ChromeHistoryClient::~ChromeHistoryClient() { |
top_sites_->RemoveObserver(this); |
} |
+void ChromeHistoryClient::SetHistoryService(HistoryService* history_service) { |
+ DCHECK(history_service); |
+ history_service_ = history_service; |
+ history_service_->AddObserver(this); |
+} |
+ |
void ChromeHistoryClient::BlockUntilBookmarksLoaded() { |
bookmark_model_->BlockTillLoaded(); |
} |
@@ -79,6 +87,31 @@ void ChromeHistoryClient::Shutdown() { |
// shutdown (HistoryService::Cleanup to complete). In such a scenario history |
// sees an incorrect view of bookmarks, but it's better than a deadlock. |
bookmark_model_->Shutdown(); |
+ if (history_service_) { |
+ history_service_->RemoveObserver(this); |
+ history_service_ = nullptr; |
+ } |
+} |
+ |
+// TODO(sdefresne): port client listening for NOTIFICATION_HISTORY_URL_VISITED |
+// to use the HistoryService::Observer pattern instead and remove this method |
+// when this is complete, http://crbug.com/42178 |
+void ChromeHistoryClient::OnURLVisited(HistoryService* history_service, |
+ ui::PageTransition transition, |
+ const history::URLRow& row, |
+ const history::RedirectList& redirects, |
+ base::Time visit_time) { |
+ DCHECK(history_service == history_service_); |
+ scoped_ptr<history::URLVisitedDetails> details( |
+ new history::URLVisitedDetails); |
+ details->transition = transition; |
+ details->row = row; |
+ details->redirects = redirects; |
+ details->visit_time = visit_time; |
+ content::NotificationService::current()->Notify( |
+ chrome::NOTIFICATION_HISTORY_URL_VISITED, |
+ content::Source<Profile>(profile_), |
+ content::Details<history::HistoryDetails>(details.get())); |
} |
void ChromeHistoryClient::TopSitesLoaded(history::TopSites* top_sites) { |