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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h"
7 #include "base/logging.h"
8 #include "chrome/browser/browser_process.h"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 TabContentsIterator::TabContentsIterator()
13 : web_view_index_(-1),
15 // Load the first WebContents into |cur_|.
19 void TabContentsIterator::Next() {
20 // The current WebContents should be valid unless we are at the beginning.
21 DCHECK(cur_
|| web_view_index_
== -1) << "Trying to advance past the end";
23 // Update |cur_| to the next WebContents in the list.
24 while (!browser_iterator_
.done()) {
25 if (++web_view_index_
>= browser_iterator_
->tab_strip_model()->count()) {
26 // Advance to the next Browser in the list.
27 browser_iterator_
.Next();
32 content::WebContents
* next_tab
= browser_iterator_
->tab_strip_model()
33 ->GetWebContentsAt(web_view_index_
);