OLD | NEW |
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 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 weak_ptr_factory_.GetWeakPtr())); | 99 weak_ptr_factory_.GetWeakPtr())); |
100 } | 100 } |
101 | 101 |
102 void PopularSitesInternalsMessageHandler::SendDownloadResult(bool success) { | 102 void PopularSitesInternalsMessageHandler::SendDownloadResult(bool success) { |
103 base::StringValue result(success ? "Success" : "Fail"); | 103 base::StringValue result(success ? "Success" : "Fail"); |
104 web_ui()->CallJavascriptFunction( | 104 web_ui()->CallJavascriptFunction( |
105 "chrome.popular_sites_internals.receiveDownloadResult", result); | 105 "chrome.popular_sites_internals.receiveDownloadResult", result); |
106 } | 106 } |
107 | 107 |
108 void PopularSitesInternalsMessageHandler::SendSites() { | 108 void PopularSitesInternalsMessageHandler::SendSites() { |
109 scoped_ptr<base::ListValue> sites_list(new base::ListValue); | 109 std::unique_ptr<base::ListValue> sites_list(new base::ListValue); |
110 for (const PopularSites::Site& site : popular_sites_->sites()) { | 110 for (const PopularSites::Site& site : popular_sites_->sites()) { |
111 scoped_ptr<base::DictionaryValue> entry(new base::DictionaryValue); | 111 std::unique_ptr<base::DictionaryValue> entry(new base::DictionaryValue); |
112 entry->SetString("title", site.title); | 112 entry->SetString("title", site.title); |
113 entry->SetString("url", site.url.spec()); | 113 entry->SetString("url", site.url.spec()); |
114 sites_list->Append(std::move(entry)); | 114 sites_list->Append(std::move(entry)); |
115 } | 115 } |
116 | 116 |
117 base::DictionaryValue result; | 117 base::DictionaryValue result; |
118 result.Set("sites", std::move(sites_list)); | 118 result.Set("sites", std::move(sites_list)); |
119 result.SetString("country", popular_sites_->GetCountry()); | 119 result.SetString("country", popular_sites_->GetCountry()); |
120 result.SetString("version", popular_sites_->GetVersion()); | 120 result.SetString("version", popular_sites_->GetVersion()); |
121 web_ui()->CallJavascriptFunction( | 121 web_ui()->CallJavascriptFunction( |
122 "chrome.popular_sites_internals.receiveSites", result); | 122 "chrome.popular_sites_internals.receiveSites", result); |
123 } | 123 } |
124 | 124 |
125 void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) { | 125 void PopularSitesInternalsMessageHandler::SendJson(const std::string& json) { |
126 web_ui()->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", | 126 web_ui()->CallJavascriptFunction("chrome.popular_sites_internals.receiveJson", |
127 base::StringValue(json)); | 127 base::StringValue(json)); |
128 } | 128 } |
129 | 129 |
130 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( | 130 void PopularSitesInternalsMessageHandler::OnPopularSitesAvailable( |
131 bool explicit_request, bool success) { | 131 bool explicit_request, bool success) { |
132 if (explicit_request) | 132 if (explicit_request) |
133 SendDownloadResult(success); | 133 SendDownloadResult(success); |
134 SendSites(); | 134 SendSites(); |
135 } | 135 } |
OLD | NEW |