| 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 "base/compiler_specific.h" |
| 10 #include "chrome/browser/history/history_types.h" | 11 #include "chrome/browser/history/history_types.h" |
| 11 #include "chrome/browser/sessions/tab_restore_service.h" | 12 #include "chrome/browser/sessions/tab_restore_service.h" |
| 12 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 13 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 13 #include "chrome/browser/ui/gtk/global_menu_owner.h" | 14 #include "chrome/browser/ui/gtk/global_menu_owner.h" |
| 14 #include "content/browser/cancelable_request.h" | 15 #include "content/browser/cancelable_request.h" |
| 15 #include "content/public/browser/notification_observer.h" | 16 #include "content/public/browser/notification_observer.h" |
| 16 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
| 17 #include "ui/base/gtk/gtk_signal.h" | 18 #include "ui/base/gtk/gtk_signal.h" |
| 18 #include "ui/base/gtk/owned_widget_gtk.h" | 19 #include "ui/base/gtk/owned_widget_gtk.h" |
| 19 | 20 |
| 20 class Browser; | 21 class Browser; |
| 21 | 22 |
| 22 namespace history { | 23 namespace history { |
| 23 class TopSites; | 24 class TopSites; |
| 24 } | 25 } |
| 25 | 26 |
| 26 typedef struct _GdkPixbuf GdkPixbuf; | 27 typedef struct _GdkPixbuf GdkPixbuf; |
| 27 | 28 |
| 28 // Controls the History menu. | 29 // Controls the History menu. |
| 29 class GlobalHistoryMenu : public GlobalMenuOwner, | 30 class GlobalHistoryMenu : public GlobalMenuOwner, |
| 30 public content::NotificationObserver, | 31 public content::NotificationObserver, |
| 31 public TabRestoreServiceObserver { | 32 public TabRestoreServiceObserver { |
| 32 public: | 33 public: |
| 33 explicit GlobalHistoryMenu(Browser* browser); | 34 explicit GlobalHistoryMenu(Browser* browser); |
| 34 virtual ~GlobalHistoryMenu(); | 35 virtual ~GlobalHistoryMenu(); |
| 35 | 36 |
| 36 // 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 |
| 37 // visited state. | 38 // visited state. |
| 38 virtual void Init(GtkWidget* history_menu, GtkWidget* history_menu_item); | 39 virtual void Init(GtkWidget* history_menu, |
| 40 GtkWidget* history_menu_item) OVERRIDE; |
| 39 | 41 |
| 40 private: | 42 private: |
| 41 class HistoryItem; | 43 class HistoryItem; |
| 42 struct ClearMenuClosure; | 44 struct ClearMenuClosure; |
| 43 struct GetIndexClosure; | 45 struct GetIndexClosure; |
| 44 | 46 |
| 45 typedef std::map<GtkWidget*, HistoryItem*> MenuItemToHistoryMap; | 47 typedef std::map<GtkWidget*, HistoryItem*> MenuItemToHistoryMap; |
| 46 | 48 |
| 47 // Sends a message off to History for data. | 49 // Sends a message off to History for data. |
| 48 void GetTopSitesData(); | 50 void GetTopSitesData(); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 76 | 78 |
| 77 // Implementation detail of GetIndexOfMenuItemWithTag. | 79 // Implementation detail of GetIndexOfMenuItemWithTag. |
| 78 static void GetIndexCallback(GtkWidget* widget, GetIndexClosure* closure); | 80 static void GetIndexCallback(GtkWidget* widget, GetIndexClosure* closure); |
| 79 | 81 |
| 80 // Implementation detail of ClearMenuSection. | 82 // Implementation detail of ClearMenuSection. |
| 81 static void ClearMenuCallback(GtkWidget* widget, ClearMenuClosure* closure); | 83 static void ClearMenuCallback(GtkWidget* widget, ClearMenuClosure* closure); |
| 82 | 84 |
| 83 // content::NotificationObserver: | 85 // content::NotificationObserver: |
| 84 virtual void Observe(int type, | 86 virtual void Observe(int type, |
| 85 const content::NotificationSource& source, | 87 const content::NotificationSource& source, |
| 86 const content::NotificationDetails& details); | 88 const content::NotificationDetails& details) OVERRIDE; |
| 87 | 89 |
| 88 // For TabRestoreServiceObserver | 90 // For TabRestoreServiceObserver |
| 89 virtual void TabRestoreServiceChanged(TabRestoreService* service); | 91 virtual void TabRestoreServiceChanged(TabRestoreService* service) OVERRIDE; |
| 90 virtual void TabRestoreServiceDestroyed(TabRestoreService* service); | 92 virtual void TabRestoreServiceDestroyed(TabRestoreService* service) OVERRIDE; |
| 91 | 93 |
| 92 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnRecentlyClosedItemActivated); | 94 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnRecentlyClosedItemActivated); |
| 93 | 95 |
| 94 // Listen for the first menu show command so we can then connect to the | 96 // Listen for the first menu show command so we can then connect to the |
| 95 // TabRestoreService. With how the global menus work, I'd prefer to register | 97 // TabRestoreService. With how the global menus work, I'd prefer to register |
| 96 // with the TabRestoreService as soon as we're constructed, but this breaks | 98 // with the TabRestoreService as soon as we're constructed, but this breaks |
| 97 // unit tests which test the service (because they force different | 99 // unit tests which test the service (because they force different |
| 98 // construction ordering while us connecting to the TabRestoreService loads | 100 // construction ordering while us connecting to the TabRestoreService loads |
| 99 // data now!) | 101 // data now!) |
| 100 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnMenuActivate); | 102 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnMenuActivate); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 | 113 |
| 112 TabRestoreService* tab_restore_service_; // weak | 114 TabRestoreService* tab_restore_service_; // weak |
| 113 | 115 |
| 114 // A mapping from GtkMenuItems to HistoryItems that maintain data. | 116 // A mapping from GtkMenuItems to HistoryItems that maintain data. |
| 115 MenuItemToHistoryMap menu_item_history_map_; | 117 MenuItemToHistoryMap menu_item_history_map_; |
| 116 | 118 |
| 117 content::NotificationRegistrar registrar_; | 119 content::NotificationRegistrar registrar_; |
| 118 }; | 120 }; |
| 119 | 121 |
| 120 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_ | 122 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_ |
| OLD | NEW |