Chromium Code Reviews| 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 class WindowStateAura : public wm::WindowState { | |
|
James Cook
2016/05/03 18:43:10
Maybe comment on why this has to be here? At first
sky
2016/05/03 19:10:06
Yep. Added comment.
| |
| 18 public: | |
| 19 explicit WindowStateAura(WmWindow* window) : wm::WindowState(window) {} | |
| 20 ~WindowStateAura() override {} | |
| 21 | |
| 22 private: | |
| 23 DISALLOW_COPY_AND_ASSIGN(WindowStateAura); | |
| 24 }; | |
| 25 | |
| 26 } // namespace | |
| 15 | 27 |
| 16 WindowState* GetActiveWindowState() { | 28 WindowState* GetActiveWindowState() { |
| 17 aura::Window* active = GetActiveWindow(); | 29 aura::Window* active = GetActiveWindow(); |
| 18 return active ? GetWindowState(active) : nullptr; | 30 return active ? GetWindowState(active) : nullptr; |
| 19 } | 31 } |
| 20 | 32 |
| 21 WindowState* GetWindowState(aura::Window* window) { | 33 WindowState* GetWindowState(aura::Window* window) { |
| 22 if (!window) | 34 if (!window) |
| 23 return nullptr; | 35 return nullptr; |
| 24 WindowState* settings = window->GetProperty(kWindowStateKey); | 36 WindowState* settings = window->GetProperty(kWindowStateKey); |
| 25 if (!settings) { | 37 if (!settings) { |
| 26 settings = new WindowState(WmWindowAura::Get(window)); | 38 settings = new WindowStateAura(WmWindowAura::Get(window)); |
| 27 window->SetProperty(kWindowStateKey, settings); | 39 window->SetProperty(kWindowStateKey, settings); |
| 28 } | 40 } |
| 29 return settings; | 41 return settings; |
| 30 } | 42 } |
| 31 | 43 |
| 32 const WindowState* GetWindowState(const aura::Window* window) { | 44 const WindowState* GetWindowState(const aura::Window* window) { |
| 33 return GetWindowState(const_cast<aura::Window*>(window)); | 45 return GetWindowState(const_cast<aura::Window*>(window)); |
| 34 } | 46 } |
| 35 | 47 |
| 36 } // namespace wm | 48 } // namespace wm |
| 37 } // namespace ash | 49 } // namespace ash |
| OLD | NEW |