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

Side by Side Diff: ash/shell/context_menu.cc

Issue 1812013003: Pass shelf instances, not root windows, for ash context menus. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Call OnShelfAlignmentChanged after LayoutShelf. Created 4 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
« no previous file with comments | « ash/shell/context_menu.h ('k') | ash/shell/shell_delegate_impl.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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/shell/context_menu.h" 5 #include "ash/shell/context_menu.h"
6 6
7 #include "ash/root_window_controller.h"
8 #include "ash/shelf/shelf.h" 7 #include "ash/shelf/shelf.h"
9 #include "ash/shelf/shelf_types.h" 8 #include "ash/shelf/shelf_types.h"
10 #include "ash/shell.h"
11 #include "grit/ash_strings.h" 9 #include "grit/ash_strings.h"
12 10
13 namespace ash { 11 namespace ash {
14 namespace shell { 12 namespace shell {
15 13
16 ContextMenu::ContextMenu(aura::Window* root) 14 ContextMenu::ContextMenu(ash::Shelf* shelf)
17 : ui::SimpleMenuModel(NULL), 15 : ui::SimpleMenuModel(nullptr), shelf_(shelf), alignment_menu_(shelf) {
18 root_window_(root), 16 DCHECK(shelf_);
19 alignment_menu_(root) {
20 DCHECK(root_window_);
21 set_delegate(this); 17 set_delegate(this);
22 AddCheckItemWithStringId(MENU_AUTO_HIDE, 18 AddCheckItemWithStringId(MENU_AUTO_HIDE,
23 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); 19 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE);
24 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, 20 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU,
25 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, 21 IDS_ASH_SHELF_CONTEXT_MENU_POSITION,
26 &alignment_menu_); 22 &alignment_menu_);
27 } 23 }
28 24
29 ContextMenu::~ContextMenu() { 25 ContextMenu::~ContextMenu() {
30 } 26 }
31 27
32 bool ContextMenu::IsCommandIdChecked(int command_id) const { 28 bool ContextMenu::IsCommandIdChecked(int command_id) const {
33 switch (command_id) { 29 if (command_id == MENU_AUTO_HIDE)
34 case MENU_AUTO_HIDE: 30 return shelf_->GetAutoHideBehavior() == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
35 return Shell::GetInstance()->GetShelfAutoHideBehavior(root_window_) == 31 return false;
36 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS;
37 default:
38 return false;
39 }
40 } 32 }
41 33
42 bool ContextMenu::IsCommandIdEnabled(int command_id) const { 34 bool ContextMenu::IsCommandIdEnabled(int command_id) const {
43 return true; 35 return true;
44 } 36 }
45 37
46 bool ContextMenu::GetAcceleratorForCommandId( 38 bool ContextMenu::GetAcceleratorForCommandId(int command_id,
47 int command_id, 39 ui::Accelerator* accelerator) {
48 ui::Accelerator* accelerator) {
49 return false; 40 return false;
50 } 41 }
51 42
52 void ContextMenu::ExecuteCommand(int command_id, int event_flags) { 43 void ContextMenu::ExecuteCommand(int command_id, int event_flags) {
53 Shell* shell = Shell::GetInstance(); 44 if (command_id == MENU_AUTO_HIDE) {
54 switch (static_cast<MenuItem>(command_id)) { 45 shelf_->SetAutoHideBehavior(shelf_->GetAutoHideBehavior() ==
55 case MENU_AUTO_HIDE: 46 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS
56 shell->SetShelfAutoHideBehavior( 47 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER
57 shell->GetShelfAutoHideBehavior(root_window_) == 48 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS);
58 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS ?
59 SHELF_AUTO_HIDE_BEHAVIOR_NEVER :
60 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
61 root_window_);
62 break;
63 case MENU_ALIGNMENT_MENU:
64 break;
65 } 49 }
66 } 50 }
67 51
68 } // namespace shell 52 } // namespace shell
69 } // namespace ash 53 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shell/context_menu.h ('k') | ash/shell/shell_delegate_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698