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

Side by Side Diff: chrome/browser/ui/toolbar/action_box_menu_model.cc

Issue 10533086: Action box menu (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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) 2012 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/ui/toolbar/action_box_menu_model.h"
6
7 #include <algorithm>
8 #include <cmath>
9
10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/extensions/extension_toolbar_model.h"
12 #include "chrome/browser/extensions/extension_service.h"
13
14 ////////////////////////////////////////////////////////////////////////////////
15 // ActionBoxMenuModel
16
17 ActionBoxMenuModel::ActionBoxMenuModel(ExtensionService* extension_service)
18 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)),
19 extension_service_(extension_service) {
20 Build();
21 }
22
23 ActionBoxMenuModel::~ActionBoxMenuModel() {
24 }
25
26
27 void ActionBoxMenuModel::ExecuteCommand(int command_id) {
28 }
29
30 bool ActionBoxMenuModel::IsCommandIdChecked(int command_id) const {
31 return false;
32 }
33
34 bool ActionBoxMenuModel::IsCommandIdEnabled(int command_id) const {
35 return true;
36 }
37
38 bool ActionBoxMenuModel::IsCommandIdVisible(int command_id) const {
39 return true;
40 }
41
42 bool ActionBoxMenuModel::GetAcceleratorForCommandId(
43 int command_id,
44 ui::Accelerator* accelerator) {
45 return false;
46 }
47
48 void ActionBoxMenuModel::Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) {
51 }
52
53 size_t ActionBoxMenuModel::action_box_extensions_size() {
54 ExtensionToolbarModel* toolbar_model = extension_service_->toolbar_model();
55 return toolbar_model->action_box_extensions_size();
56 }
57
58 const extensions::Extension*
59 ActionBoxMenuModel::GetActionBoxExtensionByIndex(int index) {
60 ExtensionToolbarModel* toolbar_model = extension_service_->toolbar_model();
61 return toolbar_model->GetActionBoxExtensionByIndex(index);
62 }
63
64 void ActionBoxMenuModel::Build() {
65 int command_id = 1000;
66 size_t size = action_box_extensions_size();
67 for (size_t i = 0; i < size; ++i) {
68 const extensions::Extension* extension = GetActionBoxExtensionByIndex(i);
69 string16 label = UTF8ToUTF16(extension->name());
70 AddItem(command_id, label);
71 id_to_extension_id_[command_id++] = extension->id();
72 }
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698