OLD | NEW |
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/public/cpp/shelf_types.h" | 7 #include "ash/public/cpp/shelf_types.h" |
8 #include "ash/shelf/wm_shelf.h" | 8 #include "ash/shelf/shelf.h" |
9 #include "ash/strings/grit/ash_strings.h" | 9 #include "ash/strings/grit/ash_strings.h" |
10 | 10 |
11 namespace ash { | 11 namespace ash { |
12 namespace shell { | 12 namespace shell { |
13 | 13 |
14 ContextMenu::ContextMenu(WmShelf* wm_shelf) | 14 ContextMenu::ContextMenu(Shelf* shelf) |
15 : ui::SimpleMenuModel(nullptr), | 15 : ui::SimpleMenuModel(nullptr), shelf_(shelf), alignment_menu_(shelf) { |
16 wm_shelf_(wm_shelf), | 16 DCHECK(shelf_); |
17 alignment_menu_(wm_shelf) { | |
18 DCHECK(wm_shelf_); | |
19 set_delegate(this); | 17 set_delegate(this); |
20 AddCheckItemWithStringId(MENU_AUTO_HIDE, | 18 AddCheckItemWithStringId(MENU_AUTO_HIDE, |
21 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); | 19 IDS_ASH_SHELF_CONTEXT_MENU_AUTO_HIDE); |
22 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, | 20 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, |
23 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, &alignment_menu_); | 21 IDS_ASH_SHELF_CONTEXT_MENU_POSITION, &alignment_menu_); |
24 } | 22 } |
25 | 23 |
26 ContextMenu::~ContextMenu() {} | 24 ContextMenu::~ContextMenu() {} |
27 | 25 |
28 bool ContextMenu::IsCommandIdChecked(int command_id) const { | 26 bool ContextMenu::IsCommandIdChecked(int command_id) const { |
29 if (command_id == MENU_AUTO_HIDE) | 27 if (command_id == MENU_AUTO_HIDE) |
30 return wm_shelf_->auto_hide_behavior() == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 28 return shelf_->auto_hide_behavior() == SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
31 return false; | 29 return false; |
32 } | 30 } |
33 | 31 |
34 bool ContextMenu::IsCommandIdEnabled(int command_id) const { | 32 bool ContextMenu::IsCommandIdEnabled(int command_id) const { |
35 return true; | 33 return true; |
36 } | 34 } |
37 | 35 |
38 void ContextMenu::ExecuteCommand(int command_id, int event_flags) { | 36 void ContextMenu::ExecuteCommand(int command_id, int event_flags) { |
39 if (command_id == MENU_AUTO_HIDE) { | 37 if (command_id == MENU_AUTO_HIDE) { |
40 wm_shelf_->SetAutoHideBehavior(wm_shelf_->auto_hide_behavior() == | 38 shelf_->SetAutoHideBehavior(shelf_->auto_hide_behavior() == |
41 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS | 39 SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS |
42 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER | 40 ? SHELF_AUTO_HIDE_BEHAVIOR_NEVER |
43 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | 41 : SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); |
44 } | 42 } |
45 } | 43 } |
46 | 44 |
47 } // namespace shell | 45 } // namespace shell |
48 } // namespace ash | 46 } // namespace ash |
OLD | NEW |