Index: components/bubble/bubble_manager.cc |
diff --git a/components/bubble/bubble_manager.cc b/components/bubble/bubble_manager.cc |
index 36902a37d4f398d224f138b6cb2c33ea6a5123f3..82e0420dda90e4610cb79423d0d600570e6145cd 100644 |
--- a/components/bubble/bubble_manager.cc |
+++ b/components/bubble/bubble_manager.cc |
@@ -47,7 +47,7 @@ bool BubbleManager::CloseBubble(BubbleReference bubble, |
BubbleCloseReason reason) { |
DCHECK(thread_checker_.CalledOnValidThread()); |
DCHECK_NE(manager_state_, ITERATING_BUBBLES); |
- return CloseAllMatchingBubbles(bubble.get(), reason); |
+ return CloseAllMatchingBubbles(bubble.get(), nullptr, reason); |
} |
void BubbleManager::CloseAllBubbles(BubbleCloseReason reason) { |
@@ -56,7 +56,7 @@ void BubbleManager::CloseAllBubbles(BubbleCloseReason reason) { |
DCHECK_NE(reason, BUBBLE_CLOSE_CANCELED); |
DCHECK(thread_checker_.CalledOnValidThread()); |
DCHECK_NE(manager_state_, ITERATING_BUBBLES); |
- CloseAllMatchingBubbles(nullptr, reason); |
+ CloseAllMatchingBubbles(nullptr, nullptr, reason); |
} |
void BubbleManager::UpdateAllBubbleAnchors() { |
@@ -89,15 +89,27 @@ void BubbleManager::FinalizePendingRequests() { |
CloseAllBubbles(BUBBLE_CLOSE_FORCED); |
} |
-bool BubbleManager::CloseAllMatchingBubbles(BubbleController* match, |
- BubbleCloseReason reason) { |
+void BubbleManager::CloseBubblesOwnedBy(const content::RenderFrameHost* frame) { |
+ CloseAllMatchingBubbles(nullptr, frame, BUBBLE_CLOSE_FRAME_DESTROYED); |
+} |
+ |
+bool BubbleManager::CloseAllMatchingBubbles( |
+ BubbleController* match, |
+ const content::RenderFrameHost* frame, |
+ BubbleCloseReason reason) { |
ScopedVector<BubbleController> close_queue; |
// Guard against bubbles being added or removed while iterating the bubbles. |
ManagerState original_state = manager_state_; |
manager_state_ = ITERATING_BUBBLES; |
for (auto iter = controllers_.begin(); iter != controllers_.end();) { |
- if ((!match || match == *iter) && (*iter)->ShouldClose(reason)) { |
+ bool matches = true; |
hcarmona
2016/02/05 22:48:24
If both |match| and |frame| are passed in, should
Jeffrey Yasskin
2016/02/08 23:59:09
Right now, only one is ever specified. I lean towa
hcarmona
2016/02/09 00:31:05
Agreed, lambda would be over-engineering.
Can we
Peter Kasting
2016/02/09 00:42:41
Hmm. I'm a little uneasy about using DCHECK like
hcarmona
2016/02/09 00:59:44
I can't think of a reason we would specify a speci
|
+ if (match && match != *iter) |
+ matches = false; |
+ if (frame && !(*iter)->OwningFrameIs(frame)) |
+ matches = false; |
+ |
+ if (matches && (*iter)->ShouldClose(reason)) { |
Peter Kasting
2016/02/06 04:13:08
Nit: Shorter and, IMO, more readable due to omitti
Jeffrey Yasskin
2016/02/08 23:59:09
I had some trouble decoding the long boolean expre
|
close_queue.push_back(*iter); |
iter = controllers_.weak_erase(iter); |
} else { |