OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 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/accelerators/accelerator_commands.h" | 5 #include "ash/accelerators/accelerator_commands.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
9 #include "ash/wm/window_cycle_controller.h" | 9 #include "ash/wm/window_cycle_controller.h" |
10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 12 #include "content/public/browser/user_metrics.h" |
12 | 13 |
13 namespace ash { | 14 namespace ash { |
14 namespace accelerators { | 15 namespace accelerators { |
15 | 16 |
16 bool ToggleMinimized() { | 17 bool ToggleMinimized() { |
17 aura::Window* window = wm::GetActiveWindow(); | 18 aura::Window* window = wm::GetActiveWindow(); |
18 // Attempt to restore the window that would be cycled through next from | 19 // Attempt to restore the window that would be cycled through next from |
19 // the launcher when there is no active window. | 20 // the launcher when there is no active window. |
20 if (!window) { | 21 if (!window) { |
21 ash::Shell::GetInstance()->window_cycle_controller()-> | 22 ash::Shell::GetInstance()->window_cycle_controller()-> |
22 HandleCycleWindow(WindowCycleController::FORWARD, false); | 23 HandleCycleWindow(WindowCycleController::FORWARD, false); |
23 return true; | 24 return true; |
24 } | 25 } |
25 wm::WindowState* window_state = wm::GetWindowState(window); | 26 wm::WindowState* window_state = wm::GetWindowState(window); |
26 if (!window_state->CanMinimize()) | 27 if (!window_state->CanMinimize()) |
27 return false; | 28 return false; |
28 ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction( | 29 content::RecordAction( |
29 ash::UMA_MINIMIZE_PER_KEY); | 30 content::UserMetricsAction("Accel_Toggle_Minimized")); |
30 window_state->Minimize(); | 31 window_state->Minimize(); |
31 return true; | 32 return true; |
32 } | 33 } |
33 | 34 |
34 void ToggleMaximized() { | 35 void ToggleMaximized() { |
35 wm::WindowState* window_state = wm::GetActiveWindowState(); | 36 wm::WindowState* window_state = wm::GetActiveWindowState(); |
36 if (!window_state) | 37 if (!window_state) |
37 return; | 38 return; |
| 39 content::RecordAction( |
| 40 content::UserMetricsAction("Accel_Toggle_Maximized")); |
38 // Get out of fullscreen when in fullscreen mode. | 41 // Get out of fullscreen when in fullscreen mode. |
39 if (window_state->IsFullscreen()) | 42 if (window_state->IsFullscreen()) |
40 ToggleFullscreen(); | 43 ToggleFullscreen(); |
41 else | 44 else |
42 window_state->ToggleMaximized(); | 45 window_state->ToggleMaximized(); |
43 } | 46 } |
44 | 47 |
45 void ToggleFullscreen() { | 48 void ToggleFullscreen() { |
46 wm::WindowState* window_state = wm::GetActiveWindowState(); | 49 wm::WindowState* window_state = wm::GetActiveWindowState(); |
47 if (window_state) | 50 if (window_state) |
48 window_state->ToggleFullscreen(); | 51 window_state->ToggleFullscreen(); |
49 } | 52 } |
50 | 53 |
51 } // namespace accelerators | 54 } // namespace accelerators |
52 } // namespace ash | 55 } // namespace ash |
OLD | NEW |