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

Side by Side Diff: components/ntp_tiles/webui/popular_sites_internals_message_handler.cc

Issue 2570783003: [Popular Sites] Split PopularSites interface and PopularSitesImpl (Closed)
Patch Set: Rebased and minor naming change. Created 4 years 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/ntp_tiles/webui/popular_sites_internals_message_handler.h" 5 #include "components/ntp_tiles/webui/popular_sites_internals_message_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 auto sites_list = base::MakeUnique<base::ListValue>(); 145 auto sites_list = base::MakeUnique<base::ListValue>();
146 for (const PopularSites::Site& site : popular_sites_->sites()) { 146 for (const PopularSites::Site& site : popular_sites_->sites()) {
147 auto entry = base::MakeUnique<base::DictionaryValue>(); 147 auto entry = base::MakeUnique<base::DictionaryValue>();
148 entry->SetString("title", site.title); 148 entry->SetString("title", site.title);
149 entry->SetString("url", site.url.spec()); 149 entry->SetString("url", site.url.spec());
150 sites_list->Append(std::move(entry)); 150 sites_list->Append(std::move(entry));
151 } 151 }
152 152
153 base::DictionaryValue result; 153 base::DictionaryValue result;
154 result.Set("sites", std::move(sites_list)); 154 result.Set("sites", std::move(sites_list));
155 result.SetString("url", popular_sites_->LastURL().spec()); 155 result.SetString("url", popular_sites_->GetLastURLFetched().spec());
156 web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveSites", 156 web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveSites",
157 result); 157 result);
158 } 158 }
159 159
160 void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) { 160 void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) {
161 web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", 161 web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson",
162 base::StringValue(json)); 162 base::StringValue(json));
163 } 163 }
164 164
165 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( 165 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable(
166 bool explicit_request, 166 bool explicit_request,
167 bool success) { 167 bool success) {
168 if (explicit_request) 168 if (explicit_request)
169 SendDownloadResult(success); 169 SendDownloadResult(success);
170 SendSites(); 170 SendSites();
171 } 171 }
172 172
173 } // namespace ntp_tiles 173 } // namespace ntp_tiles
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698