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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 54 |
55 } // namespace | 55 } // namespace |
56 | 56 |
57 struct CustomHomePagesTableModel::Entry { | 57 struct CustomHomePagesTableModel::Entry { |
58 Entry() : title_handle(0) {} | 58 Entry() : title_handle(0) {} |
59 | 59 |
60 // URL of the page. | 60 // URL of the page. |
61 GURL url; | 61 GURL url; |
62 | 62 |
63 // Page title. If this is empty, we'll display the URL as the entry. | 63 // Page title. If this is empty, we'll display the URL as the entry. |
64 string16 title; | 64 base::string16 title; |
65 | 65 |
66 // If non-zero, indicates we're loading the title for the page. | 66 // If non-zero, indicates we're loading the title for the page. |
67 HistoryService::Handle title_handle; | 67 HistoryService::Handle title_handle; |
68 }; | 68 }; |
69 | 69 |
70 CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile) | 70 CustomHomePagesTableModel::CustomHomePagesTableModel(Profile* profile) |
71 : profile_(profile), | 71 : profile_(profile), |
72 observer_(NULL) { | 72 observer_(NULL) { |
73 } | 73 } |
74 | 74 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
204 return static_cast<int>(entries_.size()); | 204 return static_cast<int>(entries_.size()); |
205 } | 205 } |
206 | 206 |
207 string16 CustomHomePagesTableModel::GetText(int row, int column_id) { | 207 string16 CustomHomePagesTableModel::GetText(int row, int column_id) { |
208 DCHECK(column_id == 0); | 208 DCHECK(column_id == 0); |
209 DCHECK(row >= 0 && row < RowCount()); | 209 DCHECK(row >= 0 && row < RowCount()); |
210 return entries_[row].title.empty() ? FormattedURL(row) : entries_[row].title; | 210 return entries_[row].title.empty() ? FormattedURL(row) : entries_[row].title; |
211 } | 211 } |
212 | 212 |
213 string16 CustomHomePagesTableModel::GetTooltip(int row) { | 213 string16 CustomHomePagesTableModel::GetTooltip(int row) { |
214 return entries_[row].title.empty() ? string16() : | 214 return entries_[row].title.empty() ? base::string16() : |
215 l10n_util::GetStringFUTF16(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP, | 215 l10n_util::GetStringFUTF16(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP, |
216 entries_[row].title, FormattedURL(row)); | 216 entries_[row].title, FormattedURL(row)); |
217 } | 217 } |
218 | 218 |
219 void CustomHomePagesTableModel::SetObserver(ui::TableModelObserver* observer) { | 219 void CustomHomePagesTableModel::SetObserver(ui::TableModelObserver* observer) { |
220 observer_ = observer; | 220 observer_ = observer; |
221 } | 221 } |
222 | 222 |
223 void CustomHomePagesTableModel::LoadTitle(Entry* entry) { | 223 void CustomHomePagesTableModel::LoadTitle(Entry* entry) { |
224 HistoryService* history_service = HistoryServiceFactory::GetForProfile( | 224 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 *index = static_cast<int>(i); | 260 *index = static_cast<int>(i); |
261 return &entries_[i]; | 261 return &entries_[i]; |
262 } | 262 } |
263 } | 263 } |
264 return NULL; | 264 return NULL; |
265 } | 265 } |
266 | 266 |
267 string16 CustomHomePagesTableModel::FormattedURL(int row) const { | 267 string16 CustomHomePagesTableModel::FormattedURL(int row) const { |
268 std::string languages = | 268 std::string languages = |
269 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); | 269 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
270 string16 url = net::FormatUrl(entries_[row].url, languages); | 270 base::string16 url = net::FormatUrl(entries_[row].url, languages); |
271 url = base::i18n::GetDisplayStringInLTRDirectionality(url); | 271 url = base::i18n::GetDisplayStringInLTRDirectionality(url); |
272 return url; | 272 return url; |
273 } | 273 } |
OLD | NEW |