Index: chrome/browser/ui/cocoa/history_menu_bridge.mm |
diff --git a/chrome/browser/ui/cocoa/history_menu_bridge.mm b/chrome/browser/ui/cocoa/history_menu_bridge.mm |
index d006a27bb113be551384ec29572b8f74013f064c..d9f298aa45b76fa272d5d1a856b17379fa6ac07c 100644 |
--- a/chrome/browser/ui/cocoa/history_menu_bridge.mm |
+++ b/chrome/browser/ui/cocoa/history_menu_bridge.mm |
@@ -117,10 +117,9 @@ HistoryMenuBridge::~HistoryMenuBridge() { |
if (history_service_) { |
registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
content::Source<Profile>(profile_)); |
- registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, |
- content::Source<Profile>(profile_)); |
registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
content::Source<Profile>(profile_)); |
+ history_service_->RemoveObserver(this); |
} else { |
registrar_.Remove(this, chrome::NOTIFICATION_HISTORY_LOADED, |
content::Source<Profile>(profile_)); |
@@ -163,6 +162,16 @@ void HistoryMenuBridge::Observe(int type, |
CreateMenu(); |
} |
+void HistoryMenuBridge::OnURLVisited(HistoryService* history_service, |
+ ui::PageTransition transition, |
+ const history::URLRow& row, |
+ const history::RedirectList& redirects, |
+ base::Time visit_time) { |
+ // History has changed, rebuild menu. |
+ need_recreate_ = true; |
droger
2014/10/14 15:15:24
Should we share the code with Observe() for this?
sdefresne
2014/10/14 16:02:05
Done.
|
+ CreateMenu(); |
+} |
+ |
void HistoryMenuBridge::TabRestoreServiceChanged(TabRestoreService* service) { |
const TabRestoreService::Entries& entries = service->entries(); |
@@ -360,12 +369,12 @@ NSMenuItem* HistoryMenuBridge::AddItemToMenu(HistoryItem* item, |
} |
void HistoryMenuBridge::Init() { |
+ DCHECK(history_service_); |
registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_MODIFIED, |
content::Source<Profile>(profile_)); |
- registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URL_VISITED, |
- content::Source<Profile>(profile_)); |
registrar_.Add(this, chrome::NOTIFICATION_HISTORY_URLS_DELETED, |
content::Source<Profile>(profile_)); |
+ history_service_->AddObserver(this); |
} |
void HistoryMenuBridge::CreateMenu() { |