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
3 // found in the LICENSE file.
5 #include "ash/accelerators/accelerator_commands.h"
8 #include "ash/shell_delegate.h"
9 #include "ash/wm/window_cycle_controller.h"
10 #include "ash/wm/window_state.h"
11 #include "ash/wm/window_util.h"
14 namespace accelerators {
16 bool ToggleMinimized() {
17 aura::Window* window = wm::GetActiveWindow();
18 // Attempt to restore the window that would be cycled through next from
19 // the launcher when there is no active window.
21 ash::Shell::GetInstance()->window_cycle_controller()->
22 HandleCycleWindow(WindowCycleController::FORWARD, false);
25 wm::WindowState* window_state = wm::GetWindowState(window);
26 if (!window_state->CanMinimize())
28 ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction(
29 ash::UMA_MINIMIZE_PER_KEY);
30 window_state->Minimize();
34 void ToggleMaximized() {
35 wm::WindowState* window_state = wm::GetActiveWindowState();
38 // Get out of fullscreen when in fullscreen mode.
39 if (window_state->IsFullscreen())
42 window_state->ToggleMaximized();
45 void ToggleFullscreen() {
46 wm::WindowState* window_state = wm::GetActiveWindowState();
48 window_state->ToggleFullscreen();
51 } // namespace accelerators