usb_gadget: Switch to official Google product IDs.
[chromium-blink-merge.git] / ash / accelerators / accelerator_commands.cc
blob9fbe5ebe3b87f0fff6eff37c13ed9fc46099c442
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"
7 #include "ash/shell.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"
15 namespace ash {
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.
22 if (!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();
27 return true;
29 wm::WindowState* window_state = wm::GetWindowState(window);
30 if (!window_state->CanMinimize())
31 return false;
32 window_state->Minimize();
33 return true;
36 void ToggleMaximized() {
37 wm::WindowState* window_state = wm::GetActiveWindowState();
38 if (!window_state)
39 return;
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();
47 if (window_state) {
48 const wm::WMEvent event(wm::WM_EVENT_TOGGLE_FULLSCREEN);
49 window_state->OnWMEvent(&event);
53 } // namespace accelerators
54 } // namespace ash