| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_ITERATOR_H_ | 5 #ifndef CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ |
| 6 #define CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ | 6 #define CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ |
| 7 | 7 |
| 8 #include "chrome/browser/ui/browser_list.h" | 8 #include "chrome/browser/ui/browser_list.h" |
| 9 #include "chrome/browser/ui/host_desktop.h" | 9 #include "chrome/browser/ui/host_desktop.h" |
| 10 | 10 |
| 11 class Browser; | 11 class Browser; |
| 12 | 12 |
| 13 namespace chrome { | 13 namespace chrome { |
| 14 | 14 |
| 15 // Iterates over all existing browsers (potentially across multiple desktops). | 15 // Iterates over all existing browsers (potentially across multiple desktops). |
| 16 // Note: to iterate only over the browsers of a specific desktop, use the | 16 // Note: to iterate only over the browsers of a specific desktop, use the |
| 17 // const_iterator of a given BrowserList instead. | 17 // const_iterator of a given BrowserList instead. |
| 18 // | 18 // |
| 19 // Example: | 19 // Example: |
| 20 // for (BrowserIterator iterator; !iterator.done(); iterator.Next()) { | 20 // for (BrowserIterator iterator; !iterator.done(); iterator.Next()) { |
| 21 // Browser* cur = *iterator; | 21 // Browser* cur = *iterator; |
| 22 // -or- | 22 // -or- |
| 23 // iterator->OperationOnBrowser(); | 23 // iterator->OperationOnBrowser(); |
| 24 // ... | 24 // ... |
| 25 // } | 25 // } |
| 26 class BrowserIterator { | 26 class BrowserIterator { |
| 27 public: | 27 public: |
| 28 BrowserIterator(); | 28 BrowserIterator(); |
| 29 ~BrowserIterator(); |
| 29 | 30 |
| 30 // Returns true if this iterator is past the last Browser. | 31 // Returns true if this iterator is past the last Browser. |
| 31 bool done() const { | 32 bool done() const { |
| 32 // |current_iterator_| is never at the end of a list unless it is done (it | 33 // |current_iterator_| is never at the end of a list unless it is done (it |
| 33 // immediately moves to the next browser list upon hitting the end of the | 34 // immediately moves to the next browser list upon hitting the end of the |
| 34 // current list unless there are no remaining empty browser lists). | 35 // current list unless there are no remaining empty browser lists). |
| 35 return current_iterator_ == current_browser_list_->end(); | 36 return current_iterator_ == current_browser_list_->end(); |
| 36 } | 37 } |
| 37 | 38 |
| 38 // Returns the current Browser, valid as long as !done(). | 39 // Returns the current Browser, valid as long as !done(). |
| (...skipping 23 matching lines...) Expand all Loading... |
| 62 // The next HostDesktopType to iterate over when |current_iterator_| reaches | 63 // The next HostDesktopType to iterate over when |current_iterator_| reaches |
| 63 // |current_browser_list_->end()|. | 64 // |current_browser_list_->end()|. |
| 64 HostDesktopType next_desktop_type_; | 65 HostDesktopType next_desktop_type_; |
| 65 | 66 |
| 66 DISALLOW_COPY_AND_ASSIGN(BrowserIterator); | 67 DISALLOW_COPY_AND_ASSIGN(BrowserIterator); |
| 67 }; | 68 }; |
| 68 | 69 |
| 69 } // namespace chrome | 70 } // namespace chrome |
| 70 | 71 |
| 71 #endif // CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ | 72 #endif // CHROME_BROWSER_UI_BROWSER_ITERATOR_H_ |
| OLD | NEW |