| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_alignment_menu.h" | 5 #include "ash/shelf/shelf_alignment_menu.h" |
| 6 | 6 |
| 7 #include "ash/metrics/user_metrics_action.h" | 7 #include "ash/metrics/user_metrics_action.h" |
| 8 #include "ash/public/cpp/shelf_types.h" | 8 #include "ash/public/cpp/shelf_types.h" |
| 9 #include "ash/shelf/wm_shelf.h" | 9 #include "ash/shelf/wm_shelf.h" |
| 10 #include "ash/shell_port.h" |
| 10 #include "ash/strings/grit/ash_strings.h" | 11 #include "ash/strings/grit/ash_strings.h" |
| 11 #include "ash/wm_shell.h" | |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 | 14 |
| 15 ShelfAlignmentMenu::ShelfAlignmentMenu(WmShelf* wm_shelf) | 15 ShelfAlignmentMenu::ShelfAlignmentMenu(WmShelf* wm_shelf) |
| 16 : ui::SimpleMenuModel(nullptr), wm_shelf_(wm_shelf) { | 16 : ui::SimpleMenuModel(nullptr), wm_shelf_(wm_shelf) { |
| 17 DCHECK(wm_shelf_); | 17 DCHECK(wm_shelf_); |
| 18 const int align_group_id = 1; | 18 const int align_group_id = 1; |
| 19 set_delegate(this); | 19 set_delegate(this); |
| 20 AddRadioItemWithStringId( | 20 AddRadioItemWithStringId( |
| 21 MENU_ALIGN_LEFT, IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT, align_group_id); | 21 MENU_ALIGN_LEFT, IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT, align_group_id); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 39 return command_id == MENU_ALIGN_RIGHT; | 39 return command_id == MENU_ALIGN_RIGHT; |
| 40 } | 40 } |
| 41 return false; | 41 return false; |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const { | 44 bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const { |
| 45 return true; | 45 return true; |
| 46 } | 46 } |
| 47 | 47 |
| 48 void ShelfAlignmentMenu::ExecuteCommand(int command_id, int event_flags) { | 48 void ShelfAlignmentMenu::ExecuteCommand(int command_id, int event_flags) { |
| 49 WmShell* shell = WmShell::Get(); | |
| 50 switch (static_cast<MenuItem>(command_id)) { | 49 switch (static_cast<MenuItem>(command_id)) { |
| 51 case MENU_ALIGN_LEFT: | 50 case MENU_ALIGN_LEFT: |
| 52 shell->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT); | 51 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT); |
| 53 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_LEFT); | 52 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_LEFT); |
| 54 break; | 53 break; |
| 55 case MENU_ALIGN_BOTTOM: | 54 case MENU_ALIGN_BOTTOM: |
| 56 shell->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM); | 55 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM); |
| 57 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 56 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
| 58 break; | 57 break; |
| 59 case MENU_ALIGN_RIGHT: | 58 case MENU_ALIGN_RIGHT: |
| 60 shell->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); | 59 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); |
| 61 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 60 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
| 62 break; | 61 break; |
| 63 } | 62 } |
| 64 } | 63 } |
| 65 | 64 |
| 66 } // namespace ash | 65 } // namespace ash |
| OLD | NEW |