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..0ca2eff724a70d756b0bcd1203e4ba030f47a631 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; |
+#else |
+chrome::HostDesktopType kDefaultHostDesktopType = |
+ chrome::HOST_DESKTOP_TYPE_NATIVE; |
+#endif |
+ |
+ |
// Type used to indicate to match anything. |
const int kMatchAny = 0; |
@@ -75,26 +83,41 @@ 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); |
+ if (!browser_list_impl) |
+ return NULL; |
size_t count = 0; |
- for (BrowserList::const_iterator i = BrowserList::begin(); |
- i != BrowserList::end(); ++i) { |
+ 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++; |
} |
@@ -105,6 +128,16 @@ size_t GetBrowserCountImpl(Profile* profile, uint32 match_types) { |
Browser* FindTabbedBrowser(Profile* profile, bool match_original_profiles) { |
return FindBrowserWithTabbedOrAnyType(profile, |
+ kDefaultHostDesktopType, |
+ true, |
+ match_original_profiles); |
+} |
+ |
+Browser* FindDesktopTabbedBrowser(Profile* profile, |
+ chrome::HostDesktopType desktop_type, |
+ bool match_original_profiles) { |
+ return FindBrowserWithTabbedOrAnyType(profile, |
+ desktop_type, |
true, |
match_original_profiles); |
} |
@@ -112,12 +145,32 @@ Browser* FindTabbedBrowser(Profile* profile, bool match_original_profiles) { |
Browser* FindOrCreateTabbedBrowser(Profile* profile) { |
Browser* browser = FindTabbedBrowser(profile, false); |
if (!browser) |
- browser = new Browser(Browser::CreateParams(profile)); |
+ browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, profile)); |
robertshield
2012/08/16 21:05:16
why do we add TYPE_TABBED here?
MAD
2012/08/17 12:45:51
Because I wanted to be more explicit that it's the
|
+ return browser; |
+} |
+ |
+Browser* FindOrCreateDesktopTabbedBrowser( |
+ Profile* profile, chrome::HostDesktopType desktop_type) { |
+ Browser* browser = FindDesktopTabbedBrowser(profile, desktop_type, false); |
+ if (!browser) |
+ browser = new Browser(Browser::CreateParams(Browser::TYPE_TABBED, |
+ profile, |
+ desktop_type)); |
return browser; |
} |
Browser* FindAnyBrowser(Profile* profile, bool match_original_profiles) { |
return FindBrowserWithTabbedOrAnyType(profile, |
+ kDefaultHostDesktopType, |
+ false, |
+ match_original_profiles); |
+} |
+ |
+Browser* FindDesktopBrowser(Profile* profile, |
+ chrome::HostDesktopType desktop_type, |
+ bool match_original_profiles) { |
+ return FindBrowserWithTabbedOrAnyType(profile, |
+ desktop_type, |
false, |
match_original_profiles); |
} |
@@ -126,6 +179,11 @@ Browser* FindBrowserWithProfile(Profile* profile) { |
return FindAnyBrowser(profile, false); |
} |
+Browser* FindDesktopBrowserWithProfile(Profile* profile, |
+ chrome::HostDesktopType desktop_type) { |
+ return FindDesktopBrowser(profile, desktop_type, false); |
+} |
+ |
Browser* FindBrowserWithID(SessionID::id_type desired_id) { |
for (BrowserList::const_iterator i = BrowserList::begin(); |
i != BrowserList::end(); ++i) { |
@@ -162,20 +220,21 @@ Browser* FindLastActiveWithProfile(Profile* profile) { |
Browser::FEATURE_NONE, kMatchAny); |
} |
-Browser* FindLastActiveWithHostDesktopType(chrome::HostDesktopType type) { |
+Browser* FindLastActiveWithHostDesktopType( |
+ chrome::HostDesktopType desktop_type) { |
chrome::BrowserListImpl* browser_list_impl = |
- chrome::BrowserListImpl::GetInstance(type); |
+ chrome::BrowserListImpl::GetInstance(desktop_type); |
if (browser_list_impl) |
return browser_list_impl->GetLastActive(); |
return NULL; |
} |
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 |