[Mac] Remove NSApplication from the renderer.
[chromium-blink-merge.git] / ash / accelerators / accelerator_commands.cc
bloba4c8367dd64876db1ae323556fbefc341fb8eb4a
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/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"
14 namespace ash {
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.
21 if (!window) {
22 ash::Shell::GetInstance()->window_cycle_controller()->
23 HandleCycleWindow(WindowCycleController::FORWARD, false);
24 return true;
26 wm::WindowState* window_state = wm::GetWindowState(window);
27 if (!window_state->CanMinimize())
28 return false;
29 window_state->Minimize();
30 return true;
33 void ToggleMaximized() {
34 wm::WindowState* window_state = wm::GetActiveWindowState();
35 if (!window_state)
36 return;
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();
43 if (window_state)
44 window_state->ToggleFullscreen();
47 } // namespace accelerators
48 } // namespace ash