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

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

Issue 1930413002: Pull g_browser_process out of PopularSites. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 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
Index: chrome/browser/android/ntp/popular_sites.cc
diff --git a/chrome/browser/android/ntp/popular_sites.cc b/chrome/browser/android/ntp/popular_sites.cc
index a43499139d6841dc5503405d356acfb75540662a..293de40edef031f56389d17985657ee0fe9dd8b5 100644
--- a/chrome/browser/android/ntp/popular_sites.cc
+++ b/chrome/browser/android/ntp/popular_sites.cc
@@ -17,7 +17,6 @@
#include "base/task_runner_util.h"
#include "base/time/time.h"
#include "base/values.h"
-#include "chrome/browser/browser_process.h"
#include "chrome/common/chrome_paths.h"
#include "components/google/core/browser/google_util.h"
#include "components/ntp_tiles/switches.h"
@@ -30,6 +29,7 @@
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
+using variations::VariationsService;
namespace {
@@ -75,21 +75,12 @@ std::string GetDefaultSearchEngineCountryCode(
return std::string();
}
-// Get the country that the experiment is running under
-std::string GetVariationsServiceCountry() {
- DCHECK(g_browser_process);
- variations::VariationsService* variations_service =
- g_browser_process->variations_service();
- if (variations_service)
- return variations_service->GetStoredPermanentCountry();
- return std::string();
-}
-
// Find out the country code of the user by using the Google country code if
// Google is the default search engine set. If Google is not the default search
// engine use the country provided by VariationsService. Fallback to a default
// if we can't make an educated guess.
std::string GetCountryToUse(const TemplateURLService* template_url_service,
+ VariationsService* variations_service,
const std::string& override_country) {
if (!override_country.empty())
return override_country;
@@ -97,8 +88,9 @@ std::string GetCountryToUse(const TemplateURLService* template_url_service,
std::string country_code = GetDefaultSearchEngineCountryCode(
template_url_service);
- if (country_code.empty())
- country_code = GetVariationsServiceCountry();
+ // Get the country that the experiment is running under
+ if (country_code.empty() && variations_service)
+ country_code = variations_service->GetStoredPermanentCountry();
if (country_code.empty())
country_code = kPopularSitesDefaultCountryCode;
@@ -178,6 +170,7 @@ PopularSites::Site::~Site() {}
PopularSites::PopularSites(PrefService* prefs,
const TemplateURLService* template_url_service,
+ VariationsService* variations_service,
net::URLRequestContextGetter* download_context,
const std::string& override_country,
const std::string& override_version,
@@ -186,7 +179,9 @@ PopularSites::PopularSites(PrefService* prefs,
: PopularSites(prefs,
template_url_service,
download_context,
- GetCountryToUse(template_url_service, override_country),
+ GetCountryToUse(template_url_service,
+ variations_service,
+ override_country),
GetVersionToUse(override_version),
GURL(),
force_download,
« no previous file with comments | « chrome/browser/android/ntp/popular_sites.h ('k') | chrome/browser/ui/webui/popular_sites_internals_message_handler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698