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

Side by Side Diff: ash/shelf/shelf_alignment_menu.cc

Issue 2046843005: mash: Migrate shelf menus to wm common types (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: ash_shell_with_content Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « ash/shelf/shelf_alignment_menu.h ('k') | ash/shelf/shelf_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/common/shelf/shelf_types.h" 7 #include "ash/common/shelf/shelf_types.h"
8 #include "ash/metrics/user_metrics_recorder.h" 8 #include "ash/common/shelf/wm_shelf.h"
9 #include "ash/shelf/shelf.h" 9 #include "ash/common/wm/wm_user_metrics_action.h"
10 #include "ash/shell.h" 10 #include "ash/common/wm_shell.h"
11 #include "grit/ash_strings.h" 11 #include "grit/ash_strings.h"
12 #include "ui/aura/window.h"
13 12
14 namespace ash { 13 namespace ash {
15 14
16 ShelfAlignmentMenu::ShelfAlignmentMenu(Shelf* shelf) 15 ShelfAlignmentMenu::ShelfAlignmentMenu(WmShelf* wm_shelf)
17 : ui::SimpleMenuModel(nullptr), shelf_(shelf) { 16 : ui::SimpleMenuModel(nullptr), wm_shelf_(wm_shelf) {
18 DCHECK(shelf_); 17 DCHECK(wm_shelf_);
19 int align_group_id = 1; 18 const int align_group_id = 1;
20 set_delegate(this); 19 set_delegate(this);
21 AddRadioItemWithStringId(MENU_ALIGN_LEFT, 20 AddRadioItemWithStringId(MENU_ALIGN_LEFT,
22 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT, 21 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT,
23 align_group_id); 22 align_group_id);
24 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM, 23 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM,
25 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM, 24 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM,
26 align_group_id); 25 align_group_id);
27 AddRadioItemWithStringId(MENU_ALIGN_RIGHT, 26 AddRadioItemWithStringId(MENU_ALIGN_RIGHT,
28 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT, 27 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT,
29 align_group_id); 28 align_group_id);
30 } 29 }
31 30
32 ShelfAlignmentMenu::~ShelfAlignmentMenu() {} 31 ShelfAlignmentMenu::~ShelfAlignmentMenu() {}
33 32
34 bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const { 33 bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const {
35 return shelf_->SelectValueForShelfAlignment(MENU_ALIGN_BOTTOM == command_id, 34 switch (wm_shelf_->GetAlignment()) {
36 MENU_ALIGN_LEFT == command_id, 35 case SHELF_ALIGNMENT_BOTTOM:
37 MENU_ALIGN_RIGHT == command_id); 36 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
37 return command_id == MENU_ALIGN_BOTTOM;
38 case SHELF_ALIGNMENT_LEFT:
39 return command_id == MENU_ALIGN_LEFT;
40 case SHELF_ALIGNMENT_RIGHT:
41 return command_id == MENU_ALIGN_RIGHT;
42 }
43 return false;
38 } 44 }
39 45
40 bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const { 46 bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const {
41 return true; 47 return true;
42 } 48 }
43 49
44 bool ShelfAlignmentMenu::GetAcceleratorForCommandId( 50 bool ShelfAlignmentMenu::GetAcceleratorForCommandId(
45 int command_id, 51 int command_id,
46 ui::Accelerator* accelerator) { 52 ui::Accelerator* accelerator) {
47 return false; 53 return false;
48 } 54 }
49 55
50 void ShelfAlignmentMenu::ExecuteCommand(int command_id, int event_flags) { 56 void ShelfAlignmentMenu::ExecuteCommand(int command_id, int event_flags) {
51 Shell* shell = Shell::GetInstance(); 57 WmShell* shell = WmShell::Get();
52 switch (static_cast<MenuItem>(command_id)) { 58 switch (static_cast<MenuItem>(command_id)) {
53 case MENU_ALIGN_LEFT: 59 case MENU_ALIGN_LEFT:
54 shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT); 60 shell->RecordUserMetricsAction(
55 shelf_->SetAlignment(SHELF_ALIGNMENT_LEFT); 61 wm::WmUserMetricsAction::SHELF_ALIGNMENT_SET_LEFT);
62 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_LEFT);
56 break; 63 break;
57 case MENU_ALIGN_BOTTOM: 64 case MENU_ALIGN_BOTTOM:
58 shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM); 65 shell->RecordUserMetricsAction(
59 shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM); 66 wm::WmUserMetricsAction::SHELF_ALIGNMENT_SET_BOTTOM);
67 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
60 break; 68 break;
61 case MENU_ALIGN_RIGHT: 69 case MENU_ALIGN_RIGHT:
62 shell->metrics()->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT); 70 shell->RecordUserMetricsAction(
63 shelf_->SetAlignment(SHELF_ALIGNMENT_RIGHT); 71 wm::WmUserMetricsAction::SHELF_ALIGNMENT_SET_RIGHT);
72 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_RIGHT);
64 break; 73 break;
65 } 74 }
66 } 75 }
67 76
68 } // namespace ash 77 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_alignment_menu.h ('k') | ash/shelf/shelf_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698