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

Unified 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 10 years 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/back_forward_menu_model.h
===================================================================
--- chrome/browser/ui/toolbar/back_forward_menu_model.h (revision 70178)
+++ chrome/browser/ui/toolbar/back_forward_menu_model.h (working copy)
@@ -6,12 +6,14 @@
#define CHROME_BROWSER_UI_TOOLBAR_BACK_FORWARD_MENU_MODEL_H_
#pragma once
+#include <set>
#include <string>
#include "app/menus/menu_model.h"
#include "base/basictypes.h"
#include "base/gtest_prod_util.h"
#include "base/string16.h"
+#include "chrome/browser/favicon_service.h"
#include "webkit/glue/window_open_disposition.h"
class Browser;
@@ -53,7 +55,7 @@
menus::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 menus::ButtonMenuItemModel* GetButtonMenuItemAt(int index) const;
virtual bool IsEnabledAt(int index) const;
virtual MenuModel* GetSubmenuModelAt(int index) const;
@@ -65,7 +67,19 @@
// 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 for the favicon service.
sky 2011/01/04 21:51:15 for -> from
+ 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;
@@ -78,7 +92,7 @@
// true (we are the forward button delegate), then this function will return
// the number of entries after 5. Note, though, that in either case it will
// not report more than kMaxHistoryItems. The number returned also does not
- // include the separator line after the history items (nor the separator for
+ // include he separator line after the history items (nor the separator for
// the "Show Full History" link).
int GetHistoryItemCount() const;
@@ -160,11 +174,23 @@
// 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;
FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, BasicCase);
FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, MaxItemsTest);
FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelTest, ChapterStops);
+ friend class BackFwdMenuModelFaviconTest;
+ FRIEND_TEST_ALL_PREFIXES(BackFwdMenuModelFaviconTest, FaviconLoadTest);
+ // Used for loading favicons from history.
+ CancelableRequestConsumerTSimple<int> load_consumer_;
+
DISALLOW_COPY_AND_ASSIGN(BackForwardMenuModel);
};

Powered by Google App Engine
This is Rietveld 408576698