| OLD | NEW |
| 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/ntp_tiles_internals_message_handler.h" | 5 #include "components/ntp_tiles/webui/ntp_tiles_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/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 | 103 |
| 104 std::string url; | 104 std::string url; |
| 105 dict->GetString("popular.overrideURL", &url); | 105 dict->GetString("popular.overrideURL", &url); |
| 106 if (url.empty()) { | 106 if (url.empty()) { |
| 107 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideURL); | 107 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideURL); |
| 108 } else { | 108 } else { |
| 109 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideURL, | 109 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideURL, |
| 110 url_formatter::FixupURL(url, std::string()).spec()); | 110 url_formatter::FixupURL(url, std::string()).spec()); |
| 111 } | 111 } |
| 112 | 112 |
| 113 std::string directory; |
| 114 dict->GetString("popular.overrideDirectory", &directory); |
| 115 if (directory.empty()) { |
| 116 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideDirectory); |
| 117 } else { |
| 118 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideDirectory, |
| 119 directory); |
| 120 } |
| 121 |
| 113 std::string country; | 122 std::string country; |
| 114 dict->GetString("popular.overrideCountry", &country); | 123 dict->GetString("popular.overrideCountry", &country); |
| 115 if (country.empty()) { | 124 if (country.empty()) { |
| 116 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideCountry); | 125 prefs->ClearPref(ntp_tiles::prefs::kPopularSitesOverrideCountry); |
| 117 } else { | 126 } else { |
| 118 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideCountry, country); | 127 prefs->SetString(ntp_tiles::prefs::kPopularSitesOverrideCountry, country); |
| 119 } | 128 } |
| 120 | 129 |
| 121 std::string version; | 130 std::string version; |
| 122 dict->GetString("popular.overrideVersion", &version); | 131 dict->GetString("popular.overrideVersion", &version); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 | 183 |
| 175 if (most_visited_sites_->DoesSourceExist(TileSource::SUGGESTIONS_SERVICE)) { | 184 if (most_visited_sites_->DoesSourceExist(TileSource::SUGGESTIONS_SERVICE)) { |
| 176 value.SetString("suggestionsService.status", suggestions_status_); | 185 value.SetString("suggestionsService.status", suggestions_status_); |
| 177 } else { | 186 } else { |
| 178 value.SetBoolean("suggestionsService", false); | 187 value.SetBoolean("suggestionsService", false); |
| 179 } | 188 } |
| 180 | 189 |
| 181 if (most_visited_sites_->DoesSourceExist(TileSource::POPULAR)) { | 190 if (most_visited_sites_->DoesSourceExist(TileSource::POPULAR)) { |
| 182 auto* popular_sites = most_visited_sites_->popular_sites(); | 191 auto* popular_sites = most_visited_sites_->popular_sites(); |
| 183 value.SetString("popular.url", popular_sites->GetURLToFetch().spec()); | 192 value.SetString("popular.url", popular_sites->GetURLToFetch().spec()); |
| 193 value.SetString("popular.directory", popular_sites->GetDirectoryToFetch()); |
| 184 value.SetString("popular.country", popular_sites->GetCountryToFetch()); | 194 value.SetString("popular.country", popular_sites->GetCountryToFetch()); |
| 185 value.SetString("popular.version", popular_sites->GetVersionToFetch()); | 195 value.SetString("popular.version", popular_sites->GetVersionToFetch()); |
| 186 | 196 |
| 187 value.SetString( | 197 value.SetString( |
| 188 "popular.overrideURL", | 198 "popular.overrideURL", |
| 189 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideURL)); | 199 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideURL)); |
| 190 value.SetString( | 200 value.SetString( |
| 201 "popular.overrideDirectory", |
| 202 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideDirectory)); |
| 203 value.SetString( |
| 191 "popular.overrideCountry", | 204 "popular.overrideCountry", |
| 192 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideCountry)); | 205 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideCountry)); |
| 193 value.SetString( | 206 value.SetString( |
| 194 "popular.overrideVersion", | 207 "popular.overrideVersion", |
| 195 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideVersion)); | 208 prefs->GetString(ntp_tiles::prefs::kPopularSitesOverrideVersion)); |
| 196 | 209 |
| 197 value.SetString("popular.json", popular_sites_json_); | 210 value.SetString("popular.json", popular_sites_json_); |
| 198 } else { | 211 } else { |
| 199 value.SetBoolean("popular", false); | 212 value.SetBoolean("popular", false); |
| 200 } | 213 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 223 | 236 |
| 224 void NTPTilesInternalsMessageHandler::OnMostVisitedURLsAvailable( | 237 void NTPTilesInternalsMessageHandler::OnMostVisitedURLsAvailable( |
| 225 const NTPTilesVector& tiles) { | 238 const NTPTilesVector& tiles) { |
| 226 SendTiles(tiles); | 239 SendTiles(tiles); |
| 227 } | 240 } |
| 228 | 241 |
| 229 void NTPTilesInternalsMessageHandler::OnIconMadeAvailable( | 242 void NTPTilesInternalsMessageHandler::OnIconMadeAvailable( |
| 230 const GURL& site_url) {} | 243 const GURL& site_url) {} |
| 231 | 244 |
| 232 } // namespace ntp_tiles | 245 } // namespace ntp_tiles |
| OLD | NEW |