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

Unified Diff: chrome/browser/ui/cocoa/history_menu_bridge.mm

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
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..50456dc3b42fc303f6d71cf757fb6fb7bc5d42a7 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_));
@@ -158,9 +157,8 @@ void HistoryMenuBridge::Observe(int type,
}
// All other notification types that we observe indicate that the history has
- // changed and we need to rebuild.
- need_recreate_ = true;
- CreateMenu();
+ // changed.
+ OnHistoryChanged();
}
void HistoryMenuBridge::TabRestoreServiceChanged(TabRestoreService* service) {
@@ -274,6 +272,14 @@ void HistoryMenuBridge::BuildMenu() {
CreateMenu();
}
+void HistoryMenuBridge::OnURLVisited(HistoryService* history_service,
+ ui::PageTransition transition,
+ const history::URLRow& row,
+ const history::RedirectList& redirects,
+ base::Time visit_time) {
+ OnHistoryChanged();
+}
+
HistoryMenuBridge::HistoryItem* HistoryMenuBridge::HistoryItemForMenuItem(
NSMenuItem* item) {
std::map<NSMenuItem*, HistoryItem*>::iterator it = menu_item_map_.find(item);
@@ -360,12 +366,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() {
@@ -389,6 +395,12 @@ void HistoryMenuBridge::CreateMenu() {
&cancelable_task_tracker_);
}
+void HistoryMenuBridge::OnHistoryChanged() {
+ // History has changed, rebuild menu.
+ need_recreate_ = true;
+ CreateMenu();
+}
+
void HistoryMenuBridge::OnVisitedHistoryResults(
history::QueryResults* results) {
NSMenu* menu = HistoryMenu();
« no previous file with comments | « chrome/browser/ui/cocoa/history_menu_bridge.h ('k') | chrome/browser/ui/views/frame/test_with_browser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698