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

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

Issue 10115001: Added page score to the ntp suggestions tab. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Addressed comment Created 8 years, 8 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
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_page_handler.h ('k') | 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 suggestions_viewed_ = true; 175 suggestions_viewed_ = true;
176 user_action_logged_ = true; 176 user_action_logged_ = true;
177 } 177 }
178 178
179 void SuggestionsHandler::HandleSuggestedSitesSelected( 179 void SuggestionsHandler::HandleSuggestedSitesSelected(
180 const base::ListValue* args) { 180 const base::ListValue* args) {
181 suggestions_viewed_ = true; 181 suggestions_viewed_ = true;
182 } 182 }
183 183
184 void SuggestionsHandler::SetPagesValueFromTopSites( 184 void SuggestionsHandler::SetPagesValueFromTopSites(
185 const history::MostVisitedURLList& data) { 185 const history::FilteredURLList& data) {
186 pages_value_.reset(new ListValue()); 186 pages_value_.reset(new ListValue());
187 for (size_t i = 0; i < data.size(); i++) { 187 for (size_t i = 0; i < data.size(); i++) {
188 const history::MostVisitedURL& suggested_url = data[i]; 188 const history::FilteredURL& suggested_url = data[i];
189 if (suggested_url.url.is_empty()) 189 if (suggested_url.url.is_empty())
190 continue; 190 continue;
191 191
192 DictionaryValue* page_value = new DictionaryValue(); 192 DictionaryValue* page_value = new DictionaryValue();
193 NewTabUI::SetURLTitleAndDirection(page_value, 193 NewTabUI::SetURLTitleAndDirection(page_value,
194 suggested_url.title, 194 suggested_url.title,
195 suggested_url.url); 195 suggested_url.url);
196 page_value->SetDouble("score", suggested_url.score);
196 pages_value_->Append(page_value); 197 pages_value_->Append(page_value);
197 } 198 }
198 } 199 }
199 200
200 void SuggestionsHandler::OnSuggestionsURLsAvailable( 201 void SuggestionsHandler::OnSuggestionsURLsAvailable(
201 CancelableRequestProvider::Handle handle, 202 CancelableRequestProvider::Handle handle,
202 history::MostVisitedURLList data) { 203 const history::FilteredURLList& data) {
203 SetPagesValueFromTopSites(data); 204 SetPagesValueFromTopSites(data);
204 if (got_first_suggestions_request_) 205 if (got_first_suggestions_request_)
205 SendPagesValue(); 206 SendPagesValue();
206 } 207 }
207 208
208 void SuggestionsHandler::Observe(int type, 209 void SuggestionsHandler::Observe(int type,
209 const content::NotificationSource& source, 210 const content::NotificationSource& source,
210 const content::NotificationDetails& details) { 211 const content::NotificationDetails& details) {
211 DCHECK_EQ(type, chrome::NOTIFICATION_TOP_SITES_CHANGED); 212 DCHECK_EQ(type, chrome::NOTIFICATION_TOP_SITES_CHANGED);
212 213
213 // Suggestions urls changed, query again. 214 // Suggestions urls changed, query again.
214 StartQueryForSuggestions(); 215 StartQueryForSuggestions();
215 } 216 }
216 217
217 void SuggestionsHandler::BlacklistURL(const GURL& url) { 218 void SuggestionsHandler::BlacklistURL(const GURL& url) {
218 // TODO(georgey) blacklist an URL. 219 // TODO(georgey) blacklist an URL.
219 } 220 }
220 221
221 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) { 222 std::string SuggestionsHandler::GetDictionaryKeyForURL(const std::string& url) {
222 return base::MD5String(url); 223 return base::MD5String(url);
223 } 224 }
224 225
225 // static 226 // static
226 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) { 227 void SuggestionsHandler::RegisterUserPrefs(PrefService* prefs) {
227 // TODO(georgey) add user preferences (such as own blacklist) as needed. 228 // TODO(georgey) add user preferences (such as own blacklist) as needed.
228 } 229 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/ntp/suggestions_page_handler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698