OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/l10n_util.h" | 7 #include "app/l10n_util.h" |
8 #include "app/resource_bundle.h" | 8 #include "app/resource_bundle.h" |
9 #include "app/table_model_observer.h" | 9 #include "app/table_model_observer.h" |
10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 } | 63 } |
64 // Complete change, so tell the view to just rebuild itself. | 64 // Complete change, so tell the view to just rebuild itself. |
65 if (observer_) | 65 if (observer_) |
66 observer_->OnModelChanged(); | 66 observer_->OnModelChanged(); |
67 } | 67 } |
68 | 68 |
69 void CustomHomePagesTableModel::Add(int index, const GURL& url) { | 69 void CustomHomePagesTableModel::Add(int index, const GURL& url) { |
70 DCHECK(index >= 0 && index <= RowCount()); | 70 DCHECK(index >= 0 && index <= RowCount()); |
71 entries_.insert(entries_.begin() + static_cast<size_t>(index), Entry()); | 71 entries_.insert(entries_.begin() + static_cast<size_t>(index), Entry()); |
72 entries_[index].url = url; | 72 entries_[index].url = url; |
| 73 LoadTitleAndFavIcon(&(entries_[index])); |
73 if (observer_) | 74 if (observer_) |
74 observer_->OnItemsAdded(index, 1); | 75 observer_->OnItemsAdded(index, 1); |
75 } | 76 } |
76 | 77 |
77 void CustomHomePagesTableModel::Remove(int index) { | 78 void CustomHomePagesTableModel::Remove(int index) { |
78 DCHECK(index >= 0 && index < RowCount()); | 79 DCHECK(index >= 0 && index < RowCount()); |
79 Entry* entry = &(entries_[index]); | 80 Entry* entry = &(entries_[index]); |
80 // Cancel any pending load requests now so we don't deref a bogus pointer when | 81 // Cancel any pending load requests now so we don't deref a bogus pointer when |
81 // we get the loaded notification. | 82 // we get the loaded notification. |
82 if (entry->title_handle) { | 83 if (entry->title_handle) { |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 return NULL; | 233 return NULL; |
233 } | 234 } |
234 | 235 |
235 string16 CustomHomePagesTableModel::FormattedURL(int row) const { | 236 string16 CustomHomePagesTableModel::FormattedURL(int row) const { |
236 std::string languages = | 237 std::string languages = |
237 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); | 238 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); |
238 string16 url = net::FormatUrl(entries_[row].url, languages); | 239 string16 url = net::FormatUrl(entries_[row].url, languages); |
239 url = base::i18n::GetDisplayStringInLTRDirectionality(url); | 240 url = base::i18n::GetDisplayStringInLTRDirectionality(url); |
240 return url; | 241 return url; |
241 } | 242 } |
OLD | NEW |