Chromium Code Reviews| 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/devtools/devtools_window.h" | |
| 7 #include "chrome/browser/profiles/profile.h" | 8 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser_iterator.h" | 9 #include "chrome/browser/ui/browser_iterator.h" |
| 9 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| 10 #include "chrome/browser/ui/browser_window.h" | 11 #include "chrome/browser/ui/browser_window.h" |
| 11 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" | 12 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "content/public/browser/navigation_controller.h" | 14 #include "content/public/browser/navigation_controller.h" |
| 14 | 15 |
| 15 using content::WebContents; | 16 using content::WebContents; |
| 16 | 17 |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 if (!window) | 159 if (!window) |
| 159 return NULL; | 160 return NULL; |
| 160 for (BrowserIterator it; !it.done(); it.Next()) { | 161 for (BrowserIterator it; !it.done(); it.Next()) { |
| 161 Browser* browser = *it; | 162 Browser* browser = *it; |
| 162 if (browser->window() && browser->window()->GetNativeWindow() == window) | 163 if (browser->window() && browser->window()->GetNativeWindow() == window) |
| 163 return browser; | 164 return browser; |
| 164 } | 165 } |
| 165 return NULL; | 166 return NULL; |
| 166 } | 167 } |
| 167 | 168 |
| 168 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { | 169 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { |
|
pfeldman
2013/08/29 11:57:36
This method is used in many places that do various
vabr (Chromium)
2013/08/29 12:51:09
That's a good point, I was also a bit scared, alth
| |
| 169 DCHECK(web_contents); | 170 DCHECK(web_contents); |
| 170 for (TabContentsIterator it; !it.done(); it.Next()) { | 171 for (TabContentsIterator it; !it.done(); it.Next()) { |
| 171 if (*it == web_contents) | 172 if (*it == web_contents) |
| 172 return it.browser(); | 173 return it.browser(); |
| 174 DevToolsWindow* dev_tools_window = | |
| 175 DevToolsWindow::GetDockedInstanceForInspectedTab(*it); | |
| 176 if (dev_tools_window && (dev_tools_window->web_contents() == web_contents)) | |
| 177 return it.browser(); | |
| 173 } | 178 } |
| 174 return NULL; | 179 return NULL; |
| 175 } | 180 } |
| 176 | 181 |
| 177 Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { | 182 Browser* FindLastActiveWithProfile(Profile* profile, HostDesktopType type) { |
| 178 BrowserList* list = BrowserList::GetInstance(type); | 183 BrowserList* list = BrowserList::GetInstance(type); |
| 179 // We are only interested in last active browsers, so we don't fall back to | 184 // We are only interested in last active browsers, so we don't fall back to |
| 180 // all browsers like FindBrowserWith* do. | 185 // all browsers like FindBrowserWith* do. |
| 181 return FindBrowserMatching(list->begin_last_active(), list->end_last_active(), | 186 return FindBrowserMatching(list->begin_last_active(), list->end_last_active(), |
| 182 profile, Browser::FEATURE_NONE, kMatchAny); | 187 profile, Browser::FEATURE_NONE, kMatchAny); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 209 | 214 |
| 210 size_t GetBrowserCount(Profile* profile, HostDesktopType type) { | 215 size_t GetBrowserCount(Profile* profile, HostDesktopType type) { |
| 211 return GetBrowserCountImpl(profile, type, kMatchAny); | 216 return GetBrowserCountImpl(profile, type, kMatchAny); |
| 212 } | 217 } |
| 213 | 218 |
| 214 size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type) { | 219 size_t GetTabbedBrowserCount(Profile* profile, HostDesktopType type) { |
| 215 return GetBrowserCountImpl(profile, type, kMatchTabbed); | 220 return GetBrowserCountImpl(profile, type, kMatchTabbed); |
| 216 } | 221 } |
| 217 | 222 |
| 218 } // namespace chrome | 223 } // namespace chrome |
| OLD | NEW |