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/mru_window_tracker.h"
10 #include "ash/wm/window_state.h"
11 #include "ash/wm/window_util.h"
12 #include "ash/wm/wm_event.h"
13 #include "base/metrics/user_metrics.h"
16 namespace accelerators
{
18 bool ToggleMinimized() {
19 aura::Window
* window
= wm::GetActiveWindow();
20 // Attempt to restore the window that would be cycled through next from
21 // the launcher when there is no active window.
23 MruWindowTracker::WindowList
mru_windows(
24 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList());
25 if (!mru_windows
.empty())
26 wm::GetWindowState(mru_windows
.front())->Activate();
29 wm::WindowState
* window_state
= wm::GetWindowState(window
);
30 if (!window_state
->CanMinimize())
32 window_state
->Minimize();
36 void ToggleMaximized() {
37 wm::WindowState
* window_state
= wm::GetActiveWindowState();
40 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Maximized"));
41 wm::WMEvent
event(wm::WM_EVENT_TOGGLE_MAXIMIZE
);
42 window_state
->OnWMEvent(&event
);
45 void ToggleFullscreen() {
46 wm::WindowState
* window_state
= wm::GetActiveWindowState();
48 const wm::WMEvent
event(wm::WM_EVENT_TOGGLE_FULLSCREEN
);
49 window_state
->OnWMEvent(&event
);
53 } // namespace accelerators