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 "chrome/browser/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
9 #include "chrome/browser/ui/browser_list_impl.h" | 9 #include "chrome/browser/ui/browser_list_impl.h" |
10 #include "chrome/browser/ui/browser_window.h" | 10 #include "chrome/browser/ui/browser_window.h" |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 Browser* FindBrowserWithWindow(gfx::NativeWindow window) { | 178 Browser* FindBrowserWithWindow(gfx::NativeWindow window) { |
179 for (BrowserList::const_iterator it = BrowserList::begin(); | 179 for (BrowserList::const_iterator it = BrowserList::begin(); |
180 it != BrowserList::end(); ++it) { | 180 it != BrowserList::end(); ++it) { |
181 Browser* browser = *it; | 181 Browser* browser = *it; |
182 if (browser->window() && browser->window()->GetNativeWindow() == window) | 182 if (browser->window() && browser->window()->GetNativeWindow() == window) |
183 return browser; | 183 return browser; |
184 } | 184 } |
185 return NULL; | 185 return NULL; |
186 } | 186 } |
187 | 187 |
| 188 } // namespace browser |
| 189 |
| 190 namespace chrome { |
| 191 |
188 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { | 192 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { |
189 DCHECK(web_contents); | 193 DCHECK(web_contents); |
190 for (TabContentsIterator it; !it.done(); ++it) { | 194 for (TabContentsIterator it; !it.done(); ++it) { |
191 if (it->web_contents() == web_contents) | 195 if (it->web_contents() == web_contents) |
192 return it.browser(); | 196 return it.browser(); |
193 } | 197 } |
194 return NULL; | 198 return NULL; |
195 } | 199 } |
196 | 200 |
197 } // namespace browser | |
198 | |
199 namespace chrome { | |
200 | |
201 Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { | 201 Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { |
202 BrowserListImpl* list = BrowserListImpl::GetInstance(type); | 202 BrowserListImpl* list = BrowserListImpl::GetInstance(type); |
203 // We are only interested in last active browsers, so we don't fall back to | 203 // We are only interested in last active browsers, so we don't fall back to |
204 // all browsers like FindBrowserWith* do. | 204 // all browsers like FindBrowserWith* do. |
205 return FindBrowserMatching(list->begin_last_active(), list->end_last_active(), | 205 return FindBrowserMatching(list->begin_last_active(), list->end_last_active(), |
206 profile, Browser::FEATURE_NONE, kMatchAny); | 206 profile, Browser::FEATURE_NONE, kMatchAny); |
207 } | 207 } |
208 | 208 |
209 Browser* FindLastActiveWithHostDesktopType(HostDesktopType type) { | 209 Browser* FindLastActiveWithHostDesktopType(HostDesktopType type) { |
210 BrowserListImpl* browser_list_impl = BrowserListImpl::GetInstance(type); | 210 BrowserListImpl* browser_list_impl = BrowserListImpl::GetInstance(type); |
211 if (browser_list_impl) | 211 if (browser_list_impl) |
212 return browser_list_impl->GetLastActive(); | 212 return browser_list_impl->GetLastActive(); |
213 return NULL; | 213 return NULL; |
214 } | 214 } |
215 | 215 |
216 size_t GetBrowserCount(Profile* profile) { | 216 size_t GetBrowserCount(Profile* profile) { |
217 return GetBrowserCountImpl(profile, kDefaultHostDesktopType, kMatchAny); | 217 return GetBrowserCountImpl(profile, kDefaultHostDesktopType, kMatchAny); |
218 } | 218 } |
219 | 219 |
220 size_t GetTabbedBrowserCount(Profile* profile) { | 220 size_t GetTabbedBrowserCount(Profile* profile) { |
221 return GetBrowserCountImpl(profile, kDefaultHostDesktopType, kMatchTabbed); | 221 return GetBrowserCountImpl(profile, kDefaultHostDesktopType, kMatchTabbed); |
222 } | 222 } |
223 | 223 |
224 } // namespace chrome | 224 } // namespace chrome |
OLD | NEW |