OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/browser_list.h" | 5 #include "chrome/browser/ui/browser_list.h" |
6 | 6 |
7 #include "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/browser.h" | 8 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/browser/ui/browser_iterator.h" | 9 #include "chrome/browser/ui/browser_iterator.h" |
10 #include "chrome/browser/ui/browser_list_impl.h" | 10 #include "chrome/browser/ui/browser_list_impl.h" |
11 #include "chrome/browser/ui/browser_list_observer.h" | 11 #include "chrome/browser/ui/browser_list_observer.h" |
12 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 13 #include "chrome/browser/ui/host_desktop.h" |
13 | 14 |
14 using content::WebContents; | 15 using content::WebContents; |
15 | 16 |
16 namespace { | 17 namespace { |
17 | 18 |
18 chrome::BrowserListImpl* GetNativeList() { | 19 chrome::BrowserListImpl* GetNativeList() { |
19 return chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); | 20 return chrome::BrowserListImpl::GetInstance(chrome::HOST_DESKTOP_TYPE_NATIVE); |
20 } | 21 } |
21 | 22 |
22 } // namespace | 23 } // namespace |
23 | 24 |
24 // static | 25 // static |
25 void BrowserList::AddBrowser(Browser* browser) { | 26 void BrowserList::AddBrowser(Browser* browser) { |
26 chrome::BrowserListImpl::GetInstance(browser->host_desktop_type())-> | 27 chrome::BrowserListImpl::GetInstance(browser->host_desktop_type())-> |
27 AddBrowser(browser); | 28 AddBrowser(browser); |
28 } | 29 } |
29 | 30 |
30 // static | 31 // static |
31 void BrowserList::RemoveBrowser(Browser* browser) { | 32 void BrowserList::RemoveBrowser(Browser* browser) { |
32 chrome::BrowserListImpl::GetInstance(browser->host_desktop_type())-> | 33 chrome::BrowserListImpl::GetInstance(browser->host_desktop_type())-> |
33 RemoveBrowser(browser); | 34 RemoveBrowser(browser); |
34 } | 35 } |
35 | 36 |
36 // static | 37 // static |
37 void BrowserList::AddObserver(chrome::BrowserListObserver* observer) { | 38 void BrowserList::AddObserver(chrome::BrowserListObserver* observer) { |
38 GetNativeList()->AddObserver(observer); | 39 for (chrome::HostDesktopType t = chrome::HOST_DESKTOP_TYPE_FIRST; |
| 40 t < chrome::HOST_DESKTOP_TYPE_COUNT; |
| 41 t = static_cast<chrome::HostDesktopType>(t + 1)) { |
| 42 chrome::BrowserListImpl::GetInstance(t)->AddObserver(observer); |
| 43 } |
39 } | 44 } |
40 | 45 |
41 // static | 46 // static |
42 void BrowserList::RemoveObserver(chrome::BrowserListObserver* observer) { | 47 void BrowserList::RemoveObserver(chrome::BrowserListObserver* observer) { |
43 GetNativeList()->RemoveObserver(observer); | 48 for (chrome::HostDesktopType t = chrome::HOST_DESKTOP_TYPE_FIRST; |
| 49 t < chrome::HOST_DESKTOP_TYPE_COUNT; |
| 50 t = static_cast<chrome::HostDesktopType>(t + 1)) { |
| 51 chrome::BrowserListImpl::GetInstance(t)->RemoveObserver(observer); |
| 52 } |
44 } | 53 } |
45 | 54 |
46 void BrowserList::CloseAllBrowsersWithProfile(Profile* profile) { | 55 void BrowserList::CloseAllBrowsersWithProfile(Profile* profile) { |
47 BrowserVector browsers_to_close; | 56 BrowserVector browsers_to_close; |
48 for (chrome::BrowserIterator it; !it.done(); it.Next()) { | 57 for (chrome::BrowserIterator it; !it.done(); it.Next()) { |
49 if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile()) | 58 if (it->profile()->GetOriginalProfile() == profile->GetOriginalProfile()) |
50 browsers_to_close.push_back(*it); | 59 browsers_to_close.push_back(*it); |
51 } | 60 } |
52 | 61 |
53 for (BrowserVector::const_iterator it = browsers_to_close.begin(); | 62 for (BrowserVector::const_iterator it = browsers_to_close.begin(); |
(...skipping 20 matching lines...) Expand all Loading... |
74 | 83 |
75 // static | 84 // static |
76 bool BrowserList::IsOffTheRecordSessionActive() { | 85 bool BrowserList::IsOffTheRecordSessionActive() { |
77 return GetNativeList()->IsIncognitoWindowOpen(); | 86 return GetNativeList()->IsIncognitoWindowOpen(); |
78 } | 87 } |
79 | 88 |
80 // static | 89 // static |
81 bool BrowserList::IsOffTheRecordSessionActiveForProfile(Profile* profile) { | 90 bool BrowserList::IsOffTheRecordSessionActiveForProfile(Profile* profile) { |
82 return GetNativeList()->IsIncognitoWindowOpenForProfile(profile); | 91 return GetNativeList()->IsIncognitoWindowOpenForProfile(profile); |
83 } | 92 } |
OLD | NEW |