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

Unified Diff: chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc

Issue 2671923002: mash: Cleanup ash shelf application menu code. (Closed)
Patch Set: Add comments Created 3 years, 10 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: chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc
diff --git a/chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc b/chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc
deleted file mode 100644
index 65f47434ec30d7c2ba461b6d4fdb5573187218d6..0000000000000000000000000000000000000000
--- a/chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// 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/ash/launcher/launcher_application_menu_item_model.h"
-
-#include <stddef.h>
-
-#include <utility>
-
-#include "base/metrics/histogram_macros.h"
-#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
-
-namespace {
-
-const char kNumItemsEnabledHistogramName[] =
- "Ash.Shelf.Menu.NumItemsEnabledUponSelection";
-
-const char kSelectedMenuItemIndexHistogramName[] =
- "Ash.Shelf.Menu.SelectedMenuItemIndex";
-
-} // namespace
-
-LauncherApplicationMenuItemModel::LauncherApplicationMenuItemModel(
- ChromeLauncherAppMenuItems item_list)
- : ui::SimpleMenuModel(this), launcher_items_(std::move(item_list)) {
- Build();
-}
-
-LauncherApplicationMenuItemModel::~LauncherApplicationMenuItemModel() {}
-
-bool LauncherApplicationMenuItemModel::IsCommandIdChecked(
- int command_id) const {
- return false;
-}
-
-bool LauncherApplicationMenuItemModel::IsCommandIdEnabled(
- int command_id) const {
- DCHECK(command_id < static_cast<int>(launcher_items_.size()));
- return launcher_items_[command_id]->IsEnabled();
-}
-
-void LauncherApplicationMenuItemModel::ExecuteCommand(int command_id,
- int event_flags) {
- DCHECK(command_id < static_cast<int>(launcher_items_.size()));
- launcher_items_[command_id]->Execute(event_flags);
- RecordMenuItemSelectedMetrics(command_id, GetNumMenuItemsEnabled());
-}
-
-void LauncherApplicationMenuItemModel::Build() {
- if (launcher_items_.empty())
- return;
-
- AddSeparator(ui::SPACING_SEPARATOR);
- for (size_t i = 0; i < launcher_items_.size(); i++) {
- ChromeLauncherAppMenuItem* item = launcher_items_[i].get();
-
- // Check for a separator requirement in front of this item.
- if (item->HasLeadingSeparator())
- AddSeparator(ui::SPACING_SEPARATOR);
-
- // The first item is the context menu, the others are the running apps.
- AddItem(i, item->title());
-
- if (!item->icon().IsEmpty())
- SetIcon(GetIndexOfCommandId(i), item->icon());
- }
- AddSeparator(ui::SPACING_SEPARATOR);
-}
-
-int LauncherApplicationMenuItemModel::GetNumMenuItemsEnabled() const {
- int num_menu_items_enabled = 0;
- for (const auto& menu_item : launcher_items_) {
- if (menu_item->IsEnabled())
- ++num_menu_items_enabled;
- }
- return num_menu_items_enabled;
-}
-
-void LauncherApplicationMenuItemModel::RecordMenuItemSelectedMetrics(
- int command_id,
- int num_menu_items_enabled) {
- UMA_HISTOGRAM_COUNTS_100(kSelectedMenuItemIndexHistogramName, command_id);
- UMA_HISTOGRAM_COUNTS_100(kNumItemsEnabledHistogramName,
- num_menu_items_enabled);
-}

Powered by Google App Engine
This is Rietveld 408576698