Index: chrome/browser/ui/browser_list.cc |
=================================================================== |
--- chrome/browser/ui/browser_list.cc (revision 88539) |
+++ chrome/browser/ui/browser_list.cc (working copy) |
@@ -155,6 +155,24 @@ |
return NULL; |
} |
+// Returns a vector of all browsers in the specified iterator that return true |
+// from |BrowserMatches|, or an empty vector if no browsers match the |
+// arguments. See |BrowserMatches| for details about the arguments. |
+template <class T> |
+std::vector<Browser*> FindAllBrowsersMatching( |
+ const T& begin, |
+ const T& end, |
+ Profile* profile, |
+ Browser::WindowFeature window_feature, |
+ uint32 match_types) { |
+ std::vector<Browser*> browsers; |
+ for (T i = begin; i != end; ++i) { |
+ if (BrowserMatches(*i, profile, window_feature, match_types)) |
+ browsers.push_back(*i); |
+ } |
+ return browsers; |
+} |
+ |
Browser* FindBrowserWithTabbedOrAnyType(Profile* profile, |
bool match_tabbed, |
bool match_incognito) { |
@@ -580,6 +598,14 @@ |
} |
// static |
+std::vector<Browser*> BrowserList::GetBrowsersWithProfile(Profile* profile) { |
+ std::vector<Browser*> browsers = FindAllBrowsersMatching( |
+ BrowserList::begin(), BrowserList::end(), profile, |
+ Browser::FEATURE_NONE, kMatchAny); |
+ return browsers; |
+} |
+ |
+// static |
size_t BrowserList::GetBrowserCountForType(Profile* profile, |
bool match_tabbed) { |
size_t result = 0; |