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

Side by Side Diff: chrome/browser/ui/browser_list_impl.h

Issue 10690151: Move implementation of BrowserList onto an inner, instantiatable class, BrowserListImpl. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 5 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
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #ifndef CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_
6 #define CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_
7
8 #include "base/observer_list.h"
9 #include "chrome/browser/ui/host_desktop.h"
10
11 class Browser;
12 class BrowserList;
13 class Profile;
14
15 namespace chrome {
16
17 class BrowserListObserver;
18
19 // Maintains a list of Browser objects present in a given HostDesktop (see
20 // HostDesktopType).
21 class BrowserListImpl {
22 public:
23 typedef std::vector<Browser*> BrowserVector;
24 typedef BrowserVector::iterator iterator;
25 typedef BrowserVector::const_iterator const_iterator;
26 typedef BrowserVector::const_reverse_iterator const_reverse_iterator;
27
28 static BrowserListImpl* GetInstance(HostDesktopType type);
29
30 // Adds and removes browsers from the global list. The browser object should
31 // be valid BEFORE these calls (for the benefit of observers), so notify and
32 // THEN delete the object.
33 void AddBrowser(Browser* browser);
34 void RemoveBrowser(Browser* browser);
35
36 void AddObserver(BrowserListObserver* observer);
37 void RemoveObserver(BrowserListObserver* observer);
38
39 // Called by Browser objects when their window is activated (focused). This
40 // allows us to determine what the last active Browser was.
41 void SetLastActive(Browser* browser);
42
43 Browser* GetLastActive();
44
45 // Closes all browsers for |profile|.
46 void CloseAllBrowsersWithProfile(Profile* profile);
47
48 // Browsers are added to the list before they have constructed windows,
49 // so the |window()| member function may return NULL.
50 const_iterator begin();
51 const_iterator end();
52
53 bool empty();
jam 2012/07/12 18:53:22 nit: according to the style guide, these should on
54 size_t size();
55
56 // Returns iterated access to list of open browsers ordered by when
57 // they were last active. The underlying data structure is a vector
58 // and we push_back on recent access so a reverse iterator gives the
59 // latest accessed browser first.
60 const_reverse_iterator begin_last_active();
jam 2012/07/12 18:53:22 ditto
61 const_reverse_iterator end_last_active();
62
63 // Returns true if at least one incognito window is open.
64 bool IsIncognitoWindowOpen();
65
66 // Returns true if at least one incognito window is open for |profile|.
67 bool IsIncognitoWindowOpenForProfile(Profile* profile);
68
69 private:
70 BrowserListImpl();
71 ~BrowserListImpl();
72
73 // Helper method to remove a browser instance from a list of browsers
74 void RemoveBrowserFrom(Browser* browser, BrowserVector* browser_list);
75
76 ObserverList<BrowserListObserver> observers_;
77
78 BrowserVector browsers_;
79 BrowserVector last_active_browsers_;
80
81 // Nothing fancy, since we only have two HDTs.
82 static BrowserListImpl* native_instance_;
83 static BrowserListImpl* ash_instance_;
84
85 DISALLOW_COPY_AND_ASSIGN(BrowserListImpl);
86 };
87
88 } // namespace chrome
89
90 #endif // CHROME_BROWSER_UI_BROWSER_LIST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698