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

Side by Side Diff: chrome/browser/ui/webui/popular_sites_internals_message_handler.cc

Issue 1995113002: Rename WebUI::CallJavascriptFunction to WebUI::CallJavascriptFunctionUnsafe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/popular_sites_internals_message_handler.h" 5 #include "chrome/browser/ui/webui/popular_sites_internals_message_handler.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 base::Bind(&PopularSitesInternalsMessageHandler::SendJson, 125 base::Bind(&PopularSitesInternalsMessageHandler::SendJson,
126 weak_ptr_factory_.GetWeakPtr())); 126 weak_ptr_factory_.GetWeakPtr()));
127 } 127 }
128 128
129 void PopularSitesInternalsMessageHandler::SendOverrides() { 129 void PopularSitesInternalsMessageHandler::SendOverrides() {
130 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs(); 130 PrefService* prefs = Profile::FromWebUI(web_ui())->GetPrefs();
131 std::string country = 131 std::string country =
132 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideCountry); 132 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideCountry);
133 std::string version = 133 std::string version =
134 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideVersion); 134 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideVersion);
135 web_ui()->CallJavascriptFunction( 135 web_ui()->CallJavascriptFunctionUnsafe(
136 "chrome.popular_sites_internals.receiveOverrides", 136 "chrome.popular_sites_internals.receiveOverrides",
137 base::StringValue(country), base::StringValue(version)); 137 base::StringValue(country), base::StringValue(version));
138 } 138 }
139 139
140 void PopularSitesInternalsMessageHandler::SendDownloadResult(bool success) { 140 void PopularSitesInternalsMessageHandler::SendDownloadResult(bool success) {
141 base::StringValue result(success ? "Success" : "Fail"); 141 base::StringValue result(success ? "Success" : "Fail");
142 web_ui()->CallJavascriptFunction( 142 web_ui()->CallJavascriptFunctionUnsafe(
143 "chrome.popular_sites_internals.receiveDownloadResult", result); 143 "chrome.popular_sites_internals.receiveDownloadResult", result);
144 } 144 }
145 145
146 void PopularSitesInternalsMessageHandler::SendSites() { 146 void PopularSitesInternalsMessageHandler::SendSites() {
147 std::unique_ptr<base::ListValue> sites_list(new base::ListValue); 147 std::unique_ptr<base::ListValue> sites_list(new base::ListValue);
148 for (const PopularSites::Site& site : popular_sites_->sites()) { 148 for (const PopularSites::Site& site : popular_sites_->sites()) {
149 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); 149 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue);
150 entry->SetString("title", site.title); 150 entry->SetString("title", site.title);
151 entry->SetString("url", site.url.spec()); 151 entry->SetString("url", site.url.spec());
152 sites_list->Append(std::move(entry)); 152 sites_list->Append(std::move(entry));
153 } 153 }
154 154
155 base::DictionaryValue result; 155 base::DictionaryValue result;
156 result.Set("sites", std::move(sites_list)); 156 result.Set("sites", std::move(sites_list));
157 result.SetString("country", popular_sites_->GetCountry()); 157 result.SetString("country", popular_sites_->GetCountry());
158 result.SetString("version", popular_sites_->GetVersion()); 158 result.SetString("version", popular_sites_->GetVersion());
159 web_ui()->CallJavascriptFunction( 159 web_ui()->CallJavascriptFunctionUnsafe(
160 "chrome.popular_sites_internals.receiveSites", result); 160 "chrome.popular_sites_internals.receiveSites", result);
161 } 161 }
162 162
163 void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) { 163 void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) {
164 web_ui()->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", 164 web_ui()->CallJavascriptFunctionUnsafe(
165 base::StringValue(json)); 165 "chrome.popular_sites_internals.receiveJson", base::StringValue(json));
166 } 166 }
167 167
168 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( 168 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable(
169 bool explicit_request, bool success) { 169 bool explicit_request, bool success) {
170 if (explicit_request) 170 if (explicit_request)
171 SendDownloadResult(success); 171 SendDownloadResult(success);
172 SendSites(); 172 SendSites();
173 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/policy_ui_handler.cc ('k') | chrome/browser/ui/webui/predictors/predictors_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698