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/shelf.h" |
10 #include "ash/shell_port.h" | 10 #include "ash/shell_port.h" |
11 #include "ash/strings/grit/ash_strings.h" | 11 #include "ash/strings/grit/ash_strings.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 | 14 |
15 ShelfAlignmentMenu::ShelfAlignmentMenu(WmShelf* wm_shelf) | 15 ShelfAlignmentMenu::ShelfAlignmentMenu(Shelf* shelf) |
16 : ui::SimpleMenuModel(nullptr), wm_shelf_(wm_shelf) { | 16 : ui::SimpleMenuModel(nullptr), shelf_(shelf) { |
17 DCHECK(wm_shelf_); | 17 DCHECK(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); |
22 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, | 22 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, |
23 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM, | 23 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM, |
24 align_group_id); | 24 align_group_id); |
25 AddRadioItemWithStringId( | 25 AddRadioItemWithStringId( |
26 MENU_ALIGN_RIGHT, IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT, align_group_id); | 26 MENU_ALIGN_RIGHT, IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT, align_group_id); |
27 } | 27 } |
28 | 28 |
29 ShelfAlignmentMenu::~ShelfAlignmentMenu() {} | 29 ShelfAlignmentMenu::~ShelfAlignmentMenu() {} |
30 | 30 |
31 bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const { | 31 bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const { |
32 switch (wm_shelf_->GetAlignment()) { | 32 switch (shelf_->alignment()) { |
33 case SHELF_ALIGNMENT_BOTTOM: | 33 case SHELF_ALIGNMENT_BOTTOM: |
34 case SHELF_ALIGNMENT_BOTTOM_LOCKED: | 34 case SHELF_ALIGNMENT_BOTTOM_LOCKED: |
35 return command_id == MENU_ALIGN_BOTTOM; | 35 return command_id == MENU_ALIGN_BOTTOM; |
36 case SHELF_ALIGNMENT_LEFT: | 36 case SHELF_ALIGNMENT_LEFT: |
37 return command_id == MENU_ALIGN_LEFT; | 37 return command_id == MENU_ALIGN_LEFT; |
38 case SHELF_ALIGNMENT_RIGHT: | 38 case SHELF_ALIGNMENT_RIGHT: |
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 switch (static_cast<MenuItem>(command_id)) { | 49 switch (static_cast<MenuItem>(command_id)) { |
50 case MENU_ALIGN_LEFT: | 50 case MENU_ALIGN_LEFT: |
51 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT); | 51 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT); |
52 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_LEFT); | 52 shelf_->SetAlignment(SHELF_ALIGNMENT_LEFT); |
53 break; | 53 break; |
54 case MENU_ALIGN_BOTTOM: | 54 case MENU_ALIGN_BOTTOM: |
55 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM); | 55 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM); |
56 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM); | 56 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM); |
57 break; | 57 break; |
58 case MENU_ALIGN_RIGHT: | 58 case MENU_ALIGN_RIGHT: |
59 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); | 59 ShellPort::Get()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); |
60 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_RIGHT); | 60 shelf_->SetAlignment(SHELF_ALIGNMENT_RIGHT); |
61 break; | 61 break; |
62 } | 62 } |
63 } | 63 } |
64 | 64 |
65 } // namespace ash | 65 } // namespace ash |
OLD | NEW |