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

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

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs Created 3 years, 9 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/shelf/shelf_alignment_menu.h"
6
7 #include "ash/common/metrics/user_metrics_action.h"
8 #include "ash/common/shelf/wm_shelf.h"
9 #include "ash/common/wm_shell.h"
10 #include "ash/public/cpp/shelf_types.h"
11 #include "ash/strings/grit/ash_strings.h"
12
13 namespace ash {
14
15 ShelfAlignmentMenu::ShelfAlignmentMenu(WmShelf* wm_shelf)
16 : ui::SimpleMenuModel(nullptr), wm_shelf_(wm_shelf) {
17 DCHECK(wm_shelf_);
18 const int align_group_id = 1;
19 set_delegate(this);
20 AddRadioItemWithStringId(
21 MENU_ALIGN_LEFT, IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_LEFT, align_group_id);
22 AddRadioItemWithStringId(MENU_ALIGN_BOTTOM,
23 IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_BOTTOM,
24 align_group_id);
25 AddRadioItemWithStringId(
26 MENU_ALIGN_RIGHT, IDS_ASH_SHELF_CONTEXT_MENU_ALIGN_RIGHT, align_group_id);
27 }
28
29 ShelfAlignmentMenu::~ShelfAlignmentMenu() {}
30
31 bool ShelfAlignmentMenu::IsCommandIdChecked(int command_id) const {
32 switch (wm_shelf_->GetAlignment()) {
33 case SHELF_ALIGNMENT_BOTTOM:
34 case SHELF_ALIGNMENT_BOTTOM_LOCKED:
35 return command_id == MENU_ALIGN_BOTTOM;
36 case SHELF_ALIGNMENT_LEFT:
37 return command_id == MENU_ALIGN_LEFT;
38 case SHELF_ALIGNMENT_RIGHT:
39 return command_id == MENU_ALIGN_RIGHT;
40 }
41 return false;
42 }
43
44 bool ShelfAlignmentMenu::IsCommandIdEnabled(int command_id) const {
45 return true;
46 }
47
48 void ShelfAlignmentMenu::ExecuteCommand(int command_id, int event_flags) {
49 WmShell* shell = WmShell::Get();
50 switch (static_cast<MenuItem>(command_id)) {
51 case MENU_ALIGN_LEFT:
52 shell->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_LEFT);
53 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_LEFT);
54 break;
55 case MENU_ALIGN_BOTTOM:
56 shell->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_BOTTOM);
57 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_BOTTOM);
58 break;
59 case MENU_ALIGN_RIGHT:
60 shell->RecordUserMetricsAction(UMA_SHELF_ALIGNMENT_SET_RIGHT);
61 wm_shelf_->SetAlignment(SHELF_ALIGNMENT_RIGHT);
62 break;
63 }
64 }
65
66 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_alignment_menu.h ('k') | ash/common/shelf/shelf_application_menu_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698