| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/common/shelf/shelf_application_menu_model.h" | 5 #include "ash/common/shelf/shelf_application_menu_model.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/metrics/histogram_macros.h" | 12 #include "base/metrics/histogram_macros.h" |
| 13 #include "ui/gfx/image/image.h" | 13 #include "ui/gfx/image/image.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 const int kInvalidCommandId = std::numeric_limits<int>::max(); | 17 const int kInvalidCommandId = std::numeric_limits<int>::max(); |
| 18 | 18 |
| 19 } // namespace | 19 } // namespace |
| 20 | 20 |
| 21 namespace ash { | 21 namespace ash { |
| 22 | 22 |
| 23 ShelfApplicationMenuModel::ShelfApplicationMenuModel( | 23 ShelfApplicationMenuModel::ShelfApplicationMenuModel( |
| 24 const base::string16& title, | 24 const base::string16& title, |
| 25 std::vector<mojom::MenuItemPtr> items, | 25 std::vector<mojom::MenuItemPtr> items, |
| 26 mojom::ShelfItemDelegate* delegate) | 26 ShelfItemDelegate* delegate) |
| 27 : ui::SimpleMenuModel(this), items_(std::move(items)), delegate_(delegate) { | 27 : ui::SimpleMenuModel(this), items_(std::move(items)), delegate_(delegate) { |
| 28 AddSeparator(ui::SPACING_SEPARATOR); | 28 AddSeparator(ui::SPACING_SEPARATOR); |
| 29 AddItem(kInvalidCommandId, title); | 29 AddItem(kInvalidCommandId, title); |
| 30 AddSeparator(ui::SPACING_SEPARATOR); | 30 AddSeparator(ui::SPACING_SEPARATOR); |
| 31 | 31 |
| 32 for (size_t i = 0; i < items_.size(); i++) { | 32 for (size_t i = 0; i < items_.size(); i++) { |
| 33 mojom::MenuItem* item = items_[i].get(); | 33 mojom::MenuItem* item = items_[i].get(); |
| 34 AddItem(i, item->label); | 34 AddItem(i, item->label); |
| 35 if (!item->image.isNull()) { | 35 if (!item->image.isNull()) { |
| 36 SetIcon(GetIndexOfCommandId(i), | 36 SetIcon(GetIndexOfCommandId(i), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 65 | 65 |
| 66 void ShelfApplicationMenuModel::RecordMenuItemSelectedMetrics( | 66 void ShelfApplicationMenuModel::RecordMenuItemSelectedMetrics( |
| 67 int command_id, | 67 int command_id, |
| 68 int num_menu_items_enabled) { | 68 int num_menu_items_enabled) { |
| 69 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.SelectedMenuItemIndex", command_id); | 69 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.SelectedMenuItemIndex", command_id); |
| 70 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.NumItemsEnabledUponSelection", | 70 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.NumItemsEnabledUponSelection", |
| 71 num_menu_items_enabled); | 71 num_menu_items_enabled); |
| 72 } | 72 } |
| 73 | 73 |
| 74 } // namespace ash | 74 } // namespace ash |
| OLD | NEW |