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

Unified Diff: chrome/browser/ui/views/wrench_menu.cc

Issue 11298004: alternate ntp: add "Recent Tabs" submenu to wrench menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased to resolve conflicts Created 8 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/wrench_menu.cc
diff --git a/chrome/browser/ui/views/wrench_menu.cc b/chrome/browser/ui/views/wrench_menu.cc
index 2a28fad338533f3256138076c0ef595d63d63e2b..3b83b0007c9ae0278afb6e96bec0a142481a0dc4 100644
--- a/chrome/browser/ui/views/wrench_menu.cc
+++ b/chrome/browser/ui/views/wrench_menu.cc
@@ -706,6 +706,43 @@ class WrenchMenu::ZoomView : public WrenchMenuView,
DISALLOW_COPY_AND_ASSIGN(ZoomView);
};
+// RecentTabsMenuModelDelegate -------------------------------------------------
+
+// Provides the ui::MenuModelDelegate implementation for RecentTabsSubMenuModel
+// items.
+class WrenchMenu::RecentTabsMenuModelDelegate : public ui::MenuModelDelegate {
+ public:
+ RecentTabsMenuModelDelegate(ui::MenuModel* model,
+ views::MenuItemView* menu_item)
+ : model_(model),
+ menu_item_(menu_item) {
+ model_->SetMenuModelDelegate(this);
+ }
+
+ virtual ~RecentTabsMenuModelDelegate() {
+ model_->SetMenuModelDelegate(NULL);
+ }
+
+ // ui::MenuModelDelegate implementation:
+ virtual void OnIconChanged(int index) OVERRIDE {
+ // |index| specifies position in children items of |menu_item_| starting at
+ // 0, its corresponding command id as used in the children menu item views
+ // follows that of the parent menu item view |menu_item_|.
+ int command_id = menu_item_->GetCommand() + 1 + index;
+ views::MenuItemView* item = menu_item_->GetMenuItemByID(command_id);
+ DCHECK(item);
+ gfx::Image icon;
+ if (model_->GetIconAt(index, &icon))
+ item->SetIcon(*icon.ToImageSkia());
+ }
+
+ private:
+ ui::MenuModel* model_;
+ views::MenuItemView* menu_item_;
+
+ DISALLOW_COPY_AND_ASSIGN(RecentTabsMenuModelDelegate);
+};
+
// WrenchMenu ------------------------------------------------------------------
WrenchMenu::WrenchMenu(Browser* browser,
@@ -900,7 +937,7 @@ void WrenchMenu::ExecuteCommand(int id, int mouse_event_flags) {
return;
}
- return entry.first->ActivatedAt(entry.second);
+ return entry.first->ActivatedAt(entry.second, mouse_event_flags);
}
bool WrenchMenu::GetAccelerator(int id, ui::Accelerator* accelerator) {
@@ -953,7 +990,6 @@ void WrenchMenu::BookmarkModelChanged() {
root_->Cancel();
}
-
void WrenchMenu::Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
@@ -1022,6 +1058,15 @@ void WrenchMenu::PopulateMenu(MenuItemView* parent,
feedback_menu_item_ = item;
break;
+ case IDC_RECENT_TABS_MENU:
+ DCHECK(chrome::search::IsInstantExtendedAPIEnabled(
+ browser_->profile()));
+ DCHECK(!recent_tabs_menu_model_delegate_.get());
+ recent_tabs_menu_model_delegate_.reset(
+ new RecentTabsMenuModelDelegate(model->GetSubmenuModelAt(index),
+ item));
+ break;
+
default:
break;
}
« no previous file with comments | « chrome/browser/ui/views/wrench_menu.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698