accelerator_commands.cc revision 8bcbed890bc3ce4d7a057a8f32cab53fa534672e
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 13namespace ash { 14namespace accelerators { 15 16bool ToggleMinimized() { 17 aura::Window* window = wm::GetActiveWindow(); 18 // Attempt to restore the window that would be cycled through next from 19 // the launcher when there is no active window. 20 if (!window) { 21 ash::Shell::GetInstance()->window_cycle_controller()-> 22 HandleCycleWindow(WindowCycleController::FORWARD, false); 23 return true; 24 } 25 wm::WindowState* window_state = wm::GetWindowState(window); 26 // Disable the shortcut for minimizing full screen window due to 27 // crbug.com/131709, which is a crashing issue related to minimizing 28 // full screen pepper window. 29 if (window_state->IsFullscreen() || !window_state->CanMinimize()) 30 return false; 31 ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction( 32 ash::UMA_MINIMIZE_PER_KEY); 33 window_state->Minimize(); 34 return true; 35} 36 37void ToggleMaximized() { 38 wm::WindowState* window_state = wm::GetActiveWindowState(); 39 if (!window_state) 40 return; 41 // Get out of fullscreen when in fullscreen mode. 42 if (window_state->IsFullscreen()) 43 Shell::GetInstance()->delegate()->ToggleFullscreen(); 44 else 45 window_state->ToggleMaximized(); 46} 47 48} // namespace accelerators 49} // namespace ash 50