• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/ui/views/frame/browser_bubble_host.h"
6 
7 #include "base/logging.h"
8 #include "chrome/browser/ui/views/browser_bubble.h"
9 
BrowserBubbleHost()10 BrowserBubbleHost::BrowserBubbleHost() {}
11 
~BrowserBubbleHost()12 BrowserBubbleHost::~BrowserBubbleHost() {}
13 
WindowMoved()14 void BrowserBubbleHost::WindowMoved() {
15   // Do safe iteration in case the bubble winds up closing as a result of this
16   // message.
17   for (BubbleSet::iterator i = browser_bubbles_.begin();
18        i != browser_bubbles_.end();) {
19     BubbleSet::iterator bubble = i++;
20     (*bubble)->BrowserWindowMoved();
21   }
22 }
23 
AttachBrowserBubble(BrowserBubble * bubble)24 void BrowserBubbleHost::AttachBrowserBubble(BrowserBubble* bubble) {
25   DCHECK(browser_bubbles_.find(bubble) == browser_bubbles_.end()) <<
26       "Attempt to register the same BrowserBubble multiple times.";
27   browser_bubbles_.insert(bubble);
28 }
29 
DetachBrowserBubble(BrowserBubble * bubble)30 void BrowserBubbleHost::DetachBrowserBubble(BrowserBubble* bubble) {
31   BubbleSet::iterator it = browser_bubbles_.find(bubble);
32   DCHECK(it != browser_bubbles_.end()) <<
33       "Attempt to detach an unrecognized BrowserBubble.";
34   if (it != browser_bubbles_.end())
35     browser_bubbles_.erase(it);
36 }
37 
Close()38 void BrowserBubbleHost::Close() {
39   // BrowserWindowClosing will usually cause the bubble to remove itself from
40   // the set, so we need to iterate in a way that's safe against deletion.
41   for (BubbleSet::iterator i = browser_bubbles_.begin();
42        i != browser_bubbles_.end();) {
43     BubbleSet::iterator bubble = i++;
44     (*bubble)->BrowserWindowClosing();
45   }
46 }
47 
48