| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_UI_BROWSER_LIST_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_LIST_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_LIST_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_LIST_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <set> |
| 9 #include <vector> | 10 #include <vector> |
| 10 | 11 |
| 11 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
| 12 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 13 | 14 |
| 14 // Stores a list of all Browser objects. | 15 // Stores a list of all Browser objects. |
| 15 class BrowserList { | 16 class BrowserList { |
| 16 public: | 17 public: |
| 17 typedef std::vector<Browser*> BrowserVector; | 18 typedef std::vector<Browser*> BrowserVector; |
| 18 typedef BrowserVector::iterator iterator; | 19 typedef BrowserVector::iterator iterator; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 TabContentsIterator(); | 212 TabContentsIterator(); |
| 212 | 213 |
| 213 // Returns true if we are past the last Browser. | 214 // Returns true if we are past the last Browser. |
| 214 bool done() const { | 215 bool done() const { |
| 215 return cur_ == NULL; | 216 return cur_ == NULL; |
| 216 } | 217 } |
| 217 | 218 |
| 218 // Returns the Browser instance associated with the current TabContents. | 219 // Returns the Browser instance associated with the current TabContents. |
| 219 // Valid as long as !Done() | 220 // Valid as long as !Done() |
| 220 Browser* browser() const { | 221 Browser* browser() const { |
| 221 return *browser_iterator_; | 222 if (browser_iterator_ != BrowserList::end()) |
| 223 return *browser_iterator_; |
| 224 return NULL; |
| 222 } | 225 } |
| 223 | 226 |
| 224 // Returns the current TabContents, valid as long as !Done() | 227 // Returns the current TabContents, valid as long as !Done() |
| 225 TabContentsWrapper* operator->() const { | 228 TabContentsWrapper* operator->() const { |
| 226 return cur_; | 229 return cur_; |
| 227 } | 230 } |
| 228 TabContentsWrapper* operator*() const { | 231 TabContentsWrapper* operator*() const { |
| 229 return cur_; | 232 return cur_; |
| 230 } | 233 } |
| 231 | 234 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 245 // call when browser_iterator_ points to the first browser and | 248 // call when browser_iterator_ points to the first browser and |
| 246 // web_view_index_ is -1, it will fill the first host. | 249 // web_view_index_ is -1, it will fill the first host. |
| 247 void Advance(); | 250 void Advance(); |
| 248 | 251 |
| 249 // iterator over all the Browser objects | 252 // iterator over all the Browser objects |
| 250 BrowserList::const_iterator browser_iterator_; | 253 BrowserList::const_iterator browser_iterator_; |
| 251 | 254 |
| 252 // tab index into the current Browser of the current web view | 255 // tab index into the current Browser of the current web view |
| 253 int web_view_index_; | 256 int web_view_index_; |
| 254 | 257 |
| 258 // iterator over the TabContentsWrappers doing background printing. |
| 259 std::set<TabContentsWrapper*>::const_iterator bg_printing_iterator_; |
| 260 |
| 255 // Current TabContents, or NULL if we're at the end of the list. This can | 261 // Current TabContents, or NULL if we're at the end of the list. This can |
| 256 // be extracted given the browser iterator and index, but it's nice to cache | 262 // be extracted given the browser iterator and index, but it's nice to cache |
| 257 // this since the caller may access the current host many times. | 263 // this since the caller may access the current host many times. |
| 258 TabContentsWrapper* cur_; | 264 TabContentsWrapper* cur_; |
| 259 }; | 265 }; |
| 260 | 266 |
| 261 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ | 267 #endif // CHROME_BROWSER_UI_BROWSER_LIST_H_ |
| OLD | NEW |