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

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

Issue 10782004: Removing usage of profile_->GetHistory() from the codebase in order to remove that function. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/browsing_data_remover_unittest.cc ('k') | chrome/browser/memory_purger.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"
11 #include "chrome/browser/history/history_service_factory.h"
11 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
12 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
14 #include "chrome/browser/ui/browser_list.h" 15 #include "chrome/browser/ui/browser_list.h"
15 #include "chrome/browser/ui/browser_tabstrip.h" 16 #include "chrome/browser/ui/browser_tabstrip.h"
16 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
17 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
18 #include "content/public/browser/web_contents.h" 19 #include "content/public/browser/web_contents.h"
19 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (observer_) 152 if (observer_)
152 observer_->OnItemsAdded(index, 1); 153 observer_->OnItemsAdded(index, 1);
153 } 154 }
154 155
155 void CustomHomePagesTableModel::Remove(int index) { 156 void CustomHomePagesTableModel::Remove(int index) {
156 DCHECK(index >= 0 && index < RowCount()); 157 DCHECK(index >= 0 && index < RowCount());
157 Entry* entry = &(entries_[index]); 158 Entry* entry = &(entries_[index]);
158 // Cancel any pending load requests now so we don't deref a bogus pointer when 159 // Cancel any pending load requests now so we don't deref a bogus pointer when
159 // we get the loaded notification. 160 // we get the loaded notification.
160 if (entry->title_handle) { 161 if (entry->title_handle) {
161 HistoryService* history_service = 162 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
162 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 163 profile_, Profile::EXPLICIT_ACCESS);
163 if (history_service) 164 if (history_service)
164 history_service->CancelRequest(entry->title_handle); 165 history_service->CancelRequest(entry->title_handle);
165 } 166 }
166 entries_.erase(entries_.begin() + static_cast<size_t>(index)); 167 entries_.erase(entries_.begin() + static_cast<size_t>(index));
167 if (observer_) 168 if (observer_)
168 observer_->OnItemsRemoved(index, 1); 169 observer_->OnItemsRemoved(index, 1);
169 } 170 }
170 171
171 void CustomHomePagesTableModel::SetToCurrentlyOpenPages() { 172 void CustomHomePagesTableModel::SetToCurrentlyOpenPages() {
172 // Remove the current entries. 173 // Remove the current entries.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 return entries_[row].title.empty() ? string16() : 211 return entries_[row].title.empty() ? string16() :
211 l10n_util::GetStringFUTF16(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP, 212 l10n_util::GetStringFUTF16(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP,
212 entries_[row].title, FormattedURL(row)); 213 entries_[row].title, FormattedURL(row));
213 } 214 }
214 215
215 void CustomHomePagesTableModel::SetObserver(ui::TableModelObserver* observer) { 216 void CustomHomePagesTableModel::SetObserver(ui::TableModelObserver* observer) {
216 observer_ = observer; 217 observer_ = observer;
217 } 218 }
218 219
219 void CustomHomePagesTableModel::LoadTitle(Entry* entry) { 220 void CustomHomePagesTableModel::LoadTitle(Entry* entry) {
220 HistoryService* history_service = 221 HistoryService* history_service = HistoryServiceFactory::GetForProfile(
221 profile_->GetHistoryService(Profile::EXPLICIT_ACCESS); 222 profile_, Profile::EXPLICIT_ACCESS);
222 if (history_service) { 223 if (history_service) {
223 entry->title_handle = history_service->QueryURL(entry->url, false, 224 entry->title_handle = history_service->QueryURL(entry->url, false,
224 &history_query_consumer_, 225 &history_query_consumer_,
225 base::Bind(&CustomHomePagesTableModel::OnGotTitle, 226 base::Bind(&CustomHomePagesTableModel::OnGotTitle,
226 base::Unretained(this))); 227 base::Unretained(this)));
227 } 228 }
228 } 229 }
229 230
230 void CustomHomePagesTableModel::OnGotTitle(HistoryService::Handle handle, 231 void CustomHomePagesTableModel::OnGotTitle(HistoryService::Handle handle,
231 bool found_url, 232 bool found_url,
(...skipping 28 matching lines...) Expand all
260 return NULL; 261 return NULL;
261 } 262 }
262 263
263 string16 CustomHomePagesTableModel::FormattedURL(int row) const { 264 string16 CustomHomePagesTableModel::FormattedURL(int row) const {
264 std::string languages = 265 std::string languages =
265 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); 266 profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
266 string16 url = net::FormatUrl(entries_[row].url, languages); 267 string16 url = net::FormatUrl(entries_[row].url, languages);
267 url = base::i18n::GetDisplayStringInLTRDirectionality(url); 268 url = base::i18n::GetDisplayStringInLTRDirectionality(url);
268 return url; 269 return url;
269 } 270 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data_remover_unittest.cc ('k') | chrome/browser/memory_purger.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698