accelerator_commands.cc revision a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7
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. 4 5#include "ash/accelerators/accelerator_commands.h" 6 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 "content/public/browser/user_metrics.h" 13 14namespace ash { 15namespace accelerators { 16 17bool 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; 25 } 26 wm::WindowState* window_state = wm::GetWindowState(window); 27 if (!window_state->CanMinimize()) 28 return false; 29 window_state->Minimize(); 30 return true; 31} 32 33void ToggleMaximized() { 34 wm::WindowState* window_state = wm::GetActiveWindowState(); 35 if (!window_state) 36 return; 37 content::RecordAction( 38 content::UserMetricsAction("Accel_Toggle_Maximized")); 39 // Get out of fullscreen when in fullscreen mode. 40 if (window_state->IsFullscreen()) 41 ToggleFullscreen(); 42 else 43 window_state->ToggleMaximized(); 44} 45 46void ToggleFullscreen() { 47 wm::WindowState* window_state = wm::GetActiveWindowState(); 48 if (window_state) 49 window_state->ToggleFullscreen(); 50} 51 52} // namespace accelerators 53} // namespace ash 54