OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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 #include "chrome/browser/custom_home_pages_table_model.h" | 5 #include "chrome/browser/custom_home_pages_table_model.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/i18n/rtl.h" | 9 #include "base/i18n/rtl.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/browser_tabstrip.h" |
15 #include "chrome/common/pref_names.h" | 16 #include "chrome/common/pref_names.h" |
16 #include "chrome/common/url_constants.h" | 17 #include "chrome/common/url_constants.h" |
17 #include "content/public/browser/web_contents.h" | 18 #include "content/public/browser/web_contents.h" |
18 #include "googleurl/src/gurl.h" | 19 #include "googleurl/src/gurl.h" |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "grit/ui_resources.h" | 21 #include "grit/ui_resources.h" |
21 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
22 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
23 #include "ui/base/models/table_model_observer.h" | 24 #include "ui/base/models/table_model_observer.h" |
24 #include "ui/gfx/codec/png_codec.h" | 25 #include "ui/gfx/codec/png_codec.h" |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 | 175 |
175 // And add all tabs for all open browsers with our profile. | 176 // And add all tabs for all open browsers with our profile. |
176 int add_index = 0; | 177 int add_index = 0; |
177 for (BrowserList::const_iterator browser_i = BrowserList::begin(); | 178 for (BrowserList::const_iterator browser_i = BrowserList::begin(); |
178 browser_i != BrowserList::end(); ++browser_i) { | 179 browser_i != BrowserList::end(); ++browser_i) { |
179 Browser* browser = *browser_i; | 180 Browser* browser = *browser_i; |
180 if (browser->profile() != profile_) | 181 if (browser->profile() != profile_) |
181 continue; // Skip incognito browsers. | 182 continue; // Skip incognito browsers. |
182 | 183 |
183 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { | 184 for (int tab_index = 0; tab_index < browser->tab_count(); ++tab_index) { |
184 const GURL url = browser->GetWebContentsAt(tab_index)->GetURL(); | 185 const GURL url = chrome::GetWebContentsAt(browser, tab_index)->GetURL(); |
185 if (ShouldAddPage(url)) | 186 if (ShouldAddPage(url)) |
186 Add(add_index++, url); | 187 Add(add_index++, url); |
187 } | 188 } |
188 } | 189 } |
189 } | 190 } |
190 | 191 |
191 std::vector<GURL> CustomHomePagesTableModel::GetURLs() { | 192 std::vector<GURL> CustomHomePagesTableModel::GetURLs() { |
192 std::vector<GURL> urls(entries_.size()); | 193 std::vector<GURL> urls(entries_.size()); |
193 for (size_t i = 0; i < entries_.size(); ++i) | 194 for (size_t i = 0; i < entries_.size(); ++i) |
194 urls[i] = entries_[i].url; | 195 urls[i] = entries_[i].url; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 return NULL; | 260 return NULL; |
260 } | 261 } |
261 | 262 |
262 string16 CustomHomePagesTableModel::FormattedURL(int row) const { | 263 string16 CustomHomePagesTableModel::FormattedURL(int row) const { |
263 std::string languages = | 264 std::string languages = |
264 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); | 265 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
265 string16 url = net::FormatUrl(entries_[row].url, languages); | 266 string16 url = net::FormatUrl(entries_[row].url, languages); |
266 url = base::i18n::GetDisplayStringInLTRDirectionality(url); | 267 url = base::i18n::GetDisplayStringInLTRDirectionality(url); |
267 return url; | 268 return url; |
268 } | 269 } |
OLD | NEW |