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

Side by Side Diff: chrome/browser/ui/gtk/global_history_menu.h

Issue 6901110: GTK: Query TopSites for the Most Visited pages and populate fill in the global History menu. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make TopSites broadcast its change notification on all blacklist/pinned url changes. Created 9 years, 8 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 | Annotate | Revision Log
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_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 "content/browser/cancelable_request.h"
11 #include "chrome/browser/favicon_service.h" 10 #include "chrome/browser/favicon_service.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 "content/browser/cancelable_request.h"
14 #include "content/common/notification_observer.h" 15 #include "content/common/notification_observer.h"
15 #include "content/common/notification_registrar.h" 16 #include "content/common/notification_registrar.h"
16 #include "ui/base/gtk/gtk_signal.h" 17 #include "ui/base/gtk/gtk_signal.h"
17 18
18 class Browser; 19 class Browser;
20
21 namespace history {
22 class TopSites;
23 }
24
19 typedef struct _GdkPixbuf GdkPixbuf; 25 typedef struct _GdkPixbuf GdkPixbuf;
20 26
21 // Controls the History menu. 27 // Controls the History menu.
22 class GlobalHistoryMenu : public NotificationObserver, 28 class GlobalHistoryMenu : public NotificationObserver,
23 public TabRestoreServiceObserver { 29 public TabRestoreServiceObserver {
24 public: 30 public:
25 explicit GlobalHistoryMenu(Browser* browser); 31 explicit GlobalHistoryMenu(Browser* browser);
26 virtual ~GlobalHistoryMenu(); 32 virtual ~GlobalHistoryMenu();
27 33
28 // Takes the history menu we need to modify based on the tab restore/most 34 // Takes the history menu we need to modify based on the tab restore/most
29 // visited state. 35 // visited state.
30 void Init(GtkWidget* history_menu); 36 void Init(GtkWidget* history_menu);
31 37
32 private: 38 private:
33 class HistoryItem; 39 class HistoryItem;
34 struct ClearMenuClosure; 40 struct ClearMenuClosure;
35 struct GetIndexClosure; 41 struct GetIndexClosure;
36 42
37 typedef std::map<GtkWidget*, HistoryItem*> MenuItemToHistoryMap; 43 typedef std::map<GtkWidget*, HistoryItem*> MenuItemToHistoryMap;
38 44
45 // Sends a message off to History for data.
46 void GetTopSitesData();
47
48 // Callback to receive data requested from GetTopSitesData().
49 void OnTopSitesReceived(const history::MostVisitedURLList& visited_list);
50
39 // Returns the currently existing HistoryItem associated with 51 // Returns the currently existing HistoryItem associated with
40 // |menu_item|. Can return NULL. 52 // |menu_item|. Can return NULL.
41 HistoryItem* HistoryItemForMenuItem(GtkWidget* menu_item); 53 HistoryItem* HistoryItemForMenuItem(GtkWidget* menu_item);
42 54
43 // Returns whether there's a valid HistoryItem representation of |entry|. 55 // Returns whether there's a valid HistoryItem representation of |entry|.
44 bool HasValidHistoryItemForTab(const TabRestoreService::Tab& entry); 56 bool HasValidHistoryItemForTab(const TabRestoreService::Tab& entry);
45 57
46 // Creates a HistoryItem from the data in |entry|. 58 // Creates a HistoryItem from the data in |entry|.
47 HistoryItem* HistoryItemForTab(const TabRestoreService::Tab& entry); 59 HistoryItem* HistoryItemForTab(const TabRestoreService::Tab& entry);
48 60
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 96
85 // For TabRestoreServiceObserver 97 // For TabRestoreServiceObserver
86 virtual void TabRestoreServiceChanged(TabRestoreService* service); 98 virtual void TabRestoreServiceChanged(TabRestoreService* service);
87 virtual void TabRestoreServiceDestroyed(TabRestoreService* service); 99 virtual void TabRestoreServiceDestroyed(TabRestoreService* service);
88 100
89 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnRecentlyClosedItemActivated); 101 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnRecentlyClosedItemActivated);
90 102
91 Browser* browser_; 103 Browser* browser_;
92 Profile* profile_; 104 Profile* profile_;
93 105
106 history::TopSites* top_sites_;
107 CancelableRequestConsumer top_sites_consumer_;
108
94 NotificationRegistrar registrar_; 109 NotificationRegistrar registrar_;
95 110
96 GdkPixbuf* default_favicon_; 111 GdkPixbuf* default_favicon_;
97 112
98 // The history menu. We keep this since we need to rewrite parts of it 113 // The history menu. We keep this since we need to rewrite parts of it
99 // periodically. 114 // periodically.
100 GtkWidget* history_menu_; 115 GtkWidget* history_menu_;
101 116
102 TabRestoreService* tab_restore_service_; // weak 117 TabRestoreService* tab_restore_service_; // weak
103 118
104 // A mapping from GtkMenuItems to HistoryItems that maintain data. 119 // A mapping from GtkMenuItems to HistoryItems that maintain data.
105 MenuItemToHistoryMap menu_item_history_map_; 120 MenuItemToHistoryMap menu_item_history_map_;
106 121
107 // Maps HistoryItems to favicon request Handles. 122 // Maps HistoryItems to favicon request Handles.
108 CancelableRequestConsumerTSimple<HistoryItem*> favicon_consumer_; 123 CancelableRequestConsumerTSimple<HistoryItem*> favicon_consumer_;
109 }; 124 };
110 125
111 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_ 126 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698