accelerator_commands.cc revision 58537e28ecd584eab876aee8be7156509866d23a
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_util.h"
11
12namespace ash {
13namespace accelerators {
14
15bool ToggleMinimized() {
16  aura::Window* window = wm::GetActiveWindow();
17  // Attempt to restore the window that would be cycled through next from
18  // the launcher when there is no active window.
19  if (!window) {
20    ash::Shell::GetInstance()->window_cycle_controller()->
21        HandleCycleWindow(WindowCycleController::FORWARD, false);
22    return true;
23  }
24  // Disable the shortcut for minimizing full screen window due to
25  // crbug.com/131709, which is a crashing issue related to minimizing
26  // full screen pepper window.
27  if (wm::IsWindowFullscreen(window) || !wm::CanMinimizeWindow(window))
28    return false;
29  ash::Shell::GetInstance()->delegate()->RecordUserMetricsAction(
30      ash::UMA_MINIMIZE_PER_KEY);
31  wm::MinimizeWindow(window);
32  return true;
33}
34
35}  // namespace accelerators
36}  // namespace ash
37