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

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

Issue 2664753002: Remove base::StringValue (Closed)
Patch Set: Rebase Created 3 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
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/json/json_writer.h" 9 #include "base/json/json_writer.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 107
108 void PopularSitesInternalsMessageHandler::SendOverrides() { 108 void PopularSitesInternalsMessageHandler::SendOverrides() {
109 PrefService* prefs = web_ui_->GetPrefs(); 109 PrefService* prefs = web_ui_->GetPrefs();
110 std::string url = 110 std::string url =
111 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideURL); 111 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideURL);
112 std::string country = 112 std::string country =
113 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideCountry); 113 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideCountry);
114 std::string version = 114 std::string version =
115 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideVersion); 115 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideVersion);
116 web_ui_->CallJavascriptFunction( 116 web_ui_->CallJavascriptFunction(
117 "chrome.popular_sites_internals.receiveOverrides", base::StringValue(url), 117 "chrome.popular_sites_internals.receiveOverrides", base::Value(url),
118 base::StringValue(country), base::StringValue(version)); 118 base::Value(country), base::Value(version));
119 } 119 }
120 120
121 void PopularSitesInternalsMessageHandler::SendDownloadResult(bool success) { 121 void PopularSitesInternalsMessageHandler::SendDownloadResult(bool success) {
122 base::StringValue result(success ? "Success" : "Fail"); 122 base::Value result(success ? "Success" : "Fail");
123 web_ui_->CallJavascriptFunction( 123 web_ui_->CallJavascriptFunction(
124 "chrome.popular_sites_internals.receiveDownloadResult", result); 124 "chrome.popular_sites_internals.receiveDownloadResult", result);
125 } 125 }
126 126
127 void PopularSitesInternalsMessageHandler::SendSites() { 127 void PopularSitesInternalsMessageHandler::SendSites() {
128 auto sites_list = base::MakeUnique<base::ListValue>(); 128 auto sites_list = base::MakeUnique<base::ListValue>();
129 for (const PopularSites::Site& site : popular_sites_->sites()) { 129 for (const PopularSites::Site& site : popular_sites_->sites()) {
130 auto entry = base::MakeUnique<base::DictionaryValue>(); 130 auto entry = base::MakeUnique<base::DictionaryValue>();
131 entry->SetString("title", site.title); 131 entry->SetString("title", site.title);
132 entry->SetString("url", site.url.spec()); 132 entry->SetString("url", site.url.spec());
133 sites_list->Append(std::move(entry)); 133 sites_list->Append(std::move(entry));
134 } 134 }
135 135
136 base::DictionaryValue result; 136 base::DictionaryValue result;
137 result.Set("sites", std::move(sites_list)); 137 result.Set("sites", std::move(sites_list));
138 result.SetString("url", popular_sites_->GetLastURLFetched().spec()); 138 result.SetString("url", popular_sites_->GetLastURLFetched().spec());
139 web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveSites", 139 web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveSites",
140 result); 140 result);
141 } 141 }
142 142
143 void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) { 143 void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) {
144 web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", 144 web_ui_->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson",
145 base::StringValue(json)); 145 base::Value(json));
146 } 146 }
147 147
148 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( 148 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable(
149 bool success) { 149 bool success) {
150 SendDownloadResult(success); 150 SendDownloadResult(success);
151 SendSites(); 151 SendSites();
152 } 152 }
153 153
154 } // namespace ntp_tiles 154 } // namespace ntp_tiles
OLDNEW
« no previous file with comments | « components/login/screens/screen_context.cc ('k') | components/ownership/owner_settings_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698