OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/browser_finder.h" | 5 #include "chrome/browser/ui/browser_finder.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 194 |
195 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { | 195 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { |
196 DCHECK(web_contents); | 196 DCHECK(web_contents); |
197 for (TabContentsIterator it; !it.done(); it.Next()) { | 197 for (TabContentsIterator it; !it.done(); it.Next()) { |
198 if (*it == web_contents) | 198 if (*it == web_contents) |
199 return it.browser(); | 199 return it.browser(); |
200 } | 200 } |
201 return NULL; | 201 return NULL; |
202 } | 202 } |
203 | 203 |
204 Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { | 204 Browser* FindLastActiveWithProfile(Profile* profile) { |
205 BrowserList* list = BrowserList::GetInstance(); | 205 BrowserList* list = BrowserList::GetInstance(); |
206 // We are only interested in last active browsers, so we don't fall back to | 206 // We are only interested in last active browsers, so we don't fall back to |
207 // all browsers like FindBrowserWith* do. | 207 // all browsers like FindBrowserWith* do. |
208 return FindBrowserMatching(list->begin_last_active(), list->end_last_active(), | 208 return FindBrowserMatching(list->begin_last_active(), list->end_last_active(), |
209 profile, Browser::FEATURE_NONE, kMatchAny); | 209 profile, Browser::FEATURE_NONE, kMatchAny); |
210 } | 210 } |
211 | 211 |
212 Browser* FindLastActiveWithHostDesktopType(HostDesktopType type) { | 212 Browser* FindLastActive() { |
213 BrowserList* browser_list_impl = BrowserList::GetInstance(); | 213 BrowserList* browser_list_impl = BrowserList::GetInstance(); |
214 if (browser_list_impl) | 214 if (browser_list_impl) |
215 return browser_list_impl->GetLastActive(); | 215 return browser_list_impl->GetLastActive(); |
216 return NULL; | 216 return NULL; |
217 } | 217 } |
218 | 218 |
219 size_t GetTotalBrowserCount() { | 219 size_t GetTotalBrowserCount() { |
220 return BrowserList::GetInstance()->size(); | 220 return BrowserList::GetInstance()->size(); |
221 } | 221 } |
222 | 222 |
223 size_t GetTotalBrowserCountForProfile(Profile* profile) { | 223 size_t GetTotalBrowserCountForProfile(Profile* profile) { |
224 size_t count = 0; | 224 size_t count = 0; |
225 for (HostDesktopType t = HOST_DESKTOP_TYPE_FIRST; t < HOST_DESKTOP_TYPE_COUNT; | 225 for (HostDesktopType t = HOST_DESKTOP_TYPE_FIRST; t < HOST_DESKTOP_TYPE_COUNT; |
226 t = static_cast<HostDesktopType>(t + 1)) { | 226 t = static_cast<HostDesktopType>(t + 1)) { |
227 count += GetBrowserCount(profile, t); | 227 count += GetBrowserCount(profile, t); |
228 } | 228 } |
229 return count; | 229 return count; |
230 } | 230 } |
231 | 231 |
232 size_t GetBrowserCount(Profile* profile, HostDesktopType type) { | 232 size_t GetBrowserCount(Profile* profile, HostDesktopType type) { |
233 return GetBrowserCountImpl(profile, type, kMatchAny); | 233 return GetBrowserCountImpl(profile, type, kMatchAny); |
234 } | 234 } |
235 | 235 |
236 size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type) { | 236 size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type) { |
237 return GetBrowserCountImpl(profile, type, kMatchTabbed); | 237 return GetBrowserCountImpl(profile, type, kMatchTabbed); |
238 } | 238 } |
239 | 239 |
240 } // namespace chrome | 240 } // namespace chrome |
OLD | NEW |