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

Unified Diff: ash/common/shelf/shelf_application_menu_model.cc

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: ash/common/shelf/shelf_application_menu_model.cc
diff --git a/ash/common/shelf/shelf_application_menu_model.cc b/ash/common/shelf/shelf_application_menu_model.cc
deleted file mode 100644
index 7bf323c12a0339ab022042ad67fa87ca8154c64f..0000000000000000000000000000000000000000
--- a/ash/common/shelf/shelf_application_menu_model.cc
+++ /dev/null
@@ -1,73 +0,0 @@
-// Copyright 2017 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 "ash/common/shelf/shelf_application_menu_model.h"
-
-#include <stddef.h>
-
-#include <limits>
-#include <utility>
-
-#include "ash/common/shelf/shelf_item_delegate.h"
-#include "ash/public/cpp/shelf_application_menu_item.h"
-#include "base/metrics/histogram_macros.h"
-
-namespace {
-
-const int kInvalidCommandId = std::numeric_limits<int>::max();
-
-} // namespace
-
-namespace ash {
-
-ShelfApplicationMenuModel::ShelfApplicationMenuModel(
- const base::string16& title,
- ShelfAppMenuItemList items,
- ShelfItemDelegate* delegate)
- : ui::SimpleMenuModel(this), items_(std::move(items)), delegate_(delegate) {
- AddSeparator(ui::SPACING_SEPARATOR);
- AddItem(kInvalidCommandId, title);
- AddSeparator(ui::SPACING_SEPARATOR);
-
- for (size_t i = 0; i < items_.size(); i++) {
- ShelfApplicationMenuItem* item = items_[i].get();
- AddItem(i, item->title());
- if (!item->icon().IsEmpty())
- SetIcon(GetIndexOfCommandId(i), item->icon());
- }
-
- // SimpleMenuModel does not allow two consecutive spacing separator items.
- // This only occurs in tests; users should not see menus with no |items_|.
- if (!items_.empty())
- AddSeparator(ui::SPACING_SEPARATOR);
-}
-
-ShelfApplicationMenuModel::~ShelfApplicationMenuModel() {}
-
-bool ShelfApplicationMenuModel::IsCommandIdChecked(int command_id) const {
- return false;
-}
-
-bool ShelfApplicationMenuModel::IsCommandIdEnabled(int command_id) const {
- return command_id >= 0 && static_cast<size_t>(command_id) < items_.size();
-}
-
-void ShelfApplicationMenuModel::ExecuteCommand(int command_id,
- int event_flags) {
- DCHECK(delegate_);
- DCHECK(IsCommandIdEnabled(command_id));
- // Have the delegate execute its own custom command id for the given item.
- delegate_->ExecuteCommand(items_[command_id]->command_id(), event_flags);
- RecordMenuItemSelectedMetrics(command_id, items_.size());
-}
-
-void ShelfApplicationMenuModel::RecordMenuItemSelectedMetrics(
- int command_id,
- int num_menu_items_enabled) {
- UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.SelectedMenuItemIndex", command_id);
- UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.NumItemsEnabledUponSelection",
- num_menu_items_enabled);
-}
-
-} // namespace ash
« no previous file with comments | « ash/common/shelf/shelf_application_menu_model.h ('k') | ash/common/shelf/shelf_application_menu_model_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698