OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/bubble/bubble_manager.h" | 5 #include "components/bubble/bubble_manager.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "components/bubble/bubble_controller.h" | 10 #include "components/bubble/bubble_controller.h" |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 CloseAllMatchingBubbles(nullptr, nullptr, reason); | 60 CloseAllMatchingBubbles(nullptr, nullptr, reason); |
61 } | 61 } |
62 | 62 |
63 void BubbleManager::UpdateAllBubbleAnchors() { | 63 void BubbleManager::UpdateAllBubbleAnchors() { |
64 DCHECK(thread_checker_.CalledOnValidThread()); | 64 DCHECK(thread_checker_.CalledOnValidThread()); |
65 DCHECK_NE(manager_state_, ITERATING_BUBBLES); | 65 DCHECK_NE(manager_state_, ITERATING_BUBBLES); |
66 | 66 |
67 // Guard against bubbles being added or removed while iterating the bubbles. | 67 // Guard against bubbles being added or removed while iterating the bubbles. |
68 ManagerState original_state = manager_state_; | 68 ManagerState original_state = manager_state_; |
69 manager_state_ = ITERATING_BUBBLES; | 69 manager_state_ = ITERATING_BUBBLES; |
70 for (auto controller : controllers_) | 70 for (auto* controller : controllers_) |
71 controller->UpdateAnchorPosition(); | 71 controller->UpdateAnchorPosition(); |
72 manager_state_ = original_state; | 72 manager_state_ = original_state; |
73 } | 73 } |
74 | 74 |
75 void BubbleManager::AddBubbleManagerObserver(BubbleManagerObserver* observer) { | 75 void BubbleManager::AddBubbleManagerObserver(BubbleManagerObserver* observer) { |
76 observers_.AddObserver(observer); | 76 observers_.AddObserver(observer); |
77 } | 77 } |
78 | 78 |
79 void BubbleManager::RemoveBubbleManagerObserver( | 79 void BubbleManager::RemoveBubbleManagerObserver( |
80 BubbleManagerObserver* observer) { | 80 BubbleManagerObserver* observer) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 if ((!bubble || bubble == *i) && (!owner || (*i)->OwningFrameIs(owner)) && | 115 if ((!bubble || bubble == *i) && (!owner || (*i)->OwningFrameIs(owner)) && |
116 (*i)->ShouldClose(reason)) { | 116 (*i)->ShouldClose(reason)) { |
117 close_queue.push_back(*i); | 117 close_queue.push_back(*i); |
118 i = controllers_.weak_erase(i); | 118 i = controllers_.weak_erase(i); |
119 } else { | 119 } else { |
120 ++i; | 120 ++i; |
121 } | 121 } |
122 } | 122 } |
123 manager_state_ = original_state; | 123 manager_state_ = original_state; |
124 | 124 |
125 for (auto controller : close_queue) { | 125 for (auto* controller : close_queue) { |
126 controller->DoClose(reason); | 126 controller->DoClose(reason); |
127 | 127 |
128 FOR_EACH_OBSERVER(BubbleManagerObserver, observers_, | 128 FOR_EACH_OBSERVER(BubbleManagerObserver, observers_, |
129 OnBubbleClosed(controller->AsWeakPtr(), reason)); | 129 OnBubbleClosed(controller->AsWeakPtr(), reason)); |
130 } | 130 } |
131 | 131 |
132 return !close_queue.empty(); | 132 return !close_queue.empty(); |
133 } | 133 } |
OLD | NEW |