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

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

Issue 6840068: GTK: Add Recently Closed tabs to the History menu in the global menu bar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Maybe abandoning this way 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_
6 #define CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_
7
8 #include <map>
9
10 #include "content/browser/cancelable_request.h"
11 #include "chrome/browser/favicon_service.h"
12 #include "chrome/browser/sessions/tab_restore_service.h"
13 #include "chrome/browser/sessions/tab_restore_service_observer.h"
14 #include "content/common/notification_observer.h"
15 #include "content/common/notification_registrar.h"
16 #include "ui/base/gtk/gtk_signal.h"
17
18 class Browser;
19 typedef struct _GdkPixbuf GdkPixbuf;
20
21 // Controls the History menu.
22 class GlobalHistoryMenu : public NotificationObserver,
23 public TabRestoreServiceObserver {
24 public:
25 explicit GlobalHistoryMenu(Browser* browser);
26 virtual ~GlobalHistoryMenu();
27
28 // Takes the history menu we need to modify based on the tab restore/most
29 // visited state.
30 void Init(GtkWidget* history_menu);
31
32 private:
33 class HistoryItem;
34 struct ClearMenuClosure;
35 struct GetIndexClosure;
36
37 typedef std::map<GtkWidget*, HistoryItem*> MenuItemToHistoryMap;
38
39 // Returns the currently existing HistoryItem associated with
40 // |menu_item|. Can return NULL.
41 HistoryItem* HistoryItemForMenuItem(GtkWidget* menu_item);
42
43 // Returns whether there's a valid HistoryItem representation of |entry|.
44 bool HasValidHistoryItemForTab(const TabRestoreService::Tab& entry);
45
46 // Creates a HistoryItem from the data in |entry|.
47 HistoryItem* HistoryItemForTab(const TabRestoreService::Tab& entry);
48
49 // Creates a menu item form |item| and inserts it in |menu| at |index|.
50 GtkWidget* AddHistoryItemToMenu(HistoryItem* item,
51 GtkWidget* menu,
52 int tag,
53 int index);
54
55 // Requests a FavIcon; we'll receive the data in the future through the
56 // GotFaviconData() callback.
57 void GetFaviconForHistoryItem(HistoryItem* item);
58
59 // Callback for GetFaviconForHistoryItem().
60 void GotFaviconData(FaviconService::Handle handle,
61 history::FaviconData favicon);
62
63 // Cancels an outstanding favicon request.
64 void CancelFaviconRequest(HistoryItem* item);
65
66 // Find the first index of the item in |menu| with the tag |tag_id|.
67 int GetIndexOfMenuItemWithTag(GtkWidget* menu, int tag_id);
68
69 // This will remove all menu items in |menu| with |tag| as their tag. This
70 // clears state about HistoryItems* that we keep to prevent that data from
71 // going stale. That's why this method recurses into its child menus.
72 void ClearMenuSection(GtkWidget* menu, int tag);
73
74 // Implementation detail of GetIndexOfMenuItemWithTag.
75 static void GetIndexCallback(GtkWidget* widget, GetIndexClosure* closure);
76
77 // Implementation detail of ClearMenuSection.
78 static void ClearMenuCallback(GtkWidget* widget, ClearMenuClosure* closure);
79
80 // NotificationObserver:
81 virtual void Observe(NotificationType type,
82 const NotificationSource& source,
83 const NotificationDetails& details);
84
85 // For TabRestoreServiceObserver
86 virtual void TabRestoreServiceChanged(TabRestoreService* service);
87 virtual void TabRestoreServiceDestroyed(TabRestoreService* service);
88
89 CHROMEGTK_CALLBACK_0(GlobalHistoryMenu, void, OnRecentlyClosedItemActivated);
90
91 Browser* browser_;
92 Profile* profile_;
93
94 NotificationRegistrar registrar_;
95
96 GdkPixbuf* default_favicon_;
97
98 // The history menu. We keep this since we need to rewrite parts of it
99 // periodically.
100 GtkWidget* history_menu_;
101
102 TabRestoreService* tab_restore_service_; // weak
103
104 // A mapping from GtkMenuItems to HistoryItems that maintain data.
105 MenuItemToHistoryMap menu_item_history_map_;
106
107 // Maps HistoryItems to favicon request Handles.
108 CancelableRequestConsumerTSimple<HistoryItem*> favicon_consumer_;
109 };
110
111 #endif // CHROME_BROWSER_UI_GTK_GLOBAL_HISTORY_MENU_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698