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

Side by Side Diff: chrome/browser/ui/cocoa/history_menu_bridge.h

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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_ 5 #ifndef CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_
6 #define CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_ 6 #define CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_
7 7
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <map> 9 #include <map>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/mac/scoped_nsobject.h" 12 #include "base/mac/scoped_nsobject.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/task/cancelable_task_tracker.h" 14 #include "base/task/cancelable_task_tracker.h"
15 #import "chrome/browser/favicon/favicon_service.h" 15 #import "chrome/browser/favicon/favicon_service.h"
16 #include "chrome/browser/history/history_service.h" 16 #include "chrome/browser/history/history_service.h"
17 #include "chrome/browser/sessions/tab_restore_service.h" 17 #include "chrome/browser/sessions/tab_restore_service.h"
18 #include "chrome/browser/sessions/tab_restore_service_observer.h" 18 #include "chrome/browser/sessions/tab_restore_service_observer.h"
19 #import "chrome/browser/ui/cocoa/main_menu_item.h" 19 #import "chrome/browser/ui/cocoa/main_menu_item.h"
20 #include "components/history/core/browser/history_service_observer.h"
20 #include "components/sessions/session_id.h" 21 #include "components/sessions/session_id.h"
21 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
22 23
23 class NotificationRegistrar; 24 class NotificationRegistrar;
24 class PageUsageData; 25 class PageUsageData;
25 class Profile; 26 class Profile;
26 class TabRestoreService; 27 class TabRestoreService;
27 @class HistoryMenuCocoaController; 28 @class HistoryMenuCocoaController;
28 29
29 namespace { 30 namespace {
(...skipping 21 matching lines...) Expand all
51 // action mechanism. 52 // action mechanism.
52 // 53 //
53 // These menu items do not use firstResponder as their target. Rather, they are 54 // These menu items do not use firstResponder as their target. Rather, they are
54 // hooked directly up to the HistoryMenuCocoaController that then bridges back 55 // hooked directly up to the HistoryMenuCocoaController that then bridges back
55 // to this class. These items are created via the AddItemToMenu() helper. Also, 56 // to this class. These items are created via the AddItemToMenu() helper. Also,
56 // unlike the typical ownership model, this bridge owns its controller. The 57 // unlike the typical ownership model, this bridge owns its controller. The
57 // controller is very thin and only exists to interact with Cocoa, but this 58 // controller is very thin and only exists to interact with Cocoa, but this
58 // class does the bulk of the work. 59 // class does the bulk of the work.
59 class HistoryMenuBridge : public content::NotificationObserver, 60 class HistoryMenuBridge : public content::NotificationObserver,
60 public TabRestoreServiceObserver, 61 public TabRestoreServiceObserver,
61 public MainMenuItem { 62 public MainMenuItem,
63 public history::HistoryServiceObserver {
62 public: 64 public:
63 // This is a generalization of the data we store in the history menu because 65 // This is a generalization of the data we store in the history menu because
64 // we pull things from different sources with different data types. 66 // we pull things from different sources with different data types.
65 struct HistoryItem { 67 struct HistoryItem {
66 public: 68 public:
67 HistoryItem(); 69 HistoryItem();
68 // Copy constructor allowed. 70 // Copy constructor allowed.
69 HistoryItem(const HistoryItem& copy); 71 HistoryItem(const HistoryItem& copy);
70 ~HistoryItem(); 72 ~HistoryItem();
71 73
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 const content::NotificationDetails& details) override; 134 const content::NotificationDetails& details) override;
133 135
134 // TabRestoreServiceObserver: 136 // TabRestoreServiceObserver:
135 virtual void TabRestoreServiceChanged(TabRestoreService* service) override; 137 virtual void TabRestoreServiceChanged(TabRestoreService* service) override;
136 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) override; 138 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) override;
137 139
138 // MainMenuItem: 140 // MainMenuItem:
139 virtual void ResetMenu() override; 141 virtual void ResetMenu() override;
140 virtual void BuildMenu() override; 142 virtual void BuildMenu() override;
141 143
144 // history::HistoryServiceObserver:
145 virtual void OnURLVisited(HistoryService* history_service,
146 ui::PageTransition transition,
147 const history::URLRow& row,
148 const history::RedirectList& redirects,
149 base::Time visit_time) override;
150
142 // Looks up an NSMenuItem in the |menu_item_map_| and returns the 151 // Looks up an NSMenuItem in the |menu_item_map_| and returns the
143 // corresponding HistoryItem. 152 // corresponding HistoryItem.
144 HistoryItem* HistoryItemForMenuItem(NSMenuItem* item); 153 HistoryItem* HistoryItemForMenuItem(NSMenuItem* item);
145 154
146 // I wish I has a "friend @class" construct. These are used by the HMCC 155 // I wish I has a "friend @class" construct. These are used by the HMCC
147 // to access model information when responding to actions. 156 // to access model information when responding to actions.
148 HistoryService* service(); 157 HistoryService* service();
149 Profile* profile(); 158 Profile* profile();
150 159
151 protected: 160 protected:
(...skipping 17 matching lines...) Expand all
169 NSInteger index); 178 NSInteger index);
170 179
171 // Called by the ctor if |service_| is ready at the time, or by a 180 // Called by the ctor if |service_| is ready at the time, or by a
172 // notification receiver. Finishes initialization tasks by subscribing for 181 // notification receiver. Finishes initialization tasks by subscribing for
173 // change notifications and calling CreateMenu(). 182 // change notifications and calling CreateMenu().
174 void Init(); 183 void Init();
175 184
176 // Does the query for the history information to create the menu. 185 // Does the query for the history information to create the menu.
177 void CreateMenu(); 186 void CreateMenu();
178 187
188 // Invoked when the History information has changed.
189 void OnHistoryChanged();
190
179 // Callback method for when HistoryService query results are ready with the 191 // Callback method for when HistoryService query results are ready with the
180 // most recently-visited sites. 192 // most recently-visited sites.
181 void OnVisitedHistoryResults(history::QueryResults* results); 193 void OnVisitedHistoryResults(history::QueryResults* results);
182 194
183 // Creates a HistoryItem* for the given tab entry. Caller takes ownership of 195 // Creates a HistoryItem* for the given tab entry. Caller takes ownership of
184 // the result and must delete it when finished. 196 // the result and must delete it when finished.
185 HistoryItem* HistoryItemForTab(const TabRestoreService::Tab& entry); 197 HistoryItem* HistoryItemForTab(const TabRestoreService::Tab& entry);
186 198
187 // Helper function that sends an async request to the FaviconService to get 199 // Helper function that sends an async request to the FaviconService to get
188 // an icon. The callback will update the NSMenuItem directly. 200 // an icon. The callback will update the NSMenuItem directly.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 bool create_in_progress_; 235 bool create_in_progress_;
224 bool need_recreate_; 236 bool need_recreate_;
225 237
226 // The default favicon if a HistoryItem does not have one. 238 // The default favicon if a HistoryItem does not have one.
227 base::scoped_nsobject<NSImage> default_favicon_; 239 base::scoped_nsobject<NSImage> default_favicon_;
228 240
229 DISALLOW_COPY_AND_ASSIGN(HistoryMenuBridge); 241 DISALLOW_COPY_AND_ASSIGN(HistoryMenuBridge);
230 }; 242 };
231 243
232 #endif // CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_ 244 #endif // CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_
OLDNEW
« no previous file with comments | « chrome/browser/sync/profile_sync_service_typed_url_unittest.cc ('k') | chrome/browser/ui/cocoa/history_menu_bridge.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698