Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: chrome/browser/custom_home_pages_table_model.cc

Issue 11275088: Remove implicit scoped_refptr operator T* Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/cookies_tree_model.cc ('k') | chrome/browser/download/download_browsertest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 observer_->OnItemsAdded(index, 1); 156 observer_->OnItemsAdded(index, 1);
157 } 157 }
158 158
159 void CustomHomePagesTableModel::Remove(int index) { 159 void CustomHomePagesTableModel::Remove(int index) {
160 DCHECK(index >= 0 && index < RowCount()); 160 DCHECK(index >= 0 && index < RowCount());
161 Entry* entry = &(entries_[index]); 161 Entry* entry = &(entries_[index]);
162 // Cancel any pending load requests now so we don't deref a bogus pointer when 162 // Cancel any pending load requests now so we don't deref a bogus pointer when
163 // we get the loaded notification. 163 // we get the loaded notification.
164 if (entry->title_handle) { 164 if (entry->title_handle) {
165 HistoryService* history_service = HistoryServiceFactory::GetForProfile( 165 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
166 profile_, Profile::EXPLICIT_ACCESS); 166 profile_, Profile::EXPLICIT_ACCESS).get();
167 if (history_service) 167 if (history_service)
168 history_service->CancelRequest(entry->title_handle); 168 history_service->CancelRequest(entry->title_handle);
169 } 169 }
170 entries_.erase(entries_.begin() + static_cast<size_t>(index)); 170 entries_.erase(entries_.begin() + static_cast<size_t>(index));
171 if (observer_) 171 if (observer_)
172 observer_->OnItemsRemoved(index, 1); 172 observer_->OnItemsRemoved(index, 1);
173 } 173 }
174 174
175 void CustomHomePagesTableModel::SetToCurrentlyOpenPages() { 175 void CustomHomePagesTableModel::SetToCurrentlyOpenPages() {
176 // Remove the current entries. 176 // Remove the current entries.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(
225 profile_, Profile::EXPLICIT_ACCESS); 225 profile_, Profile::EXPLICIT_ACCESS).get();
226 if (history_service) { 226 if (history_service) {
227 entry->title_handle = history_service->QueryURL(entry->url, false, 227 entry->title_handle = history_service->QueryURL(entry->url, false,
228 &history_query_consumer_, 228 &history_query_consumer_,
229 base::Bind(&CustomHomePagesTableModel::OnGotTitle, 229 base::Bind(&CustomHomePagesTableModel::OnGotTitle,
230 base::Unretained(this))); 230 base::Unretained(this)));
231 } 231 }
232 } 232 }
233 233
234 void CustomHomePagesTableModel::OnGotTitle(HistoryService::Handle handle, 234 void CustomHomePagesTableModel::OnGotTitle(HistoryService::Handle handle,
235 bool found_url, 235 bool found_url,
(...skipping 28 matching lines...) Expand all
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 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 }
OLDNEW
« no previous file with comments | « chrome/browser/cookies_tree_model.cc ('k') | chrome/browser/download/download_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698