| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/wm/window_state_aura.h" | 5 #include "ash/wm/window_state_aura.h" |
| 6 | 6 |
| 7 #include "ash/wm/aura/wm_window_aura.h" | 7 #include "ash/wm/aura/wm_window_aura.h" |
| 8 #include "ash/wm/common/window_state.h" | 8 #include "ash/wm/common/window_state.h" |
| 9 #include "ash/wm/window_properties.h" | 9 #include "ash/wm/window_properties.h" |
| 10 #include "ash/wm/window_util.h" | 10 #include "ash/wm/window_util.h" |
| 11 #include "ui/aura/window.h" | 11 #include "ui/aura/window.h" |
| 12 | 12 |
| 13 namespace ash { | 13 namespace ash { |
| 14 namespace wm { | 14 namespace wm { |
| 15 namespace { |
| 16 |
| 17 // This classes is used so that the WindowState constructor can be made |
| 18 // protected. GetWindowState() is the only place that should be creating |
| 19 // WindowState. |
| 20 class WindowStateAura : public wm::WindowState { |
| 21 public: |
| 22 explicit WindowStateAura(WmWindow* window) : wm::WindowState(window) {} |
| 23 ~WindowStateAura() override {} |
| 24 |
| 25 private: |
| 26 DISALLOW_COPY_AND_ASSIGN(WindowStateAura); |
| 27 }; |
| 28 |
| 29 } // namespace |
| 15 | 30 |
| 16 WindowState* GetActiveWindowState() { | 31 WindowState* GetActiveWindowState() { |
| 17 aura::Window* active = GetActiveWindow(); | 32 aura::Window* active = GetActiveWindow(); |
| 18 return active ? GetWindowState(active) : nullptr; | 33 return active ? GetWindowState(active) : nullptr; |
| 19 } | 34 } |
| 20 | 35 |
| 21 WindowState* GetWindowState(aura::Window* window) { | 36 WindowState* GetWindowState(aura::Window* window) { |
| 22 if (!window) | 37 if (!window) |
| 23 return nullptr; | 38 return nullptr; |
| 24 WindowState* settings = window->GetProperty(kWindowStateKey); | 39 WindowState* settings = window->GetProperty(kWindowStateKey); |
| 25 if (!settings) { | 40 if (!settings) { |
| 26 settings = new WindowState(WmWindowAura::Get(window)); | 41 settings = new WindowStateAura(WmWindowAura::Get(window)); |
| 27 window->SetProperty(kWindowStateKey, settings); | 42 window->SetProperty(kWindowStateKey, settings); |
| 28 } | 43 } |
| 29 return settings; | 44 return settings; |
| 30 } | 45 } |
| 31 | 46 |
| 32 const WindowState* GetWindowState(const aura::Window* window) { | 47 const WindowState* GetWindowState(const aura::Window* window) { |
| 33 return GetWindowState(const_cast<aura::Window*>(window)); | 48 return GetWindowState(const_cast<aura::Window*>(window)); |
| 34 } | 49 } |
| 35 | 50 |
| 36 } // namespace wm | 51 } // namespace wm |
| 37 } // namespace ash | 52 } // namespace ash |
| OLD | NEW |