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

Unified Diff: chrome/browser/ui/browser_finder.cc

Issue 10855183: Give access to browsers by Profile/HostDesktopType. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync'd to Tip Of Tree. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/browser_finder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/browser_finder.cc
diff --git a/chrome/browser/ui/browser_finder.cc b/chrome/browser/ui/browser_finder.cc
index 08467db84f9806de41cf7bd9b050f31e7fa67966..cac43140673f67194b0d69b77e6a5d4948b6a130 100644
--- a/chrome/browser/ui/browser_finder.cc
+++ b/chrome/browser/ui/browser_finder.cc
@@ -19,6 +19,14 @@ namespace browser {
namespace {
+#if defined(OS_CHROMEOS)
+chrome::HostDesktopType kDefaultHostDesktopType = chrome::HOST_DESKTOP_TYPE_ASH;
Ben Goodger (Google) 2012/08/21 21:47:20 my theory is that this will have to go in host_des
+#else
+chrome::HostDesktopType kDefaultHostDesktopType =
+ chrome::HOST_DESKTOP_TYPE_NATIVE;
+#endif
+
+
// Type used to indicate to match anything.
const int kMatchAny = 0;
@@ -75,28 +83,43 @@ Browser* FindBrowserMatching(const T& begin,
}
Browser* FindBrowserWithTabbedOrAnyType(Profile* profile,
+ chrome::HostDesktopType desktop_type,
bool match_tabbed,
bool match_original_profiles) {
+ chrome::BrowserListImpl* browser_list_impl =
+ chrome::BrowserListImpl::GetInstance(desktop_type);
+ if (!browser_list_impl)
+ return NULL;
uint32 match_types = kMatchAny;
if (match_tabbed)
match_types |= kMatchTabbed;
if (match_original_profiles)
match_types |= kMatchOriginalProfile;
- Browser* browser = FindBrowserMatching(
- BrowserList::begin_last_active(), BrowserList::end_last_active(),
- profile, Browser::FEATURE_NONE, match_types);
+ Browser* browser = FindBrowserMatching(browser_list_impl->begin_last_active(),
+ browser_list_impl->end_last_active(),
+ profile,
+ Browser::FEATURE_NONE,
+ match_types);
// Fall back to a forward scan of all Browsers if no active one was found.
- return browser ? browser :
- FindBrowserMatching(BrowserList::begin(), BrowserList::end(), profile,
- Browser::FEATURE_NONE, match_types);
+ return browser ? browser : FindBrowserMatching(browser_list_impl->begin(),
+ browser_list_impl->end(),
+ profile,
+ Browser::FEATURE_NONE,
+ match_types);
}
-size_t GetBrowserCountImpl(Profile* profile, uint32 match_types) {
+size_t GetBrowserCountImpl(Profile* profile,
+ chrome::HostDesktopType desktop_type,
+ uint32 match_types) {
+ chrome::BrowserListImpl* browser_list_impl =
+ chrome::BrowserListImpl::GetInstance(desktop_type);
size_t count = 0;
- for (BrowserList::const_iterator i = BrowserList::begin();
- i != BrowserList::end(); ++i) {
- if (BrowserMatches(*i, profile, Browser::FEATURE_NONE, match_types))
- count++;
+ if (browser_list_impl) {
+ for (BrowserList::const_iterator i = browser_list_impl->begin();
+ i != browser_list_impl->end(); ++i) {
+ if (BrowserMatches(*i, profile, Browser::FEATURE_NONE, match_types))
+ count++;
+ }
}
return count;
}
@@ -105,6 +128,7 @@ size_t GetBrowserCountImpl(Profile* profile, uint32 match_types) {
Browser* FindTabbedBrowser(Profile* profile, bool match_original_profiles) {
return FindBrowserWithTabbedOrAnyType(profile,
+ kDefaultHostDesktopType,
true,
match_original_profiles);
}
@@ -118,12 +142,14 @@ Browser* FindOrCreateTabbedBrowser(Profile* profile) {
Browser* FindAnyBrowser(Profile* profile, bool match_original_profiles) {
return FindBrowserWithTabbedOrAnyType(profile,
+ kDefaultHostDesktopType,
false,
match_original_profiles);
}
-Browser* FindBrowserWithProfile(Profile* profile) {
- return FindAnyBrowser(profile, false);
+Browser* FindBrowserWithProfile(Profile* profile,
+ chrome::HostDesktopType desktop_type) {
+ return FindBrowserWithTabbedOrAnyType(profile, desktop_type, false, false);
}
Browser* FindBrowserWithID(SessionID::id_type desired_id) {
@@ -171,11 +197,11 @@ Browser* FindLastActiveWithHostDesktopType(chrome::HostDesktopType type) {
}
size_t GetBrowserCount(Profile* profile) {
- return GetBrowserCountImpl(profile, kMatchAny);
+ return GetBrowserCountImpl(profile, kDefaultHostDesktopType, kMatchAny);
}
size_t GetTabbedBrowserCount(Profile* profile) {
- return GetBrowserCountImpl(profile, kMatchTabbed);
+ return GetBrowserCountImpl(profile, kDefaultHostDesktopType, kMatchTabbed);
}
} // namespace browser
« no previous file with comments | « chrome/browser/ui/browser_finder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698