OLD | NEW |
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/scoped_observer.h" |
14 #include "base/task/cancelable_task_tracker.h" | 15 #include "base/task/cancelable_task_tracker.h" |
15 #import "chrome/browser/favicon/favicon_service.h" | 16 #import "chrome/browser/favicon/favicon_service.h" |
16 #include "chrome/browser/history/history_service.h" | 17 #include "chrome/browser/history/history_service.h" |
17 #include "chrome/browser/sessions/tab_restore_service.h" | 18 #include "chrome/browser/sessions/tab_restore_service.h" |
18 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 19 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
19 #import "chrome/browser/ui/cocoa/main_menu_item.h" | 20 #import "chrome/browser/ui/cocoa/main_menu_item.h" |
20 #include "components/history/core/browser/history_service_observer.h" | 21 #include "components/history/core/browser/history_service_observer.h" |
21 #include "components/sessions/session_id.h" | 22 #include "components/sessions/session_id.h" |
22 #include "content/public/browser/notification_observer.h" | 23 #include "content/public/browser/notification_observer.h" |
23 | 24 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 void BuildMenu() override; | 143 void BuildMenu() override; |
143 | 144 |
144 // history::HistoryServiceObserver: | 145 // history::HistoryServiceObserver: |
145 void OnURLVisited(HistoryService* history_service, | 146 void OnURLVisited(HistoryService* history_service, |
146 ui::PageTransition transition, | 147 ui::PageTransition transition, |
147 const history::URLRow& row, | 148 const history::URLRow& row, |
148 const history::RedirectList& redirects, | 149 const history::RedirectList& redirects, |
149 base::Time visit_time) override; | 150 base::Time visit_time) override; |
150 void OnURLsModified(HistoryService* history_service, | 151 void OnURLsModified(HistoryService* history_service, |
151 const history::URLRows& changed_urls) override; | 152 const history::URLRows& changed_urls) override; |
| 153 void OnHistoryServiceLoaded(HistoryService* service) override; |
152 | 154 |
153 // Looks up an NSMenuItem in the |menu_item_map_| and returns the | 155 // Looks up an NSMenuItem in the |menu_item_map_| and returns the |
154 // corresponding HistoryItem. | 156 // corresponding HistoryItem. |
155 HistoryItem* HistoryItemForMenuItem(NSMenuItem* item); | 157 HistoryItem* HistoryItemForMenuItem(NSMenuItem* item); |
156 | 158 |
157 // I wish I has a "friend @class" construct. These are used by the HMCC | 159 // I wish I has a "friend @class" construct. These are used by the HMCC |
158 // to access model information when responding to actions. | 160 // to access model information when responding to actions. |
159 HistoryService* service(); | 161 HistoryService* service(); |
160 Profile* profile(); | 162 Profile* profile(); |
161 | 163 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 // Requests to re-create the menu are coalesced. |create_in_progress_| is true | 235 // Requests to re-create the menu are coalesced. |create_in_progress_| is true |
234 // when either waiting for the history service to return query results, or | 236 // when either waiting for the history service to return query results, or |
235 // when the menu is rebuilding. |need_recreate_| is true whenever a rebuild | 237 // when the menu is rebuilding. |need_recreate_| is true whenever a rebuild |
236 // has been scheduled but is waiting for the current one to finish. | 238 // has been scheduled but is waiting for the current one to finish. |
237 bool create_in_progress_; | 239 bool create_in_progress_; |
238 bool need_recreate_; | 240 bool need_recreate_; |
239 | 241 |
240 // The default favicon if a HistoryItem does not have one. | 242 // The default favicon if a HistoryItem does not have one. |
241 base::scoped_nsobject<NSImage> default_favicon_; | 243 base::scoped_nsobject<NSImage> default_favicon_; |
242 | 244 |
| 245 ScopedObserver<HistoryService, HistoryServiceObserver> |
| 246 history_service_observer_; |
| 247 |
243 DISALLOW_COPY_AND_ASSIGN(HistoryMenuBridge); | 248 DISALLOW_COPY_AND_ASSIGN(HistoryMenuBridge); |
244 }; | 249 }; |
245 | 250 |
246 #endif // CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_ | 251 #endif // CHROME_BROWSER_UI_COCOA_HISTORY_MENU_BRIDGE_H_ |
OLD | NEW |