| 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_GTK_GLOBAL_HISTORY_MENU_H_ | 5 #ifndef CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_ |
| 6 #define CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_ | 6 #define CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "chrome/browser/favicon/favicon_service.h" | 10 #include "chrome/browser/favicon/favicon_service.h" |
| 11 #include "chrome/browser/history/history_types.h" | 11 #include "chrome/browser/history/history_types.h" |
| 12 #include "chrome/browser/sessions/tab_restore_service.h" | 12 #include "chrome/browser/sessions/tab_restore_service.h" |
| 13 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 13 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 14 #include "chrome/browser/ui/gtk/global_menu_owner.h" |
| 15 #include "chrome/browser/ui/gtk/owned_widget_gtk.h" |
| 14 #include "content/browser/cancelable_request.h" | 16 #include "content/browser/cancelable_request.h" |
| 15 #include "content/common/notification_observer.h" | 17 #include "content/common/notification_observer.h" |
| 16 #include "content/common/notification_registrar.h" | 18 #include "content/common/notification_registrar.h" |
| 17 #include "ui/base/gtk/gtk_signal.h" | 19 #include "ui/base/gtk/gtk_signal.h" |
| 18 | 20 |
| 19 class Browser; | 21 class Browser; |
| 20 | 22 |
| 21 namespace history { | 23 namespace history { |
| 22 class TopSites; | 24 class TopSites; |
| 23 } | 25 } |
| 24 | 26 |
| 25 typedef struct _GdkPixbuf GdkPixbuf; | 27 typedef struct _GdkPixbuf GdkPixbuf; |
| 26 | 28 |
| 27 // Controls the History menu. | 29 // Controls the History menu. |
| 28 class GlobalHistoryMenu : public NotificationObserver, | 30 class GlobalHistoryMenu : public GlobalMenuOwner, |
| 31 public NotificationObserver, |
| 29 public TabRestoreServiceObserver { | 32 public TabRestoreServiceObserver { |
| 30 public: | 33 public: |
| 31 explicit GlobalHistoryMenu(Browser* browser); | 34 explicit GlobalHistoryMenu(Browser* browser); |
| 32 virtual ~GlobalHistoryMenu(); | 35 virtual ~GlobalHistoryMenu(); |
| 33 | 36 |
| 34 // Takes the history menu we need to modify based on the tab restore/most | 37 // Takes the history menu we need to modify based on the tab restore/most |
| 35 // visited state. | 38 // visited state. |
| 36 void Init(GtkWidget* history_menu); | 39 virtual void Init(GtkWidget* history_menu, GtkWidget* history_menu_item); |
| 37 | 40 |
| 38 private: | 41 private: |
| 39 class HistoryItem; | 42 class HistoryItem; |
| 40 struct ClearMenuClosure; | 43 struct ClearMenuClosure; |
| 41 struct GetIndexClosure; | 44 struct GetIndexClosure; |
| 42 | 45 |
| 43 typedef std::map<GtkWidget*, HistoryItem*> MenuItemToHistoryMap; | 46 typedef std::map<GtkWidget*, HistoryItem*> MenuItemToHistoryMap; |
| 44 | 47 |
| 45 // Sends a message off to History for data. | 48 // Sends a message off to History for data. |
| 46 void GetTopSitesData(); | 49 void GetTopSitesData(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 virtual void Observe(NotificationType type, | 96 virtual void Observe(NotificationType type, |
| 94 const NotificationSource& source, | 97 const NotificationSource& source, |
| 95 const NotificationDetails& details); | 98 const NotificationDetails& details); |
| 96 | 99 |
| 97 // For TabRestoreServiceObserver | 100 // For TabRestoreServiceObserver |
| 98 virtual void TabRestoreServiceChanged(TabRestoreService* service); | 101 virtual void TabRestoreServiceChanged(TabRestoreService* service); |
| 99 virtual void TabRestoreServiceDestroyed(TabRestoreService* service); | 102 virtual void TabRestoreServiceDestroyed(TabRestoreService* service); |
| 100 | 103 |
| 101 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnRecentlyClosedItemActivated); | 104 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnRecentlyClosedItemActivated); |
| 102 | 105 |
| 106 // Listen for the first menu show command so we can then connect to the |
| 107 // TabRestoreService. With how the global menus work, I'd prefer to register |
| 108 // with the TabRestoreService as soon as we're constructed, but this breaks |
| 109 // unit tests which test the service (because they force different |
| 110 // construction ordering while us connecting to the TabRestoreService loads |
| 111 // data now!) |
| 112 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnMenuActivate); |
| 113 |
| 103 Browser* browser_; | 114 Browser* browser_; |
| 104 Profile* profile_; | 115 Profile* profile_; |
| 105 | 116 |
| 117 // The history menu. We keep this since we need to rewrite parts of it |
| 118 // periodically. |
| 119 OwnedWidgetGtk history_menu_; |
| 120 |
| 106 history::TopSites* top_sites_; | 121 history::TopSites* top_sites_; |
| 107 CancelableRequestConsumer top_sites_consumer_; | 122 CancelableRequestConsumer top_sites_consumer_; |
| 108 | 123 |
| 109 NotificationRegistrar registrar_; | |
| 110 | |
| 111 GdkPixbuf* default_favicon_; | 124 GdkPixbuf* default_favicon_; |
| 112 | 125 |
| 113 // The history menu. We keep this since we need to rewrite parts of it | |
| 114 // periodically. | |
| 115 GtkWidget* history_menu_; | |
| 116 | |
| 117 TabRestoreService* tab_restore_service_; // weak | 126 TabRestoreService* tab_restore_service_; // weak |
| 118 | 127 |
| 119 // A mapping from GtkMenuItems to HistoryItems that maintain data. | 128 // A mapping from GtkMenuItems to HistoryItems that maintain data. |
| 120 MenuItemToHistoryMap menu_item_history_map_; | 129 MenuItemToHistoryMap menu_item_history_map_; |
| 121 | 130 |
| 122 // Maps HistoryItems to favicon request Handles. | 131 // Maps HistoryItems to favicon request Handles. |
| 123 CancelableRequestConsumerTSimple<HistoryItem*> favicon_consumer_; | 132 CancelableRequestConsumerTSimple<HistoryItem*> favicon_consumer_; |
| 133 |
| 134 NotificationRegistrar registrar_; |
| 124 }; | 135 }; |
| 125 | 136 |
| 126 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_ | 137 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_ |
| OLD | NEW |