| 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/shelf/shelf_application_menu_model.h" | 5 #include "ash/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> |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 bool ShelfApplicationMenuModel::IsCommandIdChecked(int command_id) const { | 50 bool ShelfApplicationMenuModel::IsCommandIdChecked(int command_id) const { |
| 51 return false; | 51 return false; |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool ShelfApplicationMenuModel::IsCommandIdEnabled(int command_id) const { | 54 bool ShelfApplicationMenuModel::IsCommandIdEnabled(int command_id) const { |
| 55 return command_id >= 0 && static_cast<size_t>(command_id) < items_.size(); | 55 return command_id >= 0 && static_cast<size_t>(command_id) < items_.size(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 void ShelfApplicationMenuModel::ExecuteCommand(int command_id, | 58 void ShelfApplicationMenuModel::ExecuteCommand(int command_id, |
| 59 int event_flags) { | 59 int event_flags) { |
| 60 DCHECK(delegate_); | |
| 61 DCHECK(IsCommandIdEnabled(command_id)); | 60 DCHECK(IsCommandIdEnabled(command_id)); |
| 62 // Have the delegate execute its own custom command id for the given item. | 61 // Have the delegate execute its own custom command id for the given item. |
| 63 delegate_->ExecuteCommand(items_[command_id]->command_id, event_flags); | 62 if (delegate_) |
| 63 delegate_->ExecuteCommand(items_[command_id]->command_id, event_flags); |
| 64 RecordMenuItemSelectedMetrics(command_id, items_.size()); | 64 RecordMenuItemSelectedMetrics(command_id, items_.size()); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void ShelfApplicationMenuModel::RecordMenuItemSelectedMetrics( | 67 void ShelfApplicationMenuModel::RecordMenuItemSelectedMetrics( |
| 68 int command_id, | 68 int command_id, |
| 69 int num_menu_items_enabled) { | 69 int num_menu_items_enabled) { |
| 70 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.SelectedMenuItemIndex", command_id); | 70 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.SelectedMenuItemIndex", command_id); |
| 71 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.NumItemsEnabledUponSelection", | 71 UMA_HISTOGRAM_COUNTS_100("Ash.Shelf.Menu.NumItemsEnabledUponSelection", |
| 72 num_menu_items_enabled); | 72 num_menu_items_enabled); |
| 73 } | 73 } |
| 74 | 74 |
| 75 } // namespace ash | 75 } // namespace ash |
| OLD | NEW |