Chromium Code Reviews| Index: chrome/browser/ui/toolbar/back_forward_menu_model.h |
| diff --git a/chrome/browser/ui/toolbar/back_forward_menu_model.h b/chrome/browser/ui/toolbar/back_forward_menu_model.h |
| index d256f0c9e52a92cec549a4573d569f3a4102aa75..f325522dd19473db5eb635dab44a7f9eaafaaa7e 100644 |
| --- a/chrome/browser/ui/toolbar/back_forward_menu_model.h |
| +++ b/chrome/browser/ui/toolbar/back_forward_menu_model.h |
| @@ -6,11 +6,13 @@ |
| #define CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_ |
| #pragma once |
| +#include <set> |
| #include <string> |
| #include "base/basictypes.h" |
| #include "base/gtest_prod_util.h" |
| #include "base/string16.h" |
| +#include "chrome/browser/favicon_service.h" |
| #include "ui/base/models/menu_model.h" |
| #include "webkit/glue/window_open_disposition.h" |
| @@ -53,7 +55,7 @@ class BackForwardMenuModel : public ui::MenuModel { |
| ui::Accelerator* accelerator) const; |
| virtual bool IsItemCheckedAt(int index) const; |
| virtual int GetGroupIdAt(int index) const; |
| - virtual bool GetIconAt(int index, SkBitmap* icon) const; |
| + virtual bool GetIconAt(int index, SkBitmap* icon); |
| virtual ui::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const; |
| virtual bool IsEnabledAt(int index) const; |
| virtual MenuModel* GetSubmenuModelAt(int index) const; |
| @@ -65,7 +67,19 @@ class BackForwardMenuModel : public ui::MenuModel { |
| // Is the item at |index| a separator? |
| bool IsSeparator(int index) const; |
| + // Set the delegate for triggering OnIconChanged. |
| + virtual void SetDelegate(Delegate* delegate); |
| + |
| private: |
| + // Requests a favicon from the FaviconService. Called by GetIconAt if the |
| + // NavigationEntry has an invalid favicon. |
| + void FetchFavicon(NavigationEntry* entry, int index); |
| + // Callback from the favicon service. |
|
sky
2011/02/22 18:28:28
newline between 76 and 77.
|
| + void OnFavIconDataAvailable(FaviconService::Handle handle, |
| + bool know_favicon, |
| + scoped_refptr<RefCountedMemory> data, |
| + bool expired, |
| + GURL icon_url); |
| // Allows the unit test to use its own dummy tab contents. |
| void set_test_tab_contents(TabContents* test_tab_contents) { |
| test_tab_contents_ = test_tab_contents; |
| @@ -160,10 +174,21 @@ class BackForwardMenuModel : public ui::MenuModel { |
| // back button. |
| ModelType model_type_; |
| + // Keeps track of which favicons have already been requested from the history |
| + // to prevent duplicate requests, identified by NavigationEntry->unique_id(). |
| + std::set<int> requested_favicons_; |
| + |
| + // Delegate from menus::MenuModel so we can trigger OnIconChanged. |
| + Delegate* delegate_; |
| + |
| friend class BackFwdMenuModelTest; |
|
sky
2011/02/22 18:28:28
Move all the friends to right after private:
|
| FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, BasicCase); |
| FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, MaxItemsTest); |
| FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, ChapterStops); |
| + FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, FaviconLoadTest); |
| + |
| + // Used for loading favicons from history. |
| + CancelableRequestConsumerTSimple<int> load_consumer_; |
| DISALLOW_COPY_AND_ASSIGN(BackForwardMenuModel); |
| }; |