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

Unified Diff: chrome/browser/android/popular_sites.cc

Issue 1331113002: Popular sites on the NTP: Add Finch params for country and version (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@dont_leak_files
Patch Set: rebase Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/android/popular_sites.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « chrome/browser/android/popular_sites.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698