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

Side by Side Diff: chrome/browser/back_forward_menu_model_views.cc

Issue 501168: Make back forward menu model a MenuModel.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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
(Empty)
1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/back_forward_menu_model_views.h"
6
7 #include "app/menus/menu_model.h"
8 #include "chrome/app/chrome_dll_resource.h"
9 #include "chrome/browser/browser.h"
10 #include "chrome/browser/metrics/user_metrics.h"
11 #include "third_party/skia/include/core/SkBitmap.h"
12 #include "views/controls/menu/menu_2.h"
13 #include "views/widget/widget.h"
14
15 ////////////////////////////////////////////////////////////////////////////////
16 // BackForwardMenuModelViews, public:
17
18 BackForwardMenuModelViews::BackForwardMenuModelViews(Browser* browser,
19 ModelType model_type,
20 views::Widget* frame)
21 : BackForwardMenuModel(browser, model_type),
22 frame_(frame) {
23 }
24
25 ////////////////////////////////////////////////////////////////////////////////
26 // BackForwardMenuModelViews, menus::MenuModel implementation:
27
28 bool BackForwardMenuModelViews::HasIcons() const {
29 return true;
30 }
31
32 int BackForwardMenuModelViews::GetItemCount() const {
33 return GetTotalItemCount();
34 }
35
36 menus::MenuModel::ItemType BackForwardMenuModelViews::GetTypeAt(
37 int index) const {
38 if (IsSeparator(GetCommandIdAt(index)))
39 return menus::MenuModel::TYPE_SEPARATOR;
40 return menus::MenuModel::TYPE_COMMAND;
41 }
42
43 int BackForwardMenuModelViews::GetCommandIdAt(int index) const {
44 return index + 1;
45 }
46
47 string16 BackForwardMenuModelViews::GetLabelAt(int index) const {
48 return GetItemLabel(GetCommandIdAt(index));
49 }
50
51 bool BackForwardMenuModelViews::IsLabelDynamicAt(int index) const {
52 return false;
53 }
54
55 bool BackForwardMenuModelViews::GetAcceleratorAt(
56 int index,
57 menus::Accelerator* accelerator) const {
58 // Look up the history accelerator.
59 if (GetCommandIdAt(index) == GetTotalItemCount())
60 return frame_->GetAccelerator(IDC_SHOW_HISTORY, accelerator);
61 return false;
62 }
63
64 bool BackForwardMenuModelViews::IsItemCheckedAt(int index) const {
65 return false;
66 }
67
68 int BackForwardMenuModelViews::GetGroupIdAt(int index) const {
69 return -1;
70 }
71
72 bool BackForwardMenuModelViews::GetIconAt(int index, SkBitmap* icon) const {
73 if (ItemHasIcon(GetCommandIdAt(index))) {
74 *icon = GetItemIcon(GetCommandIdAt(index));
75 return true;
76 }
77 return false;
78 }
79
80 bool BackForwardMenuModelViews::IsEnabledAt(int index) const {
81 return true;
82 }
83
84 menus::MenuModel* BackForwardMenuModelViews::GetSubmenuModelAt(
85 int index) const {
86 return NULL;
87 }
88
89 void BackForwardMenuModelViews::HighlightChangedTo(int index) {
90 }
91
92 void BackForwardMenuModelViews::ActivatedAt(int index) {
93 ExecuteCommandById(GetCommandIdAt(index));
94 }
95
96 void BackForwardMenuModelViews::MenuWillShow() {
97 UserMetrics::RecordComputedAction(BuildActionName("Popup", -1),
98 browser_->profile());
99 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698