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

Side by Side Diff: chrome/browser/ui/toolbar/back_forward_menu_model.h

Issue 2928005: Retrieve favicons from history as NavigationEntries are converted from TabNav... Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: Updated to compile against trunk. Created 9 years, 10 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ 5 #ifndef CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_
6 #define CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ 6 #define CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_
7 #pragma once 7 #pragma once
8 8
9 #include <set>
9 #include <string> 10 #include <string>
10 11
11 #include "base/basictypes.h" 12 #include "base/basictypes.h"
12 #include "base/gtest_prod_util.h" 13 #include "base/gtest_prod_util.h"
13 #include "base/string16.h" 14 #include "base/string16.h"
15 #include "chrome/browser/favicon_service.h"
14 #include "ui/base/models/menu_model.h" 16 #include "ui/base/models/menu_model.h"
15 #include "webkit/glue/window_open_disposition.h" 17 #include "webkit/glue/window_open_disposition.h"
16 18
17 class Browser; 19 class Browser;
18 class SkBitmap; 20 class SkBitmap;
19 class TabContents; 21 class TabContents;
20 class NavigationEntry; 22 class NavigationEntry;
21 23
22 /////////////////////////////////////////////////////////////////////////////// 24 ///////////////////////////////////////////////////////////////////////////////
23 // 25 //
(...skipping 22 matching lines...) Expand all
46 // out the total number of items to show. 48 // out the total number of items to show.
47 virtual int GetItemCount() const; 49 virtual int GetItemCount() const;
48 virtual ItemType GetTypeAt(int index) const; 50 virtual ItemType GetTypeAt(int index) const;
49 virtual int GetCommandIdAt(int index) const; 51 virtual int GetCommandIdAt(int index) const;
50 virtual string16 GetLabelAt(int index) const; 52 virtual string16 GetLabelAt(int index) const;
51 virtual bool IsItemDynamicAt(int index) const; 53 virtual bool IsItemDynamicAt(int index) const;
52 virtual bool GetAcceleratorAt(int index, 54 virtual bool GetAcceleratorAt(int index,
53 ui::Accelerator* accelerator) const; 55 ui::Accelerator* accelerator) const;
54 virtual bool IsItemCheckedAt(int index) const; 56 virtual bool IsItemCheckedAt(int index) const;
55 virtual int GetGroupIdAt(int index) const; 57 virtual int GetGroupIdAt(int index) const;
56 virtual bool GetIconAt(int index, SkBitmap* icon) const; 58 virtual bool GetIconAt(int index, SkBitmap* icon);
57 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const; 59 virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const;
58 virtual bool IsEnabledAt(int index) const; 60 virtual bool IsEnabledAt(int index) const;
59 virtual MenuModel* GetSubmenuModelAt(int index) const; 61 virtual MenuModel* GetSubmenuModelAt(int index) const;
60 virtual void HighlightChangedTo(int index); 62 virtual void HighlightChangedTo(int index);
61 virtual void ActivatedAt(int index); 63 virtual void ActivatedAt(int index);
62 virtual void ActivatedAtWithDisposition(int index, int disposition); 64 virtual void ActivatedAtWithDisposition(int index, int disposition);
63 virtual void MenuWillShow(); 65 virtual void MenuWillShow();
64 66
65 // Is the item at |index| a separator? 67 // Is the item at |index| a separator?
66 bool IsSeparator(int index) const; 68 bool IsSeparator(int index) const;
67 69
70 // Set the delegate for triggering OnIconChanged.
71 virtual void SetDelegate(Delegate* delegate);
72
68 private: 73 private:
74 // Requests a favicon from the FaviconService. Called by GetIconAt if the
75 // NavigationEntry has an invalid favicon.
76 void FetchFavicon(NavigationEntry* entry, int index);
77 // Callback from the favicon service.
sky 2011/02/22 18:28:28 newline between 76 and 77.
78 void OnFavIconDataAvailable(FaviconService::Handle handle,
79 bool know_favicon,
80 scoped_refptr<RefCountedMemory> data,
81 bool expired,
82 GURL icon_url);
69 // Allows the unit test to use its own dummy tab contents. 83 // Allows the unit test to use its own dummy tab contents.
70 void set_test_tab_contents(TabContents* test_tab_contents) { 84 void set_test_tab_contents(TabContents* test_tab_contents) {
71 test_tab_contents_ = test_tab_contents; 85 test_tab_contents_ = test_tab_contents;
72 } 86 }
73 87
74 // Returns how many history items the menu should show. For example, if the 88 // Returns how many history items the menu should show. For example, if the
75 // navigation controller of the current tab has a current entry index of 5 and 89 // navigation controller of the current tab has a current entry index of 5 and
76 // forward_direction_ is false (we are the back button delegate) then this 90 // forward_direction_ is false (we are the back button delegate) then this
77 // function will return 5 (representing 0-4). If forward_direction_ is 91 // function will return 5 (representing 0-4). If forward_direction_ is
78 // true (we are the forward button delegate), then this function will return 92 // true (we are the forward button delegate), then this function will return
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 167
154 Browser* browser_; 168 Browser* browser_;
155 169
156 // The unit tests will provide their own TabContents to use. 170 // The unit tests will provide their own TabContents to use.
157 TabContents* test_tab_contents_; 171 TabContents* test_tab_contents_;
158 172
159 // Represents whether this is the delegate for the forward button or the 173 // Represents whether this is the delegate for the forward button or the
160 // back button. 174 // back button.
161 ModelType model_type_; 175 ModelType model_type_;
162 176
177 // Keeps track of which favicons have already been requested from the history
178 // to prevent duplicate requests, identified by NavigationEntry->unique_id().
179 std::set<int> requested_favicons_;
180
181 // Delegate from menus::MenuModel so we can trigger OnIconChanged.
182 Delegate* delegate_;
183
163 friend class BackFwdMenuModelTest; 184 friend class BackFwdMenuModelTest;
sky 2011/02/22 18:28:28 Move all the friends to right after private:
164 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, BasicCase); 185 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, BasicCase);
165 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, MaxItemsTest); 186 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, MaxItemsTest);
166 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, ChapterStops); 187 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, ChapterStops);
188 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, FaviconLoadTest);
189
190 // Used for loading favicons from history.
191 CancelableRequestConsumerTSimple<int> load_consumer_;
167 192
168 DISALLOW_COPY_AND_ASSIGN(BackForwardMenuModel); 193 DISALLOW_COPY_AND_ASSIGN(BackForwardMenuModel);
169 }; 194 };
170 195
171 #endif // CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ 196 #endif // CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698