Chromium Code Reviews| Index: components/ntp_tiles/popular_sites_impl.cc |
| diff --git a/components/ntp_tiles/popular_sites_impl.cc b/components/ntp_tiles/popular_sites_impl.cc |
| index f083770a26ebd13a3f58813acfd2d20841e5f690..bed315197ce069c655f723a41f7897e85764e7d4 100644 |
| --- a/components/ntp_tiles/popular_sites_impl.cc |
| +++ b/components/ntp_tiles/popular_sites_impl.cc |
| @@ -52,7 +52,8 @@ namespace ntp_tiles { |
| namespace { |
| const char kPopularSitesURLFormat[] = |
| - "https://www.gstatic.com/chrome/ntp/suggested_sites_%s_%s.json"; |
| + "https://www.gstatic.com/%ssuggested_sites_%s_%s.json"; |
| +const char kPopularSitesDefaultPath[] = "chrome/ntp/"; |
|
sfiera
2017/04/25 13:35:42
This isn't the [whole] path, it's the directory.
mastiz
2017/04/25 17:54:00
Thanks, renamed path->directory.
|
| const char kPopularSitesDefaultCountryCode[] = "DEFAULT"; |
| const char kPopularSitesDefaultVersion[] = "5"; |
| const int kPopularSitesRedownloadIntervalHours = 24; |
| @@ -65,10 +66,11 @@ const char kPopularSitesJsonPref[] = "suggested_sites_json"; |
| // versions of Chrome, no longer used. Remove after M61. |
| const char kPopularSitesLocalFilenameToCleanup[] = "suggested_sites.json"; |
| -GURL GetPopularSitesURL(const std::string& country, |
| +GURL GetPopularSitesURL(const std::string& path, |
| + const std::string& country, |
| const std::string& version) { |
| - return GURL(base::StringPrintf(kPopularSitesURLFormat, country.c_str(), |
| - version.c_str())); |
| + return GURL(base::StringPrintf(kPopularSitesURLFormat, path.c_str(), |
| + country.c_str(), version.c_str())); |
| } |
| // Extract the country from the default search engine if the default search |
| @@ -259,13 +261,24 @@ GURL PopularSitesImpl::GetLastURLFetched() const { |
| } |
| GURL PopularSitesImpl::GetURLToFetch() { |
| + const std::string path = GetPathToFetch(); |
| const std::string country = GetCountryToFetch(); |
| const std::string version = GetVersionToFetch(); |
| const GURL override_url = |
| GURL(prefs_->GetString(ntp_tiles::prefs::kPopularSitesOverrideURL)); |
| return override_url.is_valid() ? override_url |
| - : GetPopularSitesURL(country, version); |
| + : GetPopularSitesURL(path, country, version); |
| +} |
| + |
| +std::string PopularSitesImpl::GetPathToFetch() { |
| + std::string path = |
| + prefs_->GetString(ntp_tiles::prefs::kPopularSitesOverridePath); |
| + |
| + if (path.empty()) |
| + path = kPopularSitesDefaultPath; |
| + |
| + return path; |
| } |
| // Determine the country code to use. In order of precedence: |
| @@ -325,6 +338,8 @@ void PopularSitesImpl::RegisterProfilePrefs( |
| user_prefs::PrefRegistrySyncable* user_prefs) { |
| user_prefs->RegisterStringPref(ntp_tiles::prefs::kPopularSitesOverrideURL, |
| std::string()); |
| + user_prefs->RegisterStringPref(ntp_tiles::prefs::kPopularSitesOverridePath, |
| + std::string()); |
| user_prefs->RegisterStringPref(ntp_tiles::prefs::kPopularSitesOverrideCountry, |
| std::string()); |
| user_prefs->RegisterStringPref(ntp_tiles::prefs::kPopularSitesOverrideVersion, |
| @@ -413,7 +428,8 @@ void PopularSitesImpl::OnDownloadFailed() { |
| if (!is_fallback_) { |
| DLOG(WARNING) << "Download country site list failed"; |
| is_fallback_ = true; |
| - pending_url_ = GetPopularSitesURL(kPopularSitesDefaultCountryCode, |
| + pending_url_ = GetPopularSitesURL(kPopularSitesDefaultPath, |
| + kPopularSitesDefaultCountryCode, |
| kPopularSitesDefaultVersion); |
| FetchPopularSites(); |
| } else { |