Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: chrome/browser/ui/browser_list.cc

Issue 12258019: Make BrowserList::(Add|Remove)Observer add the observer to every desktop's browser list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Need to friend the methods directly since they are static (otherwise linux_clang doesn't like it) Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/browser_list.h ('k') | chrome/browser/ui/browser_list_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_list.h ('k') | chrome/browser/ui/browser_list_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698