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 "base/utf_string_conversions.h" | |
8 #include "chrome/browser/extensions/extension_toolbar_model.h" | |
9 #include "chrome/browser/extensions/extension_service.h" | |
10 | |
11 // Arbitrary number just to leave enough space for menu ids | |
12 // that shown before extensions. | |
msw
2012/07/24 23:41:55
grammar nit: "that show"
yefimt
2012/07/25 21:09:21
Done.
| |
13 static const int kFirstExtensionCommandId = 1000; | |
14 | |
15 //////////////////////////////////////////////////////////////////////////////// | |
16 // ActionBoxMenuModel | |
17 | |
18 ActionBoxMenuModel::ActionBoxMenuModel(ExtensionService* extension_service) | |
19 : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), | |
20 extension_service_(extension_service) { | |
21 Build(); | |
22 } | |
23 | |
24 ActionBoxMenuModel::~ActionBoxMenuModel() { | |
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::GetAcceleratorForCommandId( | |
39 int command_id, | |
40 ui::Accelerator* accelerator) { | |
41 return false; | |
42 } | |
43 | |
44 void ActionBoxMenuModel::Observe(int type, | |
45 const content::NotificationSource& source, | |
46 const content::NotificationDetails& details) { | |
47 } | |
48 | |
49 size_t ActionBoxMenuModel::action_box_extensions_size() { | |
msw
2012/07/24 23:41:55
nit: definition order should match declaration ord
yefimt
2012/07/25 21:09:21
Done.
| |
50 return extension_service_->toolbar_model()->action_box_extensions_size(); | |
51 } | |
52 | |
53 const extensions::Extension* | |
54 ActionBoxMenuModel::GetActionBoxExtensionByIndex(int index) { | |
msw
2012/07/24 23:41:55
nit: definition order should match declaration ord
yefimt
2012/07/25 21:09:21
Done.
| |
55 return extension_service_->toolbar_model()-> | |
56 GetActionBoxExtensionByIndex(index); | |
57 } | |
58 | |
59 void ActionBoxMenuModel::Build() { | |
60 int command_id = kFirstExtensionCommandId; | |
61 for (size_t i = 0; i < action_box_extensions_size(); ++i) { | |
62 const extensions::Extension* extension = GetActionBoxExtensionByIndex(i); | |
63 AddItem(command_id, UTF8ToUTF16(extension->name())); | |
64 id_to_extension_id_[command_id++] = extension->id(); | |
65 } | |
66 } | |
OLD | NEW |