| Index: chrome/browser/android/popular_sites.cc
|
| diff --git a/chrome/browser/android/popular_sites.cc b/chrome/browser/android/popular_sites.cc
|
| index 55a157ec3b0bde889cad3ee2bd6cde6ab7e3d7c0..26a626890f74d51d2d00df2e81f952fa995ceeb3 100644
|
| --- a/chrome/browser/android/popular_sites.cc
|
| +++ b/chrome/browser/android/popular_sites.cc
|
| @@ -28,8 +28,9 @@ using content::BrowserThread;
|
| namespace {
|
|
|
| const char kPopularSitesURLFormat[] = "https://www.gstatic.com/chrome/ntp/%s";
|
| -const char kPopularSitesServerFilenameFormat[] = "suggested_sites_%s_2.json";
|
| +const char kPopularSitesServerFilenameFormat[] = "suggested_sites_%s_%s.json";
|
| const char kPopularSitesDefaultCountryCode[] = "DEFAULT";
|
| +const char kPopularSitesDefaultVersion[] = "2";
|
| const char kPopularSitesLocalFilename[] = "suggested_sites.json";
|
|
|
|
|
| @@ -55,7 +56,7 @@ std::string GetCountryCode(Profile* profile) {
|
| SearchEngineType::SEARCH_ENGINE_GOOGLE;
|
|
|
| if (!is_google_search_engine)
|
| - return kPopularSitesDefaultCountryCode;
|
| + return kPopularSitesDefaultCountryCode;
|
|
|
| GURL search_url = default_provider->GenerateSearchURL(
|
| template_url_service->search_terms_data());
|
| @@ -66,18 +67,31 @@ std::string GetCountryCode(Profile* profile) {
|
| return country_code;
|
| }
|
|
|
| -std::string GetPopularSitesServerFilename(Profile* profile,
|
| - const std::string& filename) {
|
| - if (!filename.empty())
|
| - return filename;
|
| -
|
| +std::string GetPopularSitesServerFilename(
|
| + Profile* profile,
|
| + const std::string& override_country,
|
| + const std::string& override_version,
|
| + const std::string& override_filename) {
|
| + if (!override_filename.empty())
|
| + return override_filename;
|
| +
|
| + std::string country = !override_country.empty() ? override_country
|
| + : GetCountryCode(profile);
|
| + std::string version = !override_version.empty() ? override_version
|
| + : kPopularSitesDefaultVersion;
|
| return base::StringPrintf(kPopularSitesServerFilenameFormat,
|
| - GetCountryCode(profile).c_str());
|
| + country.c_str(), version.c_str());
|
| }
|
|
|
| -GURL GetPopularSitesURL(Profile* profile, const std::string& filename) {
|
| +GURL GetPopularSitesURL(Profile* profile,
|
| + const std::string& override_country,
|
| + const std::string& override_version,
|
| + const std::string& override_filename) {
|
| return GURL(base::StringPrintf(kPopularSitesURLFormat,
|
| - GetPopularSitesServerFilename(profile, filename).c_str()));
|
| + GetPopularSitesServerFilename(profile,
|
| + override_country,
|
| + override_version,
|
| + override_filename).c_str()));
|
| }
|
|
|
| base::FilePath GetPopularSitesPath() {
|
| @@ -138,7 +152,9 @@ PopularSites::Site::Site(const base::string16& title,
|
| PopularSites::Site::~Site() {}
|
|
|
| PopularSites::PopularSites(Profile* profile,
|
| - const std::string& filename,
|
| + const std::string& override_country,
|
| + const std::string& override_version,
|
| + const std::string& override_filename,
|
| const FinishedCallback& callback)
|
| : callback_(callback), weak_ptr_factory_(this) {
|
| base::FilePath path = GetPopularSitesPath();
|
| @@ -146,8 +162,9 @@ PopularSites::PopularSites(Profile* profile,
|
| // local file afterwards.
|
| static bool overwrite = true;
|
| downloader_.reset(new FileDownloader(
|
| - GetPopularSitesURL(profile, filename), path, overwrite,
|
| - profile->GetRequestContext(),
|
| + GetPopularSitesURL(
|
| + profile, override_country, override_version, override_filename),
|
| + path, overwrite, profile->GetRequestContext(),
|
| base::Bind(&PopularSites::OnDownloadDone, base::Unretained(this), path)));
|
| overwrite = false;
|
| }
|
|
|