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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/chrome_bubble_manager.h"
7 #include "chrome/browser/ui/tabs/tab_strip_model.h"
8 #include "content/public/browser/browser_thread.h"
9 #include "content/public/browser/web_contents.h"
11 ChromeBubbleManager::ChromeBubbleManager(TabStripModel
* tab_strip_model
)
12 : tab_strip_model_(tab_strip_model
) {
13 DCHECK_CURRENTLY_ON(content::BrowserThread::UI
);
14 DCHECK(tab_strip_model_
);
15 tab_strip_model_
->AddObserver(this);
18 ChromeBubbleManager::~ChromeBubbleManager() {
19 tab_strip_model_
->RemoveObserver(this);
22 void ChromeBubbleManager::TabDetachedAt(content::WebContents
* contents
,
24 CloseAllBubbles(BUBBLE_CLOSE_TABDETACHED
);
25 // Any bubble that didn't close should update its anchor position.
26 UpdateAllBubbleAnchors();
29 void ChromeBubbleManager::TabDeactivated(content::WebContents
* contents
) {
30 CloseAllBubbles(BUBBLE_CLOSE_TABSWITCHED
);
33 void ChromeBubbleManager::ActiveTabChanged(content::WebContents
* old_contents
,
34 content::WebContents
* new_contents
,
37 Observe(new_contents
);
40 void ChromeBubbleManager::DidToggleFullscreenModeForTab(
41 bool entered_fullscreen
) {
42 CloseAllBubbles(BUBBLE_CLOSE_FULLSCREEN_TOGGLED
);
43 // Any bubble that didn't close should update its anchor position.
44 UpdateAllBubbleAnchors();
47 void ChromeBubbleManager::NavigationEntryCommitted(
48 const content::LoadCommittedDetails
& load_details
) {
49 CloseAllBubbles(BUBBLE_CLOSE_NAVIGATED
);