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

Side by Side Diff: chrome/browser/ui/webui/ntp/suggestions_page_handler.cc

Issue 9583033: NTP: Fix a leak. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Simplify. Created 8 years, 9 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 | « no previous file | no next file » | 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/ui/webui/ntp/suggestions_page_handler.h" 5 #include "chrome/browser/ui/webui/ntp/suggestions_page_handler.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 // TODO(georgey) clear blacklist. 129 // TODO(georgey) clear blacklist.
130 } 130 }
131 131
132 void SuggestionsHandler::SetPagesValueFromTopSites( 132 void SuggestionsHandler::SetPagesValueFromTopSites(
133 const history::MostVisitedURLList& data) { 133 const history::MostVisitedURLList& data) {
134 // TODO(georgey) - change to our suggestions pages - right now as a test 134 // TODO(georgey) - change to our suggestions pages - right now as a test
135 // returns top 20 sites in reverse order. 135 // returns top 20 sites in reverse order.
136 pages_value_.reset(new ListValue()); 136 pages_value_.reset(new ListValue());
137 for (size_t i = 0; i < data.size(); i++) { 137 for (size_t i = 0; i < data.size(); i++) {
138 const history::MostVisitedURL& suggested_url = data[data.size() - i - 1]; 138 const history::MostVisitedURL& suggested_url = data[data.size() - i - 1];
139 if (suggested_url.url.is_empty())
140 continue;
141
139 DictionaryValue* page_value = new DictionaryValue(); 142 DictionaryValue* page_value = new DictionaryValue();
140 if (suggested_url.url.is_empty()) {
141 continue;
142 }
143
144 NewTabUI::SetURLTitleAndDirection(page_value, 143 NewTabUI::SetURLTitleAndDirection(page_value,
145 suggested_url.title, 144 suggested_url.title,
146 suggested_url.url); 145 suggested_url.url);
147 pages_value_->Append(page_value); 146 pages_value_->Append(page_value);
148 } 147 }
149 } 148 }
150 149
151 void SuggestionsHandler::OnSuggestionsURLsAvailable( 150 void SuggestionsHandler::OnSuggestionsURLsAvailable(
152 const history::MostVisitedURLList& data) { 151 const history::MostVisitedURLList& data) {
153 SetPagesValueFromTopSites(data); 152 SetPagesValueFromTopSites(data);
(...skipping 15 matching lines...) Expand all
169 } 168 }
170 169
171 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { 170 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) {
172 return base::MD5String(url); 171 return base::MD5String(url);
173 } 172 }
174 173
175 // static 174 // static
176 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) { 175 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) {
177 // TODO(georgey) add user preferences (such as own blacklist) as needed. 176 // TODO(georgey) add user preferences (such as own blacklist) as needed.
178 } 177 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698