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_manager.h" | 5 #include "ui/wm/core/transient_window_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <functional> | 8 #include <functional> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| 11 #include "base/stl_util.h" |
11 #include "ui/aura/client/transient_window_client_observer.h" | 12 #include "ui/aura/client/transient_window_client_observer.h" |
12 #include "ui/aura/window.h" | 13 #include "ui/aura/window.h" |
13 #include "ui/aura/window_tracker.h" | 14 #include "ui/aura/window_tracker.h" |
14 #include "ui/base/class_property.h" | 15 #include "ui/base/class_property.h" |
15 #include "ui/wm/core/transient_window_controller.h" | 16 #include "ui/wm/core/transient_window_controller.h" |
16 #include "ui/wm/core/transient_window_observer.h" | 17 #include "ui/wm/core/transient_window_observer.h" |
17 #include "ui/wm/core/transient_window_stacking_client.h" | 18 #include "ui/wm/core/transient_window_stacking_client.h" |
18 #include "ui/wm/core/window_util.h" | 19 #include "ui/wm/core/window_util.h" |
19 | 20 |
20 using aura::Window; | 21 using aura::Window; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 } | 57 } |
57 | 58 |
58 void TransientWindowManager::AddTransientChild(Window* child) { | 59 void TransientWindowManager::AddTransientChild(Window* child) { |
59 // TransientWindowStackingClient does the stacking of transient windows. If it | 60 // TransientWindowStackingClient does the stacking of transient windows. If it |
60 // isn't installed stacking is going to be wrong. | 61 // isn't installed stacking is going to be wrong. |
61 DCHECK(TransientWindowStackingClient::instance_); | 62 DCHECK(TransientWindowStackingClient::instance_); |
62 | 63 |
63 TransientWindowManager* child_manager = Get(child); | 64 TransientWindowManager* child_manager = Get(child); |
64 if (child_manager->transient_parent_) | 65 if (child_manager->transient_parent_) |
65 Get(child_manager->transient_parent_)->RemoveTransientChild(child); | 66 Get(child_manager->transient_parent_)->RemoveTransientChild(child); |
66 DCHECK(std::find(transient_children_.begin(), transient_children_.end(), | 67 DCHECK(!base::ContainsValue(transient_children_, child)); |
67 child) == transient_children_.end()); | |
68 transient_children_.push_back(child); | 68 transient_children_.push_back(child); |
69 child_manager->transient_parent_ = window_; | 69 child_manager->transient_parent_ = window_; |
70 | 70 |
71 for (aura::client::TransientWindowClientObserver& observer : | 71 for (aura::client::TransientWindowClientObserver& observer : |
72 TransientWindowController::Get()->observers_) { | 72 TransientWindowController::Get()->observers_) { |
73 observer.OnTransientChildWindowAdded(window_, child); | 73 observer.OnTransientChildWindowAdded(window_, child); |
74 } | 74 } |
75 | 75 |
76 // Restack |child| properly above its transient parent, if they share the same | 76 // Restack |child| properly above its transient parent, if they share the same |
77 // parent. | 77 // parent. |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 // Destroy transient children, only after we've removed ourselves from our | 237 // Destroy transient children, only after we've removed ourselves from our |
238 // parent, as destroying an active transient child may otherwise attempt to | 238 // parent, as destroying an active transient child may otherwise attempt to |
239 // refocus us. | 239 // refocus us. |
240 Windows transient_children(transient_children_); | 240 Windows transient_children(transient_children_); |
241 for (auto* child : transient_children) | 241 for (auto* child : transient_children) |
242 delete child; | 242 delete child; |
243 DCHECK(transient_children_.empty()); | 243 DCHECK(transient_children_.empty()); |
244 } | 244 } |
245 | 245 |
246 } // namespace wm | 246 } // namespace wm |
OLD | NEW |