| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_list.h" | 7 #include "chrome/browser/browser_list.h" |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 | 187 |
| 188 // static | 188 // static |
| 189 Browser* BrowserList::GetLastActive() { | 189 Browser* BrowserList::GetLastActive() { |
| 190 if (!last_active_browsers_.empty()) | 190 if (!last_active_browsers_.empty()) |
| 191 return *(last_active_browsers_.rbegin()); | 191 return *(last_active_browsers_.rbegin()); |
| 192 | 192 |
| 193 return NULL; | 193 return NULL; |
| 194 } | 194 } |
| 195 | 195 |
| 196 // static | 196 // static |
| 197 Browser* BrowserList::GetLastActiveWithProfile(Profile* p) { |
| 198 list_type::reverse_iterator browser = last_active_browsers_.rbegin(); |
| 199 for (; browser != last_active_browsers_.rend(); ++browser) { |
| 200 if ((*browser)->profile() == p) { |
| 201 return *browser; |
| 202 } |
| 203 } |
| 204 |
| 205 return NULL; |
| 206 } |
| 207 |
| 208 // static |
| 197 Browser* BrowserList::FindBrowserWithType(Profile* p, Browser::Type t) { | 209 Browser* BrowserList::FindBrowserWithType(Profile* p, Browser::Type t) { |
| 198 Browser* last_active = GetLastActive(); | 210 Browser* last_active = GetLastActive(); |
| 199 if (last_active && last_active->profile() == p && last_active->type() == t) | 211 if (last_active && last_active->profile() == p && last_active->type() == t) |
| 200 return last_active; | 212 return last_active; |
| 201 | 213 |
| 202 BrowserList::const_iterator i; | 214 BrowserList::const_iterator i; |
| 203 for (i = BrowserList::begin(); i != BrowserList::end(); ++i) { | 215 for (i = BrowserList::begin(); i != BrowserList::end(); ++i) { |
| 204 if (*i == last_active) | 216 if (*i == last_active) |
| 205 continue; | 217 continue; |
| 206 | 218 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 } | 300 } |
| 289 | 301 |
| 290 WebContents* next_tab = | 302 WebContents* next_tab = |
| 291 (*browser_iterator_)->GetTabContentsAt(web_view_index_)->AsWebContents(); | 303 (*browser_iterator_)->GetTabContentsAt(web_view_index_)->AsWebContents(); |
| 292 if (next_tab) { | 304 if (next_tab) { |
| 293 cur_ = next_tab; | 305 cur_ = next_tab; |
| 294 return; | 306 return; |
| 295 } | 307 } |
| 296 } | 308 } |
| 297 } | 309 } |
| OLD | NEW |