summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 02:18:56 +0000
committerblundell@chromium.org <blundell@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-13 02:18:56 +0000
commit4c2eb40ea4ef62a5d003ce6e8afc9d5f5613aace (patch)
tree4b3b003ee7be39cbc387ec44a35cb7b256399755
parentfda0b1195c86de9c6f1bf993b31fb08b1ee926b7 (diff)
downloadchromium_src-4c2eb40ea4ef62a5d003ce6e8afc9d5f5613aace.zip
chromium_src-4c2eb40ea4ef62a5d003ce6e8afc9d5f5613aace.tar.gz
chromium_src-4c2eb40ea4ef62a5d003ce6e8afc9d5f5613aace.tar.bz2
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
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc4
-rw-r--r--chrome/browser/google/google_util.cc13
-rw-r--r--chrome/browser/google/google_util.h6
-rw-r--r--chrome/browser/printing/print_dialog_cloud.cc17
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_blocking_page.cc3
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_util.cc4
-rw-r--r--chrome/browser/ui/webui/extensions/extension_settings_handler.cc38
-rw-r--r--chrome/browser/ui/webui/ntp/ntp_resource_cache.cc10
-rw-r--r--chrome/browser/ui/webui/sync_setup_handler.cc20
-rw-r--r--chrome/browser/web_resource/web_resource_service.cc8
10 files changed, 70 insertions, 53 deletions
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index 4a4d714..b2bdbc6 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -312,8 +312,8 @@ void ExistingUserController::CancelPasswordChangedFlow() {
void ExistingUserController::CreateAccount() {
content::RecordAction(base::UserMetricsAction("Login.CreateAccount"));
- guest_mode_url_ =
- google_util::AppendGoogleLocaleParam(GURL(kCreateAccountURL));
+ guest_mode_url_ = google_util::AppendGoogleLocaleParam(
+ GURL(kCreateAccountURL), g_browser_process->GetApplicationLocale());
LoginAsGuest();
}
diff --git a/chrome/browser/google/google_util.cc b/chrome/browser/google/google_util.cc
index 551cf32..a68e938 100644
--- a/chrome/browser/google/google_util.cc
+++ b/chrome/browser/google/google_util.cc
@@ -13,7 +13,6 @@
#include "base/strings/string_split.h"
#include "base/strings/string_util.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_url_tracker.h"
#include "components/url_fixer/url_fixer.h"
@@ -72,16 +71,10 @@ std::string GetGoogleLocale(const std::string& 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(
- url, "hl", GetGoogleLocale(g_browser_process->GetApplicationLocale()));
-}
-
-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();
+ url, "hl", GetGoogleLocale(application_locale));
}
std::string GetGoogleCountryCode(GURL google_homepage_url) {
diff --git a/chrome/browser/google/google_util.h b/chrome/browser/google/google_util.h
index 3210405..67e2bb3 100644
--- a/chrome/browser/google/google_util.h
+++ b/chrome/browser/google/google_util.h
@@ -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
// check to see if the param already exists.
-GURL AppendGoogleLocaleParam(const GURL& url);
-
-// String version of AppendGoogleLocaleParam.
-std::string StringAppendGoogleLocaleParam(const std::string& url);
+GURL AppendGoogleLocaleParam(const GURL& url,
+ const std::string& application_locale);
// Returns the Google country code string for the given Google homepage URL.
std::string GetGoogleCountryCode(GURL google_homepage_url);
diff --git a/chrome/browser/printing/print_dialog_cloud.cc b/chrome/browser/printing/print_dialog_cloud.cc
index e610947..6e335e0 100644
--- a/chrome/browser/printing/print_dialog_cloud.cc
+++ b/chrome/browser/printing/print_dialog_cloud.cc
@@ -14,6 +14,7 @@
#include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/devtools/devtools_window.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
@@ -336,7 +337,8 @@ void CloudPrintFlowHandler::RegisterMessages() {
NavigationEntry* pending_entry = controller->GetPendingEntry();
if (pending_entry) {
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,
content::Source<NavigationController>(controller));
@@ -711,12 +713,13 @@ void CreateCloudPrintSigninTab(Browser* browser,
DCHECK_CURRENTLY_ON(BrowserThread::UI);
GURL url = add_account ? cloud_devices::GetCloudPrintAddAccountURL()
: cloud_devices::GetCloudPrintSigninURL();
- content::WebContents* web_contents = browser->OpenURL(
- content::OpenURLParams(google_util::AppendGoogleLocaleParam(url),
- content::Referrer(),
- NEW_FOREGROUND_TAB,
- content::PAGE_TRANSITION_AUTO_BOOKMARK,
- false));
+ content::WebContents* web_contents = browser->OpenURL(content::OpenURLParams(
+ google_util::AppendGoogleLocaleParam(
+ url, g_browser_process->GetApplicationLocale()),
+ content::Referrer(),
+ NEW_FOREGROUND_TAB,
+ content::PAGE_TRANSITION_AUTO_BOOKMARK,
+ false));
new SignInObserver(web_contents, cloud_devices::GetCloudPrintURL(), callback);
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
index 85877cc..4f2c67ff 100644
--- a/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_blocking_page.cc
@@ -453,7 +453,8 @@ void SafeBrowsingBlockingPage::CommandReceived(const std::string& cmd) {
base::StringPrintf(kSbDiagnosticUrl,
net::EscapeQueryParamValue(bad_url_spec, true).c_str());
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 ==
SB_THREAT_TYPE_URL_MALWARE ||
unsafe_resources_[element_index].threat_type ==
diff --git a/chrome/browser/safe_browsing/safe_browsing_util.cc b/chrome/browser/safe_browsing/safe_browsing_util.cc
index 8630e04..be57484 100644
--- a/chrome/browser/safe_browsing/safe_browsing_util.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_util.cc
@@ -7,6 +7,7 @@
#include "base/logging.h"
#include "base/strings/string_util.h"
#include "base/strings/stringprintf.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/safe_browsing/chunk.pb.h"
#include "crypto/sha2.h"
@@ -508,7 +509,8 @@ GURL GeneratePhishingReportUrl(const std::string& report_page,
GURL report_url(report_page + base::StringPrintf(kReportParams,
client_name.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) {
diff --git a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
index f25b8db..44cec5f 100644
--- a/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
+++ b/chrome/browser/ui/webui/extensions/extension_settings_handler.cc
@@ -426,15 +426,21 @@ void ExtensionSettingsHandler::GetLocalizedValues(
l10n_util::GetStringUTF16(IDS_EXTENSIONS_DEVELOPER_MODE_LINK));
source->AddString("extensionSettingsNoExtensions",
l10n_util::GetStringUTF16(IDS_EXTENSIONS_NONE_INSTALLED));
- source->AddString("extensionSettingsSuggestGallery",
- l10n_util::GetStringFUTF16(IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY,
- base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam(
- GURL(extension_urls::GetExtensionGalleryURL())).spec())));
+ source->AddString(
+ "extensionSettingsSuggestGallery",
+ l10n_util::GetStringFUTF16(
+ IDS_EXTENSIONS_NONE_INSTALLED_SUGGEST_GALLERY,
+ base::ASCIIToUTF16(
+ google_util::AppendGoogleLocaleParam(
+ GURL(extension_urls::GetExtensionGalleryURL()),
+ g_browser_process->GetApplicationLocale()).spec())));
source->AddString("extensionSettingsGetMoreExtensions",
l10n_util::GetStringUTF16(IDS_GET_MORE_EXTENSIONS));
source->AddString("extensionSettingsGetMoreExtensionsUrl",
- base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam(
- GURL(extension_urls::GetExtensionGalleryURL())).spec()));
+ base::ASCIIToUTF16(
+ google_util::AppendGoogleLocaleParam(
+ GURL(extension_urls::GetExtensionGalleryURL()),
+ g_browser_process->GetApplicationLocale()).spec()));
source->AddString("extensionSettingsExtensionId",
l10n_util::GetStringUTF16(IDS_EXTENSIONS_ID));
source->AddString("extensionSettingsExtensionPath",
@@ -493,11 +499,15 @@ void ExtensionSettingsHandler::GetLocalizedValues(
source->AddString("extensionSettingsLearnMore",
l10n_util::GetStringUTF16(IDS_LEARN_MORE));
source->AddString("extensionSettingsCorruptInstallHelpUrl",
- base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam(
- GURL(chrome::kCorruptExtensionURL)).spec()));
+ base::ASCIIToUTF16(
+ google_util::AppendGoogleLocaleParam(
+ GURL(chrome::kCorruptExtensionURL),
+ g_browser_process->GetApplicationLocale()).spec()));
source->AddString("extensionSettingsSuspiciousInstallHelpUrl",
- base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam(
- GURL(chrome::kRemoveNonCWSExtensionURL)).spec()));
+ base::ASCIIToUTF16(
+ google_util::AppendGoogleLocaleParam(
+ GURL(chrome::kRemoveNonCWSExtensionURL),
+ g_browser_process->GetApplicationLocale()).spec()));
source->AddString("extensionSettingsShowButton",
l10n_util::GetStringUTF16(IDS_EXTENSIONS_SHOW_BUTTON));
source->AddString("extensionSettingsLoadUnpackedButton",
@@ -512,9 +522,11 @@ void ExtensionSettingsHandler::GetLocalizedValues(
"extensionSettingsAppsDevToolsPromoHTML",
l10n_util::GetStringFUTF16(
IDS_EXTENSIONS_APPS_DEV_TOOLS_PROMO_HTML,
- base::ASCIIToUTF16(google_util::AppendGoogleLocaleParam(
- GURL(extension_urls::GetWebstoreItemDetailURLPrefix() +
- kAppsDeveloperToolsExtensionId)).spec())));
+ base::ASCIIToUTF16(
+ google_util::AppendGoogleLocaleParam(
+ GURL(extension_urls::GetWebstoreItemDetailURLPrefix() +
+ kAppsDeveloperToolsExtensionId),
+ g_browser_process->GetApplicationLocale()).spec())));
source->AddString(
"extensionSettingsAppDevToolsPromoClose",
l10n_util::GetStringUTF16(IDS_CLOSE));
diff --git a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
index 23b25f1..c60e52b 100644
--- a/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
+++ b/chrome/browser/ui/webui/ntp/ntp_resource_cache.cc
@@ -310,7 +310,7 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() {
localized_strings.SetString("learnMore",
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(
prefs::kShowBookmarkBar);
@@ -356,7 +356,7 @@ void NTPResourceCache::CreateNewTabGuestHTML() {
localized_strings.SetString("enterpriseLearnMore",
l10n_util::GetStringUTF16(IDS_LEARN_MORE));
localized_strings.SetString("enterpriseInfoHintLink",
- GURL(chrome::kLearnMoreEnterpriseURL).spec());
+ chrome::kLearnMoreEnterpriseURL);
} else {
localized_strings.SetString("enterpriseInfoVisible", "false");
}
@@ -368,8 +368,7 @@ void NTPResourceCache::CreateNewTabGuestHTML() {
l10n_util::GetStringUTF16(guest_tab_heading_ids));
localized_strings.SetString("learnMore",
l10n_util::GetStringUTF16(guest_tab_link_ids));
- localized_strings.SetString("learnMoreLink",
- GURL(guest_tab_link).spec());
+ localized_strings.SetString("learnMoreLink", guest_tab_link);
webui::SetFontAndTextDirection(&localized_strings);
@@ -459,7 +458,8 @@ void NTPResourceCache::CreateNewTabHTML() {
l10n_util::GetStringUTF16(IDS_LEARN_MORE));
load_time_data.SetString("webStoreLink",
google_util::AppendGoogleLocaleParam(
- GURL(extension_urls::GetWebstoreLaunchURL())).spec());
+ GURL(extension_urls::GetWebstoreLaunchURL()),
+ g_browser_process->GetApplicationLocale()).spec());
load_time_data.SetString("appInstallHintText",
l10n_util::GetStringUTF16(IDS_NEW_TAB_APP_INSTALL_HINT_LABEL));
load_time_data.SetBoolean("isDiscoveryInNTPEnabled",
diff --git a/chrome/browser/ui/webui/sync_setup_handler.cc b/chrome/browser/ui/webui/sync_setup_handler.cc
index 346247d..7e71099 100644
--- a/chrome/browser/ui/webui/sync_setup_handler.cc
+++ b/chrome/browser/ui/webui/sync_setup_handler.cc
@@ -17,6 +17,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "chrome/app/chrome_command_ids.h"
+#include "chrome/browser/browser_process.h"
#include "chrome/browser/google/google_util.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/profiles/profile.h"
@@ -221,16 +222,21 @@ void SyncSetupHandler::GetStaticLocalizedValues(
GetStringFUTF16(IDS_SYNC_ENCRYPTION_SECTION_MESSAGE, product_name));
localized_strings->SetString(
"passphraseRecover",
- GetStringFUTF16(IDS_SYNC_PASSPHRASE_RECOVER,
- base::ASCIIToUTF16(
- google_util::StringAppendGoogleLocaleParam(
- chrome::kSyncGoogleDashboardURL))));
- localized_strings->SetString("stopSyncingExplanation",
+ GetStringFUTF16(
+ IDS_SYNC_PASSPHRASE_RECOVER,
+ base::ASCIIToUTF16(
+ google_util::AppendGoogleLocaleParam(
+ GURL(chrome::kSyncGoogleDashboardURL),
+ g_browser_process->GetApplicationLocale()).spec())));
+ localized_strings->SetString(
+ "stopSyncingExplanation",
l10n_util::GetStringFUTF16(
IDS_SYNC_STOP_SYNCING_EXPLANATION_LABEL,
l10n_util::GetStringUTF16(IDS_PRODUCT_NAME),
- base::ASCIIToUTF16(google_util::StringAppendGoogleLocaleParam(
- chrome::kSyncGoogleDashboardURL))));
+ base::ASCIIToUTF16(
+ google_util::AppendGoogleLocaleParam(
+ GURL(chrome::kSyncGoogleDashboardURL),
+ g_browser_process->GetApplicationLocale()).spec())));
localized_strings->SetString("deleteProfileLabel",
l10n_util::GetStringUTF16(IDS_SYNC_STOP_DELETE_PROFILE_LABEL));
localized_strings->SetString("stopSyncingTitle",
diff --git a/chrome/browser/web_resource/web_resource_service.cc b/chrome/browser/web_resource/web_resource_service.cc
index 646dd6c..7a3ae62 100644
--- a/chrome/browser/web_resource/web_resource_service.cc
+++ b/chrome/browser/web_resource/web_resource_service.cc
@@ -119,9 +119,11 @@ void WebResourceService::StartFetch() {
// Balanced in OnURLFetchComplete.
AddRef();
- GURL web_resource_server = apply_locale_to_url_ ?
- google_util::AppendGoogleLocaleParam(web_resource_server_) :
- web_resource_server_;
+ GURL web_resource_server =
+ apply_locale_to_url_
+ ? google_util::AppendGoogleLocaleParam(
+ web_resource_server_, g_browser_process->GetApplicationLocale())
+ : web_resource_server_;
DVLOG(1) << "WebResourceService StartFetch " << web_resource_server;
url_fetcher_.reset(net::URLFetcher::Create(