Disable TabDragController tests that fail with a real compositor.
[chromium-blink-merge.git] / chrome / browser / ui / ash / launcher / launcher_application_menu_item_model.cc
blob46824f437cfc3e06965a0f4650f8d03b77e30a0d
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.
5 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h"
7 #include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
9 LauncherApplicationMenuItemModel::LauncherApplicationMenuItemModel(
10 ChromeLauncherAppMenuItems item_list)
11 : ash::ShelfMenuModel(this),
12 launcher_items_(item_list.Pass()) {
13 Build();
16 LauncherApplicationMenuItemModel::~LauncherApplicationMenuItemModel() {
19 bool LauncherApplicationMenuItemModel::IsCommandActive(int command_id) const {
20 DCHECK(command_id >= 0);
21 DCHECK(static_cast<size_t>(command_id) < launcher_items_.size());
22 return launcher_items_[command_id]->IsActive();
25 bool LauncherApplicationMenuItemModel::IsCommandIdChecked(
26 int command_id) const {
27 return false;
30 bool LauncherApplicationMenuItemModel::IsCommandIdEnabled(
31 int command_id) const {
32 DCHECK(command_id < static_cast<int>(launcher_items_.size()));
33 return launcher_items_[command_id]->IsEnabled();
36 bool LauncherApplicationMenuItemModel::GetAcceleratorForCommandId(
37 int command_id,
38 ui::Accelerator* accelerator) {
39 return false;
42 void LauncherApplicationMenuItemModel::ExecuteCommand(int command_id,
43 int event_flags) {
44 DCHECK(command_id < static_cast<int>(launcher_items_.size()));
45 launcher_items_[command_id]->Execute(event_flags);
48 void LauncherApplicationMenuItemModel::Build() {
49 AddSeparator(ui::SPACING_SEPARATOR);
50 for (size_t i = 0; i < launcher_items_.size(); i++) {
51 ChromeLauncherAppMenuItem* item = launcher_items_[i];
53 // Check for a separator requirement in front of this item.
54 if (item->HasLeadingSeparator())
55 AddSeparator(ui::SPACING_SEPARATOR);
57 // The first item is the context menu, the others are the running apps.
58 AddItem(i, item->title());
60 if (!item->icon().IsEmpty())
61 SetIcon(GetIndexOfCommandId(i), item->icon());
63 RemoveTrailingSeparators();
65 // Adding final spacing (if the menu is not empty) to conform the menu to our
66 // style.
67 if (launcher_items_.size())
68 AddSeparator(ui::SPACING_SEPARATOR);