| 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/aura/wm_window_aura.h" | 5 #include "ash/aura/wm_window_aura.h" |
| 6 | 6 |
| 7 #include "ash/aura/aura_layout_manager_adapter.h" | 7 #include "ash/aura/aura_layout_manager_adapter.h" |
| 8 #include "ash/aura/wm_root_window_controller_aura.h" | 8 #include "ash/aura/wm_root_window_controller_aura.h" |
| 9 #include "ash/aura/wm_shell_aura.h" | 9 #include "ash/aura/wm_shell_aura.h" |
| 10 #include "ash/common/ash_constants.h" | 10 #include "ash/common/ash_constants.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 } // namespace | 79 } // namespace |
| 80 | 80 |
| 81 WmWindowAura::WmWindowAura(aura::Window* window) | 81 WmWindowAura::WmWindowAura(aura::Window* window) |
| 82 : window_(window), | 82 : window_(window), |
| 83 // Mirrors that of aura::Window. | 83 // Mirrors that of aura::Window. |
| 84 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY) { | 84 observers_(base::ObserverList<WmWindowObserver>::NOTIFY_EXISTING_ONLY) { |
| 85 window_->AddObserver(this); | 85 window_->AddObserver(this); |
| 86 window_->SetProperty(kWmWindowKey, this); | 86 window_->SetProperty(kWmWindowKey, this); |
| 87 } | 87 } |
| 88 | 88 |
| 89 WmWindowAura::~WmWindowAura() { |
| 90 window_->RemoveObserver(this); |
| 91 } |
| 92 |
| 89 // static | 93 // static |
| 90 const WmWindow* WmWindowAura::Get(const aura::Window* window) { | 94 const WmWindow* WmWindowAura::Get(const aura::Window* window) { |
| 91 if (!window) | 95 if (!window) |
| 92 return nullptr; | 96 return nullptr; |
| 93 | 97 |
| 94 const WmWindow* wm_window = window->GetProperty(kWmWindowKey); | 98 const WmWindow* wm_window = window->GetProperty(kWmWindowKey); |
| 95 if (wm_window) | 99 if (wm_window) |
| 96 return wm_window; | 100 return wm_window; |
| 97 // WmWindowAura is owned by the aura::Window. | 101 // WmWindowAura is owned by the aura::Window. |
| 98 // TODO(sky): fix constness. | 102 // TODO(sky): fix constness. |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 632 } | 636 } |
| 633 | 637 |
| 634 void WmWindowAura::AddObserver(WmWindowObserver* observer) { | 638 void WmWindowAura::AddObserver(WmWindowObserver* observer) { |
| 635 observers_.AddObserver(observer); | 639 observers_.AddObserver(observer); |
| 636 } | 640 } |
| 637 | 641 |
| 638 void WmWindowAura::RemoveObserver(WmWindowObserver* observer) { | 642 void WmWindowAura::RemoveObserver(WmWindowObserver* observer) { |
| 639 observers_.RemoveObserver(observer); | 643 observers_.RemoveObserver(observer); |
| 640 } | 644 } |
| 641 | 645 |
| 642 WmWindowAura::~WmWindowAura() { | 646 bool WmWindowAura::HasObserver(const WmWindowObserver* observer) const { |
| 643 window_->RemoveObserver(this); | 647 return observers_.HasObserver(observer); |
| 644 } | 648 } |
| 645 | 649 |
| 646 void WmWindowAura::OnWindowHierarchyChanging( | 650 void WmWindowAura::OnWindowHierarchyChanging( |
| 647 const HierarchyChangeParams& params) { | 651 const HierarchyChangeParams& params) { |
| 648 WmWindowObserver::TreeChangeParams wm_params; | 652 WmWindowObserver::TreeChangeParams wm_params; |
| 649 wm_params.target = Get(params.target); | 653 wm_params.target = Get(params.target); |
| 650 wm_params.new_parent = Get(params.new_parent); | 654 wm_params.new_parent = Get(params.new_parent); |
| 651 wm_params.old_parent = Get(params.old_parent); | 655 wm_params.old_parent = Get(params.old_parent); |
| 652 FOR_EACH_OBSERVER(WmWindowObserver, observers_, | 656 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 653 OnWindowTreeChanging(this, wm_params)); | 657 OnWindowTreeChanging(this, wm_params)); |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 712 bool visible) { | 716 bool visible) { |
| 713 FOR_EACH_OBSERVER(WmWindowObserver, observers_, | 717 FOR_EACH_OBSERVER(WmWindowObserver, observers_, |
| 714 OnWindowVisibilityChanging(this, visible)); | 718 OnWindowVisibilityChanging(this, visible)); |
| 715 } | 719 } |
| 716 | 720 |
| 717 void WmWindowAura::OnWindowTitleChanged(aura::Window* window) { | 721 void WmWindowAura::OnWindowTitleChanged(aura::Window* window) { |
| 718 FOR_EACH_OBSERVER(WmWindowObserver, observers_, OnWindowTitleChanged(this)); | 722 FOR_EACH_OBSERVER(WmWindowObserver, observers_, OnWindowTitleChanged(this)); |
| 719 } | 723 } |
| 720 | 724 |
| 721 } // namespace ash | 725 } // namespace ash |
| OLD | NEW |