Infobar material design refresh: layout
[chromium-blink-merge.git] / chrome / browser / ui / tab_contents / tab_contents_iterator.cc
blobbc035776d812f79fa5ef230901461b18e831bc46
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),
14 cur_(NULL) {
15 // Load the first WebContents into |cur_|.
16 Next();
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();
28 web_view_index_ = -1;
29 continue;
32 content::WebContents* next_tab = browser_iterator_->tab_strip_model()
33 ->GetWebContentsAt(web_view_index_);
34 if (next_tab) {
35 cur_ = next_tab;
36 return;
39 // Reached the end.
40 cur_ = NULL;