OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |