| 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( |
| 26 mru_windows[mru_windows.size() > 1 ? 1 : 0])->Activate(); |
| 27 } |
| 24 return true; | 28 return true; |
| 25 } | 29 } |
| 26 wm::WindowState* window_state = wm::GetWindowState(window); | 30 wm::WindowState* window_state = wm::GetWindowState(window); |
| 27 if (!window_state->CanMinimize()) | 31 if (!window_state->CanMinimize()) |
| 28 return false; | 32 return false; |
| 29 window_state->Minimize(); | 33 window_state->Minimize(); |
| 30 return true; | 34 return true; |
| 31 } | 35 } |
| 32 | 36 |
| 33 void ToggleMaximized() { | 37 void ToggleMaximized() { |
| 34 wm::WindowState* window_state = wm::GetActiveWindowState(); | 38 wm::WindowState* window_state = wm::GetActiveWindowState(); |
| 35 if (!window_state) | 39 if (!window_state) |
| 36 return; | 40 return; |
| 37 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Maximized")); | 41 base::RecordAction(base::UserMetricsAction("Accel_Toggle_Maximized")); |
| 38 window_state->OnWMEvent(wm::TOGGLE_MAXIMIZE); | 42 window_state->OnWMEvent(wm::TOGGLE_MAXIMIZE); |
| 39 } | 43 } |
| 40 | 44 |
| 41 void ToggleFullscreen() { | 45 void ToggleFullscreen() { |
| 42 wm::WindowState* window_state = wm::GetActiveWindowState(); | 46 wm::WindowState* window_state = wm::GetActiveWindowState(); |
| 43 if (window_state) | 47 if (window_state) |
| 44 window_state->ToggleFullscreen(); | 48 window_state->ToggleFullscreen(); |
| 45 } | 49 } |
| 46 | 50 |
| 47 } // namespace accelerators | 51 } // namespace accelerators |
| 48 } // namespace ash | 52 } // namespace ash |
| OLD | NEW |