Chromium Code Reviews| Index: chrome/browser/ui/toolbar/action_box_menu_model.cc |
| diff --git a/chrome/browser/ui/toolbar/action_box_menu_model.cc b/chrome/browser/ui/toolbar/action_box_menu_model.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..2642d885553f5886c474dbdc6befd3a8b9e89c89 |
| --- /dev/null |
| +++ b/chrome/browser/ui/toolbar/action_box_menu_model.cc |
| @@ -0,0 +1,64 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/toolbar/action_box_menu_model.h" |
| + |
| +#include "base/utf_string_conversions.h" |
| +#include "chrome/browser/extensions/extension_toolbar_model.h" |
| +#include "chrome/browser/extensions/extension_service.h" |
| + |
| +static const int kFirstExtensionCommandId = 1000; |
|
Peter Kasting
2012/07/18 01:37:25
Nit: Comment on whether and how this interacts wit
yefimt
2012/07/18 23:18:13
Done.
|
| + |
| +//////////////////////////////////////////////////////////////////////////////// |
| +// ActionBoxMenuModel |
| + |
| +ActionBoxMenuModel::ActionBoxMenuModel(ExtensionService* extension_service) |
| + : ALLOW_THIS_IN_INITIALIZER_LIST(ui::SimpleMenuModel(this)), |
| + extension_service_(extension_service) { |
| + Build(); |
| +} |
| + |
| +ActionBoxMenuModel::~ActionBoxMenuModel() { |
| +} |
| + |
| +void ActionBoxMenuModel::ExecuteCommand(int command_id) { |
| +} |
| + |
| +bool ActionBoxMenuModel::IsCommandIdChecked(int command_id) const { |
| + return false; |
| +} |
| + |
| +bool ActionBoxMenuModel::IsCommandIdEnabled(int command_id) const { |
| + return true; |
| +} |
| + |
| +bool ActionBoxMenuModel::GetAcceleratorForCommandId( |
| + int command_id, |
| + ui::Accelerator* accelerator) { |
| + return false; |
| +} |
| + |
| +void ActionBoxMenuModel::Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) { |
| +} |
| + |
| +size_t ActionBoxMenuModel::action_box_extensions_size() { |
| + return extension_service_->toolbar_model()->action_box_extensions_size(); |
| +} |
| + |
| +const extensions::Extension* |
| + ActionBoxMenuModel::GetActionBoxExtensionByIndex(int index) { |
| + return extension_service_->toolbar_model()-> |
| + GetActionBoxExtensionByIndex(index); |
| +} |
| + |
| +void ActionBoxMenuModel::Build() { |
| + int command_id = kFirstExtensionCommandId; |
| + for (size_t i = 0; i < action_box_extensions_size(); ++i) { |
| + const extensions::Extension* extension = GetActionBoxExtensionByIndex(i); |
| + AddItem(command_id, UTF8ToUTF16(extension->name())); |
| + id_to_extension_id_[command_id++] = extension->id(); |
| + } |
| +} |