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 return ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS == | 28 internal::RootWindowController* controller = |
| 29 Shell::GetPrimaryRootWindowController(); |
| 30 ash::ShelfAutoHideBehavior auto_hide_behavior = |
29 Shell::GetInstance()->GetShelfAutoHideBehavior(); | 31 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); |
30 } | 37 } |
31 | 38 |
32 // static | 39 // static |
33 ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() { | 40 ShelfAutoHideBehavior LauncherContextMenu::GetToggledAutoHideBehavior() { |
34 return IsAutoHideMenuHideChecked() ? ash::SHELF_AUTO_HIDE_BEHAVIOR_NEVER : | 41 ash::ShelfAutoHideBehavior auto_hide_behavior; |
35 ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS; | 42 if (Shell::GetPrimaryRootWindowController()->IsInMaximizedMode()) { |
| 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; |
36 } | 53 } |
37 | 54 |
38 // static | 55 // static |
39 int LauncherContextMenu::GetAutoHideResourceStringId() { | 56 int LauncherContextMenu::GetAutoHideResourceStringId() { |
40 return IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE; | 57 return Shell::GetPrimaryRootWindowController()->IsInMaximizedMode() ? |
| 58 IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_MAXIMIZED : |
| 59 IDS_AURA_LAUNCHER_CONTEXT_MENU_AUTO_HIDE_NOT_MAXIMIZED; |
41 } | 60 } |
42 | 61 |
43 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { | 62 bool LauncherContextMenu::IsCommandIdChecked(int command_id) const { |
44 switch (command_id) { | 63 switch (command_id) { |
45 case MENU_AUTO_HIDE: | 64 case MENU_AUTO_HIDE: |
46 return IsAutoHideMenuHideChecked(); | 65 return IsAutoHideMenuHideChecked(); |
47 default: | 66 default: |
48 return false; | 67 return false; |
49 } | 68 } |
50 } | 69 } |
(...skipping 13 matching lines...) Expand all Loading... |
64 case MENU_AUTO_HIDE: | 83 case MENU_AUTO_HIDE: |
65 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( | 84 ash::Shell::GetInstance()->SetShelfAutoHideBehavior( |
66 GetToggledAutoHideBehavior()); | 85 GetToggledAutoHideBehavior()); |
67 break; | 86 break; |
68 case MENU_ALIGNMENT_MENU: | 87 case MENU_ALIGNMENT_MENU: |
69 break; | 88 break; |
70 } | 89 } |
71 } | 90 } |
72 | 91 |
73 } // namespace ash | 92 } // namespace ash |
OLD | NEW |