OLD | NEW |
---|---|
(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> | |
Peter Kasting
2012/07/14 02:08:01
Nit: Why are either of these #includes necessary?
yefimt
2012/07/17 18:20:37
Done.
| |
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 void ActionBoxMenuModel::ExecuteCommand(int command_id) { | |
27 } | |
28 | |
29 bool ActionBoxMenuModel::IsCommandIdChecked(int command_id) const { | |
30 return false; | |
31 } | |
32 | |
33 bool ActionBoxMenuModel::IsCommandIdEnabled(int command_id) const { | |
34 return true; | |
35 } | |
36 | |
37 bool ActionBoxMenuModel::GetAcceleratorForCommandId( | |
38 int command_id, | |
39 ui::Accelerator* accelerator) { | |
40 return false; | |
41 } | |
42 | |
43 void ActionBoxMenuModel::Observe(int type, | |
44 const content::NotificationSource& source, | |
Peter Kasting
2012/07/14 02:08:01
Nit: Incorrect indenting
yefimt
2012/07/17 18:20:37
Done.
| |
45 const content::NotificationDetails& details) { | |
46 } | |
47 | |
48 size_t ActionBoxMenuModel::action_box_extensions_size() { | |
49 ExtensionToolbarModel* toolbar_model = extension_service_->toolbar_model(); | |
Peter Kasting
2012/07/14 02:08:01
Nit: Inline into next line (2 places)
yefimt
2012/07/17 18:20:37
Done.
| |
50 return toolbar_model->action_box_extensions_size(); | |
51 } | |
52 | |
53 const extensions::Extension* | |
54 ActionBoxMenuModel::GetActionBoxExtensionByIndex(int index) { | |
Peter Kasting
2012/07/14 02:08:01
Nit: Indent 4
yefimt
2012/07/17 18:20:37
Done.
| |
55 ExtensionToolbarModel* toolbar_model = extension_service_->toolbar_model(); | |
56 return toolbar_model->GetActionBoxExtensionByIndex(index); | |
57 } | |
58 | |
59 void ActionBoxMenuModel::Build() { | |
60 int command_id = 1000; | |
Peter Kasting
2012/07/14 02:08:01
Nit: What is this magic number?
yefimt
2012/07/17 18:20:37
Done.
| |
61 size_t size = action_box_extensions_size(); | |
Peter Kasting
2012/07/14 02:08:01
Nit: Inline into loop declaration
yefimt
2012/07/17 18:20:37
Done.
| |
62 for (size_t i = 0; i < size; ++i) { | |
63 const extensions::Extension* extension = GetActionBoxExtensionByIndex(i); | |
64 string16 label = UTF8ToUTF16(extension->name()); | |
Peter Kasting
2012/07/14 02:08:01
Nit: Inline into next line
yefimt
2012/07/17 18:20:37
Done.
| |
65 AddItem(command_id, label); | |
66 id_to_extension_id_[command_id++] = extension->id(); | |
67 } | |
68 } | |
OLD | NEW |