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

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

Issue 573553004: Eliminate NOTIFICATION_HISTORY_LOADED notification (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 143
142 // Looks up an NSMenuItem in the |menu_item_map_| and returns the 144 // Looks up an NSMenuItem in the |menu_item_map_| and returns the
143 // corresponding HistoryItem. 145 // corresponding HistoryItem.
144 HistoryItem* HistoryItemForMenuItem(NSMenuItem* item); 146 HistoryItem* HistoryItemForMenuItem(NSMenuItem* item);
145 147
146 // I wish I has a "friend @class" construct. These are used by the HMCC 148 // I wish I has a "friend @class" construct. These are used by the HMCC
147 // to access model information when responding to actions. 149 // to access model information when responding to actions.
148 HistoryService* service(); 150 HistoryService* service();
149 Profile* profile(); 151 Profile* profile();
150 152
153 // Is called when |service| is loaded.
sdefresne 2014/10/20 13:15:42 // history::HistoryServiceObserver:
nshaik 2014/10/29 08:43:39 Done.
154 virtual void HistoryServiceLoaded(HistoryService* service) OVERRIDE;
sdefresne 2014/10/20 13:15:42 OVERRIDE -> override
nshaik 2014/10/29 08:43:39 Done.
155
151 protected: 156 protected:
152 // Return the History menu. 157 // Return the History menu.
153 virtual NSMenu* HistoryMenu(); 158 virtual NSMenu* HistoryMenu();
154 159
155 // Clear items in the given |menu|. Menu items in the same section are given 160 // Clear items in the given |menu|. Menu items in the same section are given
156 // the same tag. This will go through the entire history menu, removing all 161 // the same tag. This will go through the entire history menu, removing all
157 // items with a given tag. Note that this will recurse to submenus, removing 162 // items with a given tag. Note that this will recurse to submenus, removing
158 // child items from the menu item map. This will only remove items that have 163 // child items from the menu item map. This will only remove items that have
159 // a target hooked up to the |controller_|. 164 // a target hooked up to the |controller_|.
160 void ClearMenuSection(NSMenu* menu, NSInteger tag); 165 void ClearMenuSection(NSMenu* menu, NSInteger tag);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 bool create_in_progress_; 228 bool create_in_progress_;
224 bool need_recreate_; 229 bool need_recreate_;
225 230
226 // The default favicon if a HistoryItem does not have one. 231 // The default favicon if a HistoryItem does not have one.
227 base::scoped_nsobject<NSImage> default_favicon_; 232 base::scoped_nsobject<NSImage> default_favicon_;
228 233
229 DISALLOW_COPY_AND_ASSIGN(HistoryMenuBridge); 234 DISALLOW_COPY_AND_ASSIGN(HistoryMenuBridge);
230 }; 235 };
231 236
232 #endif // CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_ 237 #endif // CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698