accelerator_commands.cc revision 68043e1e95eeb07d5cae7aca370b26518b0867d6
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
37}  // namespace accelerators
38}  // namespace ash
39