Chromium Code Reviews| Index: chrome/browser/ui/browser_finder.cc |
| diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc |
| index cd485eeff4cee19132e074146208d3eddd74fbfc..263a0ffb12ba2512b71dccd1e0abf20bceac081b 100644 |
| --- a/chrome/browser/ui/browser_finder.cc |
| +++ b/chrome/browser/ui/browser_finder.cc |
| @@ -105,6 +105,23 @@ Browser* FindBrowserMatching(const T& begin, |
| return NULL; |
| } |
| +// Returns all browsers in the specified iterator that returns true from |
| +// |BrowserMatches|. See |BrowserMatches| for details on 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*> matches; |
| + for (T i = begin; i != end; ++i) { |
| + if (BrowserMatches(*i, profile, window_feature, match_types)) |
| + matches.push_back(*i); |
| + } |
| + return matches; |
| +} |
| + |
| Browser* FindBrowserWithTabbedOrAnyType(Profile* profile, |
| chrome::HostDesktopType desktop_type, |
| bool match_tabbed, |
| @@ -130,6 +147,35 @@ Browser* FindBrowserWithTabbedOrAnyType(Profile* profile, |
| match_types); |
| } |
| +std::vector<Browser*> FindAllBrowsersWithTabbedOrAnyType( |
|
mark a. foltz
2016/01/04 20:11:41
It seems like you are adding duplicate implementat
GeorgeZ
2016/01/06 22:41:39
browser matching using function.
bool BrowserMatch
GeorgeZ
2016/01/08 19:39:02
According Avi@, I removed all change in browser_fi
|
| + Profile* profile, |
| + chrome::HostDesktopType desktop_type, |
| + bool match_tabbed, |
| + bool match_original_profiles) { |
| + std::vector<Browser*> matches; |
| + BrowserList* browser_list_impl = BrowserList::GetInstance(desktop_type); |
| + if (!browser_list_impl) |
| + return matches; |
| + uint32 match_types = kMatchAny; |
| + if (match_tabbed) |
| + match_types |= kMatchTabbed; |
| + if (match_original_profiles) |
| + match_types |= kMatchOriginalProfile; |
| + matches = |
| + FindAllBrowsersMatching(browser_list_impl->begin_last_active(), |
| + browser_list_impl->end_last_active(), profile, |
| + Browser::FEATURE_NONE, match_types); |
| + if (!matches.empty()) |
| + return matches; |
| + |
| + // Fall back to a forward scan of all Browsers if no active one was found. |
| + matches = FindAllBrowsersMatching(browser_list_impl->begin(), |
| + browser_list_impl->end(), profile, |
| + Browser::FEATURE_NONE, match_types); |
| + |
| + return matches; |
| +} |
| + |
| size_t GetBrowserCountImpl(Profile* profile, |
| chrome::HostDesktopType desktop_type, |
| uint32 match_types) { |
| @@ -172,6 +218,12 @@ Browser* FindBrowserWithProfile(Profile* profile, |
| return FindBrowserWithTabbedOrAnyType(profile, desktop_type, false, false); |
| } |
| +std::vector<Browser*> FindAllTabbedBrowsersWithProfile( |
| + Profile* profile, |
| + HostDesktopType desktop_type) { |
| + return FindAllBrowsersWithTabbedOrAnyType(profile, desktop_type, true, false); |
| +} |
| + |
| Browser* FindBrowserWithID(SessionID::id_type desired_id) { |
| for (BrowserIterator it; !it.done(); it.Next()) { |
| if (it->session_id().id() == desired_id) |