summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/tabs/tab_strip_model_utils.cc
blob: ed09b85658dde0e6e330b97716d7913342d35246 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/tabs/tab_strip_model_utils.h"

#include "chrome/browser/history/top_sites.h"
#include "chrome/browser/ui/tabs/tab_strip_model.h"
#include "content/public/browser/web_contents.h"

namespace chrome {

int IndexOfFirstBlockedTab(const TabStripModel* model) {
  DCHECK(model);
  for (int i = 0; i < model->count(); ++i) {
    if (model->IsTabBlocked(i))
      return i;
  }
  // No blocked tabs.
  return model->count();
}

void GetOpenUrls(const TabStripModel& tabs,
                 const history::TopSites& top_sites,
                 std::set<std::string>* urls) {
  for (int i = 0; i < tabs.count(); ++i) {
    content::WebContents* web_contents = tabs.GetWebContentsAt(i);
    if (web_contents)
      urls->insert(top_sites.GetCanonicalURLString(web_contents->GetURL()));
  }
}

}  // namespace chrome