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/launcher/launcher_context_menu.h" | 5 #include "ash/launcher/launcher_context_menu.h" |
6 | 6 |
7 #include "ash/root_window_controller.h" | 7 #include "ash/root_window_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/wm/shelf_types.h" | 9 #include "ash/wm/shelf_types.h" |
10 #include "grit/ash_strings.h" | 10 #include "grit/ash_strings.h" |
11 #include "ui/base/l10n/l10n_util.h" | 11 #include "ui/base/l10n/l10n_util.h" |
12 | 12 |
13 namespace ash { | 13 namespace ash { |
14 | 14 |
15 LauncherContextMenu::LauncherContextMenu() : ui::SimpleMenuModel(NULL) { | 15 LauncherContextMenu::LauncherContextMenu() : ui::SimpleMenuModel(NULL) { |
16 set_delegate(this); | 16 set_delegate(this); |
17 AddCheckItemWithStringId(MENU_AUTO_HIDE, GetAutoHideResourceStringId()); | 17 AddCheckItemWithStringId(MENU_AUTO_HIDE, GetAutoHideResourceStringId()); |
18 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, | 18 AddSubMenuWithStringId(MENU_ALIGNMENT_MENU, |
19 IDS_AURA_LAUNCHER_CONTEXT_MENU_POSITION, | 19 IDS_AURA_LAUNCHER_CONTEXT_MENU_POSITION, |
20 &alignment_menu_); | 20 &alignment_menu_); |
21 } | 21 } |
22 | 22 |
23 LauncherContextMenu::~LauncherContextMenu() { | 23 LauncherContextMenu::~LauncherContextMenu() { |
24 } | 24 } |
25 | 25 |
26 // static | 26 // static |
27 bool LauncherContextMenu::IsAutoHideMenuHideChecked() { | 27 bool LauncherContextMenu::IsAutoHideMenuHideChecked() { |
28 internal::RootWindowController* controller = | 28 return ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS == |
29 Shell::GetPrimaryRootWindowController(); | |
30 ash::ShelfAutoHideBehavior auto_hide_behavior = | |
31 Shell::GetInstance()->GetShelfAutoHideBehavior(); | 29 Shell::GetInstance()->GetShelfAutoHideBehavior(); |
32 return (controller->IsInMaximizedMode() && | |
33 (auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT || | |
34 auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS)) || | |
35 (!controller->IsInMaximizedMode() && | |
36 auto_hide_behavior == ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS); | |
37 } | 30 } |
38 | 31 |
39 // static | 32 // static |
40 ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() { | 33 ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() { |
41 ash::ShelfAutoHideBehavior auto_hide_behavior; | 34 return IsAutoHideMenuHideChecked() ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER : |
42 if (Shell::GetPrimaryRootWindowController()->IsInMaximizedMode()) { | 35 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; |
43 if (IsAutoHideMenuHideChecked()) | |
44 auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER; | |
45 else | |
46 auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT; | |
47 } else if (IsAutoHideMenuHideChecked()) { | |
48 auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_DEFAULT; | |
49 } else { | |
50 auto_hide_behavior = ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | |
51 } | |
52 return auto_hide_behavior; | |
53 } | 36 } |
54 | 37 |
55 // static | 38 // static |
56 int LauncherContextMenu::GetAutoHideResourceStringId() { | 39 int LauncherContextMenu::GetAutoHideResourceStringId() { |
57 return Shell::GetPrimaryRootWindowController()->IsInMaximizedMode() ? | 40 return IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_NOT_MAXIMIZED; |
58 IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_MAXIMIZED : | |
59 IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_NOT_MAXIMIZED; | |
60 } | 41 } |
61 | 42 |
62 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { | 43 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { |
63 switch (command_id) { | 44 switch (command_id) { |
64 case MENU_AUTO_HIDE: | 45 case MENU_AUTO_HIDE: |
65 return IsAutoHideMenuHideChecked(); | 46 return IsAutoHideMenuHideChecked(); |
66 default: | 47 default: |
67 return false; | 48 return false; |
68 } | 49 } |
69 } | 50 } |
(...skipping 13 matching lines...) Expand all Loading... |
83 case MENU_AUTO_HIDE: | 64 case MENU_AUTO_HIDE: |
84 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( | 65 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( |
85 GetToggledAutoHideBehavior()); | 66 GetToggledAutoHideBehavior()); |
86 break; | 67 break; |
87 case MENU_ALIGNMENT_MENU: | 68 case MENU_ALIGNMENT_MENU: |
88 break; | 69 break; |
89 } | 70 } |
90 } | 71 } |
91 | 72 |
92 } // namespace ash | 73 } // namespace ash |
OLD | NEW |