| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/wm/core/transient_window_controller.h" | 5 #include "ui/wm/core/transient_window_controller.h" |
| 6 | 6 |
| 7 #include "ui/aura/client/transient_window_client_observer.h" |
| 7 #include "ui/wm/core/transient_window_manager.h" | 8 #include "ui/wm/core/transient_window_manager.h" |
| 8 | 9 |
| 9 namespace wm { | 10 namespace wm { |
| 10 | 11 |
| 12 // static |
| 13 TransientWindowController* TransientWindowController::instance_ = nullptr; |
| 14 |
| 11 TransientWindowController::TransientWindowController() { | 15 TransientWindowController::TransientWindowController() { |
| 16 DCHECK(!instance_); |
| 17 instance_ = this; |
| 12 } | 18 } |
| 13 | 19 |
| 14 TransientWindowController::~TransientWindowController() { | 20 TransientWindowController::~TransientWindowController() { |
| 21 DCHECK_EQ(instance_, this); |
| 22 instance_ = nullptr; |
| 15 } | 23 } |
| 16 | 24 |
| 17 void TransientWindowController::AddTransientChild(aura::Window* parent, | 25 void TransientWindowController::AddTransientChild(aura::Window* parent, |
| 18 aura::Window* child) { | 26 aura::Window* child) { |
| 19 TransientWindowManager::Get(parent)->AddTransientChild(child); | 27 TransientWindowManager::Get(parent)->AddTransientChild(child); |
| 20 } | 28 } |
| 21 | 29 |
| 22 void TransientWindowController::RemoveTransientChild(aura::Window* parent, | 30 void TransientWindowController::RemoveTransientChild(aura::Window* parent, |
| 23 aura::Window* child) { | 31 aura::Window* child) { |
| 24 TransientWindowManager::Get(parent)->RemoveTransientChild(child); | 32 TransientWindowManager::Get(parent)->RemoveTransientChild(child); |
| 25 } | 33 } |
| 26 | 34 |
| 27 aura::Window* TransientWindowController::GetTransientParent( | 35 aura::Window* TransientWindowController::GetTransientParent( |
| 28 aura::Window* window) { | 36 aura::Window* window) { |
| 29 return const_cast<aura::Window*>(GetTransientParent( | 37 return const_cast<aura::Window*>(GetTransientParent( |
| 30 const_cast<const aura::Window*>(window))); | 38 const_cast<const aura::Window*>(window))); |
| 31 } | 39 } |
| 32 | 40 |
| 33 const aura::Window* TransientWindowController::GetTransientParent( | 41 const aura::Window* TransientWindowController::GetTransientParent( |
| 34 const aura::Window* window) { | 42 const aura::Window* window) { |
| 35 const TransientWindowManager* window_manager = | 43 const TransientWindowManager* window_manager = |
| 36 TransientWindowManager::Get(window); | 44 TransientWindowManager::Get(window); |
| 37 return window_manager ? window_manager->transient_parent() : NULL; | 45 return window_manager ? window_manager->transient_parent() : NULL; |
| 38 } | 46 } |
| 39 | 47 |
| 48 void TransientWindowController::AddObserver( |
| 49 aura::client::TransientWindowClientObserver* observer) { |
| 50 observers_.AddObserver(observer); |
| 51 } |
| 52 |
| 53 void TransientWindowController::RemoveObserver( |
| 54 aura::client::TransientWindowClientObserver* observer) { |
| 55 observers_.RemoveObserver(observer); |
| 56 } |
| 57 |
| 40 } // namespace wm | 58 } // namespace wm |
| OLD | NEW |