| Index: chrome/browser/ui/browser_finder.cc
|
| diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc
|
| index 9dedf681b5dc61d308848ddcfdc434dad445fc2a..83692e54266a76386aa3ed2b60109a1b52c88540 100644
|
| --- a/chrome/browser/ui/browser_finder.cc
|
| +++ b/chrome/browser/ui/browser_finder.cc
|
| @@ -108,6 +108,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_t 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,
|
| @@ -133,6 +150,35 @@ Browser* FindBrowserWithTabbedOrAnyType(Profile* profile,
|
| match_types);
|
| }
|
|
|
| +std::vector<Browser*> FindAllBrowsersWithTabbedOrAnyType(
|
| + 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_t 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_t match_types) {
|
| @@ -175,6 +221,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)
|
|
|