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_window.h" | 9 #include "chrome/browser/ui/browser_window.h" |
10 #include "chrome/browser/ui/tab_contents/tab_contents.h" | 10 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { | 147 Browser* FindBrowserWithWebContents(const WebContents* web_contents) { |
148 DCHECK(web_contents); | 148 DCHECK(web_contents); |
149 for (TabContentsIterator it; !it.done(); ++it) { | 149 for (TabContentsIterator it; !it.done(); ++it) { |
150 if (it->web_contents() == web_contents) | 150 if (it->web_contents() == web_contents) |
151 return it.browser(); | 151 return it.browser(); |
152 } | 152 } |
153 return NULL; | 153 return NULL; |
154 } | 154 } |
155 | 155 |
| 156 Browser* FindBrowserForController( |
| 157 const content::NavigationController* controller, |
| 158 int* index_result) { |
| 159 for (BrowserList::const_iterator it = BrowserList::begin(); |
| 160 it != BrowserList::end(); ++it) { |
| 161 int index = (*it)->tab_strip_model()->GetIndexOfWebContents( |
| 162 controller->GetWebContents()); |
| 163 if (index != TabStripModel::kNoTab) { |
| 164 if (index_result) |
| 165 *index_result = index; |
| 166 return *it; |
| 167 } |
| 168 } |
| 169 return NULL; |
| 170 } |
| 171 |
| 172 |
156 Browser* FindLastActiveWithProfile(Profile* profile) { | 173 Browser* FindLastActiveWithProfile(Profile* profile) { |
157 // We are only interested in last active browsers, so we don't fall back to | 174 // We are only interested in last active browsers, so we don't fall back to |
158 // all browsers like FindBrowserWith* do. | 175 // all browsers like FindBrowserWith* do. |
159 return FindBrowserMatching( | 176 return FindBrowserMatching( |
160 BrowserList::begin_last_active(), BrowserList::end_last_active(), profile, | 177 BrowserList::begin_last_active(), BrowserList::end_last_active(), profile, |
161 Browser::FEATURE_NONE, kMatchAny); | 178 Browser::FEATURE_NONE, kMatchAny); |
162 } | 179 } |
163 | 180 |
164 size_t GetBrowserCount(Profile* profile) { | 181 size_t GetBrowserCount(Profile* profile) { |
165 return GetBrowserCountImpl(profile, kMatchAny); | 182 return GetBrowserCountImpl(profile, kMatchAny); |
166 } | 183 } |
167 | 184 |
168 size_t GetTabbedBrowserCount(Profile* profile) { | 185 size_t GetTabbedBrowserCount(Profile* profile) { |
169 return GetBrowserCountImpl(profile, kMatchTabbed); | 186 return GetBrowserCountImpl(profile, kMatchTabbed); |
170 } | 187 } |
171 | 188 |
172 } // namespace browser | 189 } // namespace browser |
OLD | NEW |