Commit 4c2eb40e authored by blundell@chromium.org's avatar blundell@chromium.org

Change google_util::AppendGoogleLocaleParam to take in the application locale

This function will be componentized, and hence cannot reference
g_browser_process.

BUG=373203
TBR=thakis

Review URL: https://codereview.chromium.org/327793005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@276886 0039d316-1c4b-4281-b951-d872f2087c98
parent fda0b119
...@@ -312,8 +312,8 @@ void ExistingUserController::CancelPasswordChangedFlow() { ...@@ -312,8 +312,8 @@ void ExistingUserController::CancelPasswordChangedFlow() {
void ExistingUserController::CreateAccount() { void ExistingUserController::CreateAccount() {
content::RecordAction(base::UserMetricsAction("Login.CreateAccount")); content::RecordAction(base::UserMetricsAction("Login.CreateAccount"));
guest_mode_url_ = guest_mode_url_ = google_util::AppendGoogleLocaleParam(
google_util::AppendGoogleLocaleParam(GURL(kCreateAccountURL)); GURL(kCreateAccountURL), g_browser_process->GetApplicationLocale());
LoginAsGuest(); LoginAsGuest();
} }
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h"
#include "components/google/core/browser/google_switches.h" #include "components/google/core/browser/google_switches.h"
#include "components/google/core/browser/google_url_tracker.h" #include "components/google/core/browser/google_url_tracker.h"
#include "components/url_fixer/url_fixer.h" #include "components/url_fixer/url_fixer.h"
...@@ -72,16 +71,10 @@ std::string GetGoogleLocale(const std::string& application_locale) { ...@@ -72,16 +71,10 @@ std::string GetGoogleLocale(const std::string& application_locale) {
return (application_locale == "nb") ? "no" : application_locale; return (application_locale == "nb") ? "no" : application_locale;
} }
GURL AppendGoogleLocaleParam(const GURL& url) { GURL AppendGoogleLocaleParam(const GURL& url,
const std::string& application_locale) {
return net::AppendQueryParameter( return net::AppendQueryParameter(
url, "hl", GetGoogleLocale(g_browser_process->GetApplicationLocale())); url, "hl", GetGoogleLocale(application_locale));
}
std::string StringAppendGoogleLocaleParam(const std::string& url) {
GURL original_url(url);
DCHECK(original_url.is_valid());
GURL localized_url = AppendGoogleLocaleParam(original_url);
return localized_url.spec();
} }
std::string GetGoogleCountryCode(GURL google_homepage_url) { std::string GetGoogleCountryCode(GURL google_homepage_url) {
......
...@@ -34,10 +34,8 @@ std::string GetGoogleLocale(const std::string& application_locale); ...@@ -34,10 +34,8 @@ std::string GetGoogleLocale(const std::string& application_locale);
// Adds the Google locale string to the URL (e.g., hl=en-US). This does not // Adds the Google locale string to the URL (e.g., hl=en-US). This does not
// check to see if the param already exists. // check to see if the param already exists.
GURL AppendGoogleLocaleParam(const GURL& url); GURL AppendGoogleLocaleParam(const GURL& url,
const std::string& application_locale);
// String version of AppendGoogleLocaleParam.
std::string StringAppendGoogleLocaleParam(const std::string& url);
// Returns the Google country code string for the given Google homepage URL. // Returns the Google country code string for the given Google homepage URL.
std::string GetGoogleCountryCode(GURL google_homepage_url); std::string GetGoogleCountryCode(GURL google_homepage_url);
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window.h" #include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/google/google_util.h" #include "chrome/browser/google/google_util.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
...@@ -336,7 +337,8 @@ void CloudPrintFlowHandler::RegisterMessages() { ...@@ -336,7 +337,8 @@ void CloudPrintFlowHandler::RegisterMessages() {
NavigationEntry* pending_entry = controller->GetPendingEntry(); NavigationEntry* pending_entry = controller->GetPendingEntry();
if (pending_entry) { if (pending_entry) {
pending_entry->SetURL(google_util::AppendGoogleLocaleParam( pending_entry->SetURL(google_util::AppendGoogleLocaleParam(
cloud_devices::GetCloudPrintRelativeURL("client/dialog.html"))); cloud_devices::GetCloudPrintRelativeURL("client/dialog.html"),
g_browser_process->GetApplicationLocale()));
} }
registrar_.Add(this, content::NOTIFICATION_LOAD_STOP, registrar_.Add(this, content::NOTIFICATION_LOAD_STOP,
content::Source<NavigationController>(controller)); content::Source<NavigationController>(controller));
...@@ -711,8 +713,9 @@ void CreateCloudPrintSigninTab(Browser* browser, ...@@ -711,8 +713,9 @@ void CreateCloudPrintSigninTab(Browser* browser,
DCHECK_CURRENTLY_ON(BrowserThread::UI); DCHECK_CURRENTLY_ON(BrowserThread::UI);
GURL url = add_account ? cloud_devices::GetCloudPrintAddAccountURL() GURL url = add_account ? cloud_devices::GetCloudPrintAddAccountURL()
: cloud_devices::GetCloudPrintSigninURL(); : cloud_devices::GetCloudPrintSigninURL();
content::WebContents* web_contents = browser->OpenURL( content::WebContents* web_contents = browser->OpenURL(content::OpenURLParams(
content::OpenURLParams(google_util::AppendGoogleLocaleParam(url), google_util::AppendGoogleLocaleParam(
url, g_browser_process->GetApplicationLocale()),
content::Referrer(), content::Referrer(),
NEW_FOREGROUND_TAB, NEW_FOREGROUND_TAB,
content::PAGE_TRANSITION_AUTO_BOOKMARK, content::PAGE_TRANSITION_AUTO_BOOKMARK,
......
...@@ -453,7 +453,8 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) { ...@@ -453,7 +453,8 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
base::StringPrintf(kSbDiagnosticUrl, base::StringPrintf(kSbDiagnosticUrl,
net::EscapeQueryParamValue(bad_url_spec, true).c_str()); net::EscapeQueryParamValue(bad_url_spec, true).c_str());
GURL diagnostic_url(diagnostic); GURL diagnostic_url(diagnostic);
diagnostic_url = google_util::AppendGoogleLocaleParam(diagnostic_url); diagnostic_url = google_util::AppendGoogleLocaleParam(
diagnostic_url, g_browser_process->GetApplicationLocale());
DCHECK(unsafe_resources_[element_index].threat_type == DCHECK(unsafe_resources_[element_index].threat_type ==
SB_THREAT_TYPE_URL_MALWARE || SB_THREAT_TYPE_URL_MALWARE ||
unsafe_resources_[element_index].threat_type == unsafe_resources_[element_index].threat_type ==
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/strings/string_util.h" #include "base/strings/string_util.h"
#include "base/strings/stringprintf.h" #include "base/strings/stringprintf.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_util.h" #include "chrome/browser/google/google_util.h"
#include "chrome/browser/safe_browsing/chunk.pb.h" #include "chrome/browser/safe_browsing/chunk.pb.h"
#include "crypto/sha2.h" #include "crypto/sha2.h"
...@@ -508,7 +509,8 @@ GURL GeneratePhishingReportUrl(const std::string& report_page, ...@@ -508,7 +509,8 @@ GURL GeneratePhishingReportUrl(const std::string& report_page,
GURL report_url(report_page + base::StringPrintf(kReportParams, GURL report_url(report_page + base::StringPrintf(kReportParams,
client_name.c_str(), client_name.c_str(),
current_esc.c_str())); current_esc.c_str()));
return google_util::AppendGoogleLocaleParam(report_url); return google_util::AppendGoogleLocaleParam(
report_url, g_browser_process->GetApplicationLocale());
} }
SBFullHash StringToSBFullHash(const std::string& hash_in) { SBFullHash StringToSBFullHash(const std::string& hash_in) {
......
...@@ -426,15 +426,21 @@ void ExtensionSettingsHandler::GetLocalizedValues( ...@@ -426,15 +426,21 @@ void ExtensionSettingsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEVELOPER_MODE_LINK)); l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEVELOPER_MODE_LINK));
source->AddString("extensionSettingsNoExtensions", source->AddString("extensionSettingsNoExtensions",
l10n_util::GetStringUTF16(IDS_EXTENSIONS_NONE_INSTALLED)); l10n_util::GetStringUTF16(IDS_EXTENSIONS_NONE_INSTALLED));
source->AddString("extensionSettingsSuggestGallery", source->AddString(
l10n_util::GetStringFUTF16(IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY, "extensionSettingsSuggestGallery",
base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam( l10n_util::GetStringFUTF16(
GURL(extension_urls::GetExtensionGalleryURL())).spec()))); IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY,
base::ASCIIToUTF16(
google_util::AppendGoogleLocaleParam(
GURL(extension_urls::GetExtensionGalleryURL()),
g_browser_process->GetApplicationLocale()).spec())));
source->AddString("extensionSettingsGetMoreExtensions", source->AddString("extensionSettingsGetMoreExtensions",
l10n_util::GetStringUTF16(IDS_GET_MORE_EXTENSIONS)); l10n_util::GetStringUTF16(IDS_GET_MORE_EXTENSIONS));
source->AddString("extensionSettingsGetMoreExtensionsUrl", source->AddString("extensionSettingsGetMoreExtensionsUrl",
base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam( base::ASCIIToUTF16(
GURL(extension_urls::GetExtensionGalleryURL())).spec())); google_util::AppendGoogleLocaleParam(
GURL(extension_urls::GetExtensionGalleryURL()),
g_browser_process->GetApplicationLocale()).spec()));
source->AddString("extensionSettingsExtensionId", source->AddString("extensionSettingsExtensionId",
l10n_util::GetStringUTF16(IDS_EXTENSIONS_ID)); l10n_util::GetStringUTF16(IDS_EXTENSIONS_ID));
source->AddString("extensionSettingsExtensionPath", source->AddString("extensionSettingsExtensionPath",
...@@ -493,11 +499,15 @@ void ExtensionSettingsHandler::GetLocalizedValues( ...@@ -493,11 +499,15 @@ void ExtensionSettingsHandler::GetLocalizedValues(
source->AddString("extensionSettingsLearnMore", source->AddString("extensionSettingsLearnMore",
l10n_util::GetStringUTF16(IDS_LEARN_MORE)); l10n_util::GetStringUTF16(IDS_LEARN_MORE));
source->AddString("extensionSettingsCorruptInstallHelpUrl", source->AddString("extensionSettingsCorruptInstallHelpUrl",
base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam( base::ASCIIToUTF16(
GURL(chrome::kCorruptExtensionURL)).spec())); google_util::AppendGoogleLocaleParam(
GURL(chrome::kCorruptExtensionURL),
g_browser_process->GetApplicationLocale()).spec()));
source->AddString("extensionSettingsSuspiciousInstallHelpUrl", source->AddString("extensionSettingsSuspiciousInstallHelpUrl",
base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam( base::ASCIIToUTF16(
GURL(chrome::kRemoveNonCWSExtensionURL)).spec())); google_util::AppendGoogleLocaleParam(
GURL(chrome::kRemoveNonCWSExtensionURL),
g_browser_process->GetApplicationLocale()).spec()));
source->AddString("extensionSettingsShowButton", source->AddString("extensionSettingsShowButton",
l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON)); l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON));
source->AddString("extensionSettingsLoadUnpackedButton", source->AddString("extensionSettingsLoadUnpackedButton",
...@@ -512,9 +522,11 @@ void ExtensionSettingsHandler::GetLocalizedValues( ...@@ -512,9 +522,11 @@ void ExtensionSettingsHandler::GetLocalizedValues(
"extensionSettingsAppsDevToolsPromoHTML", "extensionSettingsAppsDevToolsPromoHTML",
l10n_util::GetStringFUTF16( l10n_util::GetStringFUTF16(
IDS_EXTENSIONS_APPS_DEV_TOOLS_PROMO_HTML, IDS_EXTENSIONS_APPS_DEV_TOOLS_PROMO_HTML,
base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam( base::ASCIIToUTF16(
google_util::AppendGoogleLocaleParam(
GURL(extension_urls::GetWebstoreItemDetailURLPrefix() + GURL(extension_urls::GetWebstoreItemDetailURLPrefix() +
kAppsDeveloperToolsExtensionId)).spec()))); kAppsDeveloperToolsExtensionId),
g_browser_process->GetApplicationLocale()).spec())));
source->AddString( source->AddString(
"extensionSettingsAppDevToolsPromoClose", "extensionSettingsAppDevToolsPromoClose",
l10n_util::GetStringUTF16(IDS_CLOSE)); l10n_util::GetStringUTF16(IDS_CLOSE));
......
...@@ -310,7 +310,7 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() { ...@@ -310,7 +310,7 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() {
localized_strings.SetString("learnMore", localized_strings.SetString("learnMore",
l10n_util::GetStringUTF16(new_tab_link_ids)); l10n_util::GetStringUTF16(new_tab_link_ids));
localized_strings.SetString("learnMoreLink", GURL(new_tab_link).spec()); localized_strings.SetString("learnMoreLink", new_tab_link);
bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean( bool bookmark_bar_attached = profile_->GetPrefs()->GetBoolean(
prefs::kShowBookmarkBar); prefs::kShowBookmarkBar);
...@@ -356,7 +356,7 @@ void NTPResourceCache::CreateNewTabGuestHTML() { ...@@ -356,7 +356,7 @@ void NTPResourceCache::CreateNewTabGuestHTML() {
localized_strings.SetString("enterpriseLearnMore", localized_strings.SetString("enterpriseLearnMore",
l10n_util::GetStringUTF16(IDS_LEARN_MORE)); l10n_util::GetStringUTF16(IDS_LEARN_MORE));
localized_strings.SetString("enterpriseInfoHintLink", localized_strings.SetString("enterpriseInfoHintLink",
GURL(chrome::kLearnMoreEnterpriseURL).spec()); chrome::kLearnMoreEnterpriseURL);
} else { } else {
localized_strings.SetString("enterpriseInfoVisible", "false"); localized_strings.SetString("enterpriseInfoVisible", "false");
} }
...@@ -368,8 +368,7 @@ void NTPResourceCache::CreateNewTabGuestHTML() { ...@@ -368,8 +368,7 @@ void NTPResourceCache::CreateNewTabGuestHTML() {
l10n_util::GetStringUTF16(guest_tab_heading_ids)); l10n_util::GetStringUTF16(guest_tab_heading_ids));
localized_strings.SetString("learnMore", localized_strings.SetString("learnMore",
l10n_util::GetStringUTF16(guest_tab_link_ids)); l10n_util::GetStringUTF16(guest_tab_link_ids));
localized_strings.SetString("learnMoreLink", localized_strings.SetString("learnMoreLink", guest_tab_link);
GURL(guest_tab_link).spec());
webui::SetFontAndTextDirection(&localized_strings); webui::SetFontAndTextDirection(&localized_strings);
...@@ -459,7 +458,8 @@ void NTPResourceCache::CreateNewTabHTML() { ...@@ -459,7 +458,8 @@ void NTPResourceCache::CreateNewTabHTML() {
l10n_util::GetStringUTF16(IDS_LEARN_MORE)); l10n_util::GetStringUTF16(IDS_LEARN_MORE));
load_time_data.SetString("webStoreLink", load_time_data.SetString("webStoreLink",
google_util::AppendGoogleLocaleParam( google_util::AppendGoogleLocaleParam(
GURL(extension_urls::GetWebstoreLaunchURL())).spec()); GURL(extension_urls::GetWebstoreLaunchURL()),
g_browser_process->GetApplicationLocale()).spec());
load_time_data.SetString("appInstallHintText", load_time_data.SetString("appInstallHintText",
l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL)); l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL));
load_time_data.SetBoolean("isDiscoveryInNTPEnabled", load_time_data.SetBoolean("isDiscoveryInNTPEnabled",
......
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "base/values.h" #include "base/values.h"
#include "chrome/app/chrome_command_ids.h" #include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_util.h" #include "chrome/browser/google/google_util.h"
#include "chrome/browser/lifetime/application_lifetime.h" #include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
...@@ -221,16 +222,21 @@ void SyncSetupHandler::GetStaticLocalizedValues( ...@@ -221,16 +222,21 @@ void SyncSetupHandler::GetStaticLocalizedValues(
GetStringFUTF16(IDS_SYNC_ENCRYPTION_SECTION_MESSAGE, product_name)); GetStringFUTF16(IDS_SYNC_ENCRYPTION_SECTION_MESSAGE, product_name));
localized_strings->SetString( localized_strings->SetString(
"passphraseRecover", "passphraseRecover",
GetStringFUTF16(IDS_SYNC_PASSPHRASE_RECOVER, GetStringFUTF16(
IDS_SYNC_PASSPHRASE_RECOVER,
base::ASCIIToUTF16( base::ASCIIToUTF16(
google_util::StringAppendGoogleLocaleParam( google_util::AppendGoogleLocaleParam(
chrome::kSyncGoogleDashboardURL)))); GURL(chrome::kSyncGoogleDashboardURL),
localized_strings->SetString("stopSyncingExplanation", g_browser_process->GetApplicationLocale()).spec())));
localized_strings->SetString(
"stopSyncingExplanation",
l10n_util::GetStringFUTF16( l10n_util::GetStringFUTF16(
IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL, IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME), l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
base::ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam( base::ASCIIToUTF16(
chrome::kSyncGoogleDashboardURL)))); google_util::AppendGoogleLocaleParam(
GURL(chrome::kSyncGoogleDashboardURL),
g_browser_process->GetApplicationLocale()).spec())));
localized_strings->SetString("deleteProfileLabel", localized_strings->SetString("deleteProfileLabel",
l10n_util::GetStringUTF16(IDS_SYNC_STOP_DELETE_PROFILE_LABEL)); l10n_util::GetStringUTF16(IDS_SYNC_STOP_DELETE_PROFILE_LABEL));
localized_strings->SetString("stopSyncingTitle", localized_strings->SetString("stopSyncingTitle",
......
...@@ -119,9 +119,11 @@ void WebResourceService::StartFetch() { ...@@ -119,9 +119,11 @@ void WebResourceService::StartFetch() {
// Balanced in OnURLFetchComplete. // Balanced in OnURLFetchComplete.
AddRef(); AddRef();
GURL web_resource_server = apply_locale_to_url_ ? GURL web_resource_server =
google_util::AppendGoogleLocaleParam(web_resource_server_) : apply_locale_to_url_
web_resource_server_; ? google_util::AppendGoogleLocaleParam(
web_resource_server_, g_browser_process->GetApplicationLocale())
: web_resource_server_;
DVLOG(1) << "WebResourceService StartFetch " << web_resource_server; DVLOG(1) << "WebResourceService StartFetch " << web_resource_server;
url_fetcher_.reset(net::URLFetcher::Create( url_fetcher_.reset(net::URLFetcher::Create(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment