| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ash/accelerators/accelerator_commands.h" | 5 #include "ash/accelerators/accelerator_commands.h" |
| 6 | 6 |
| 7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
| 8 #include "ash/shell_delegate.h" | 8 #include "ash/shell_delegate.h" |
| 9 #include "ash/wm/window_cycle_controller.h" | 9 #include "ash/wm/mru_window_tracker.h" |
| 10 #include "ash/wm/window_state.h" | 10 #include "ash/wm/window_state.h" |
| 11 #include "ash/wm/window_util.h" | 11 #include "ash/wm/window_util.h" |
| 12 #include "base/metrics/user_metrics.h" | 12 #include "base/metrics/user_metrics.h" |
| 13 | 13 |
| 14 namespace ash { | 14 namespace ash { |
| 15 namespace accelerators { | 15 namespace accelerators { |
| 16 | 16 |
| 17 bool ToggleMinimized() { | 17 bool ToggleMinimized() { |
| 18 aura::Window* window = wm::GetActiveWindow(); | 18 aura::Window* window = wm::GetActiveWindow(); |
| 19 // Attempt to restore the window that would be cycled through next from | 19 // Attempt to restore the window that would be cycled through next from |
| 20 // the launcher when there is no active window. | 20 // the launcher when there is no active window. |
| 21 if (!window) { | 21 if (!window) { |
| 22 ash::Shell::GetInstance()->window_cycle_controller()-> | 22 MruWindowTracker::WindowList mru_windows( |
| 23 HandleCycleWindow(WindowCycleController::FORWARD, false); | 23 Shell::GetInstance()->mru_window_tracker()->BuildMruWindowList()); |
| 24 if (!mru_windows.empty()) |
| 25 wm::GetWindowState(mru_windows.front())->Activate(); |
| 24 return true; | 26 return true; |
| 25 } | 27 } |
| 26 wm::WindowState* window_state = wm::GetWindowState(window); | 28 wm::WindowState* window_state = wm::GetWindowState(window); |
| 27 if (!window_state->CanMinimize()) | 29 if (!window_state->CanMinimize()) |
| 28 return false; | 30 return false; |
| 29 window_state->Minimize(); | 31 window_state->Minimize(); |
| 30 return true; | 32 return true; |
| 31 } | 33 } |
| 32 | 34 |
| 33 void ToggleMaximized() { | 35 void ToggleMaximized() { |
| 34 wm::WindowState* window_state = wm::GetActiveWindowState(); | 36 wm::WindowState* window_state = wm::GetActiveWindowState(); |
| 35 if (!window_state) | 37 if (!window_state) |
| 36 return; | 38 return; |
| 37 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Maximized")); | 39 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Maximized")); |
| 38 window_state->OnWMEvent(wm::TOGGLE_MAXIMIZE); | 40 window_state->OnWMEvent(wm::TOGGLE_MAXIMIZE); |
| 39 } | 41 } |
| 40 | 42 |
| 41 void ToggleFullscreen() { | 43 void ToggleFullscreen() { |
| 42 wm::WindowState* window_state = wm::GetActiveWindowState(); | 44 wm::WindowState* window_state = wm::GetActiveWindowState(); |
| 43 if (window_state) | 45 if (window_state) |
| 44 window_state->ToggleFullscreen(); | 46 window_state->ToggleFullscreen(); |
| 45 } | 47 } |
| 46 | 48 |
| 47 } // namespace accelerators | 49 } // namespace accelerators |
| 48 } // namespace ash | 50 } // namespace ash |
| OLD | NEW |