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

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: '' Created 9 years, 12 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 "app/menus/menu_model.h" 12 #include "app/menus/menu_model.h"
12 #include "base/basictypes.h" 13 #include "base/basictypes.h"
13 #include "base/gtest_prod_util.h" 14 #include "base/gtest_prod_util.h"
14 #include "base/string16.h" 15 #include "base/string16.h"
16 #include "chrome/browser/favicon_service.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 //
24 // BackForwardMenuModel 26 // BackForwardMenuModel
(...skipping 21 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 menus::Accelerator* accelerator) const; 55 menus::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 menus::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const; 59 virtual menus::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 for the favicon service.
sky 2011/01/04 21:51:15 for -> from
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
79 // the number of entries after 5. Note, though, that in either case it will 93 // the number of entries after 5. Note, though, that in either case it will
80 // not report more than kMaxHistoryItems. The number returned also does not 94 // not report more than kMaxHistoryItems. The number returned also does not
81 // include the separator line after the history items (nor the separator for 95 // include he separator line after the history items (nor the separator for
82 // the "Show Full History" link). 96 // the "Show Full History" link).
83 int GetHistoryItemCount() const; 97 int GetHistoryItemCount() const;
84 98
85 // Returns how many chapter-stop items the menu should show. For the 99 // Returns how many chapter-stop items the menu should show. For the
86 // definition of a chapter-stop, see GetIndexOfNextChapterStop(). The number 100 // definition of a chapter-stop, see GetIndexOfNextChapterStop(). The number
87 // returned does not include the separator lines before and after the 101 // returned does not include the separator lines before and after the
88 // chapter-stops. 102 // chapter-stops.
89 int GetChapterStopCount(int history_items) const; 103 int GetChapterStopCount(int history_items) const;
90 104
91 // Finds the next chapter-stop in the NavigationEntryList starting from 105 // Finds the next chapter-stop in the NavigationEntryList starting from
(...skipping 61 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;
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 class BackFwdMenuModelFaviconTest;
189 FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelFaviconTest, FaviconLoadTest);
190
191 // Used for loading favicons from history.
192 CancelableRequestConsumerTSimple<int> load_consumer_;
167 193
168 DISALLOW_COPY_AND_ASSIGN(BackForwardMenuModel); 194 DISALLOW_COPY_AND_ASSIGN(BackForwardMenuModel);
169 }; 195 };
170 196
171 #endif // CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ 197 #endif // CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698