| 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" |
| 11 #include "chrome/browser/ui/browser_iterator.h" | |
| 12 #include "chrome/browser/ui/browser_list.h" | 11 #include "chrome/browser/ui/browser_list.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 12 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 13 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
| 17 | 16 |
| 18 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
| 19 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" | 18 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" |
| 20 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" | 19 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" |
| 21 #include "components/signin/core/account_id/account_id.h" | 20 #include "components/signin/core/account_id/account_id.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 false, | 168 false, |
| 170 match_original_profiles); | 169 match_original_profiles); |
| 171 } | 170 } |
| 172 | 171 |
| 173 Browser* FindBrowserWithProfile(Profile* profile, | 172 Browser* FindBrowserWithProfile(Profile* profile, |
| 174 HostDesktopType desktop_type) { | 173 HostDesktopType desktop_type) { |
| 175 return FindBrowserWithTabbedOrAnyType(profile, desktop_type, false, false); | 174 return FindBrowserWithTabbedOrAnyType(profile, desktop_type, false, false); |
| 176 } | 175 } |
| 177 | 176 |
| 178 Browser* FindBrowserWithID(SessionID::id_type desired_id) { | 177 Browser* FindBrowserWithID(SessionID::id_type desired_id) { |
| 179 for (BrowserIterator it; !it.done(); it.Next()) { | 178 for (auto& browser : *BrowserList::GetInstance()) { |
| 180 if (it->session_id().id() == desired_id) | 179 if (browser->session_id().id() == desired_id) |
| 181 return *it; | 180 return browser; |
| 182 } | 181 } |
| 183 return NULL; | 182 return NULL; |
| 184 } | 183 } |
| 185 | 184 |
| 186 Browser* FindBrowserWithWindow(gfx::NativeWindow window) { | 185 Browser* FindBrowserWithWindow(gfx::NativeWindow window) { |
| 187 if (!window) | 186 if (!window) |
| 188 return NULL; | 187 return NULL; |
| 189 for (BrowserIterator it; !it.done(); it.Next()) { | 188 for (auto& browser : *BrowserList::GetInstance()) { |
| 190 Browser* browser = *it; | |
| 191 if (browser->window() && browser->window()->GetNativeWindow() == window) | 189 if (browser->window() && browser->window()->GetNativeWindow() == window) |
| 192 return browser; | 190 return browser; |
| 193 } | 191 } |
| 194 return NULL; | 192 return NULL; |
| 195 } | 193 } |
| 196 | 194 |
| 197 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { | 195 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { |
| 198 DCHECK(web_contents); | 196 DCHECK(web_contents); |
| 199 for (TabContentsIterator it; !it.done(); it.Next()) { | 197 for (TabContentsIterator it; !it.done(); it.Next()) { |
| 200 if (*it == web_contents) | 198 if (*it == web_contents) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 231 |
| 234 size_t GetBrowserCount(Profile* profile, HostDesktopType type) { | 232 size_t GetBrowserCount(Profile* profile, HostDesktopType type) { |
| 235 return GetBrowserCountImpl(profile, type, kMatchAny); | 233 return GetBrowserCountImpl(profile, type, kMatchAny); |
| 236 } | 234 } |
| 237 | 235 |
| 238 size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type) { | 236 size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type) { |
| 239 return GetBrowserCountImpl(profile, type, kMatchTabbed); | 237 return GetBrowserCountImpl(profile, type, kMatchTabbed); |
| 240 } | 238 } |
| 241 | 239 |
| 242 } // namespace chrome | 240 } // namespace chrome |
| OLD | NEW |