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"
12 #include "base/metrics/user_metrics.h"
15 namespace accelerators
{
17 bool ToggleMinimized() {
18 aura::Window
* window
= wm::GetActiveWindow();
19 // Attempt to restore the window that would be cycled through next from
20 // the launcher when there is no active window.
22 ash::Shell::GetInstance()->window_cycle_controller()->
23 HandleCycleWindow(WindowCycleController::FORWARD
, false);
26 wm::WindowState
* window_state
= wm::GetWindowState(window
);
27 if (!window_state
->CanMinimize())
29 window_state
->Minimize();
33 void ToggleMaximized() {
34 wm::WindowState
* window_state
= wm::GetActiveWindowState();
37 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Maximized"));
38 window_state
->OnWMEvent(wm::TOGGLE_MAXIMIZE
);
41 void ToggleFullscreen() {
42 wm::WindowState
* window_state
= wm::GetActiveWindowState();
44 window_state
->ToggleFullscreen();
47 } // namespace accelerators