From 043e72f70ae61f1a62aefef6d137c4916206d3c9 Mon Sep 17 00:00:00 2001 From: Victoria Lease Date: Wed, 14 Mar 2012 14:43:06 -0700 Subject: fix hl parameter for incognito search Bug: 5777487 Change-Id: I34ea2e3aac0659cb5fe29732b30a117a289a4b72 --- .../android/browser/search/SearchEngineInfo.java | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/com/android/browser/search/SearchEngineInfo.java b/src/com/android/browser/search/SearchEngineInfo.java index ec304f6..0c11a04 100644 --- a/src/com/android/browser/search/SearchEngineInfo.java +++ b/src/com/android/browser/search/SearchEngineInfo.java @@ -83,13 +83,15 @@ public class SearchEngineInfo { // Add the current language/country information to the URIs. Locale locale = context.getResources().getConfiguration().locale; - StringBuilder language = new StringBuilder(locale.getLanguage()); - if (!TextUtils.isEmpty(locale.getCountry())) { - language.append('-'); - language.append(locale.getCountry()); + String language = locale.getLanguage(); + StringBuilder languageBuilder = new StringBuilder(language); + String country = locale.getCountry(); + if (!TextUtils.isEmpty(country) && useLangCountryHl(language, country)) { + languageBuilder.append('-'); + languageBuilder.append(country); } - String language_str = language.toString(); + String language_str = languageBuilder.toString(); mSearchEngineData[FIELD_SEARCH_URI] = mSearchEngineData[FIELD_SEARCH_URI].replace(PARAMETER_LANGUAGE, language_str); mSearchEngineData[FIELD_SUGGEST_URI] = @@ -109,6 +111,19 @@ public class SearchEngineInfo { mSearchEngineData[FIELD_SUGGEST_URI].replace(PARAMETER_INPUT_ENCODING, enc); } + private static boolean useLangCountryHl(String language, String country) { + // lang-country is currently only supported for a small number of locales + if("en".equals(language)) { + return "GB".equals(country); + } else if ("zh".equals(language)) { + return "CN".equals(country) || "TW".equals(country); + } else if ("pt".equals(language)) { + return "BR".equals(country) || "PT".equals(country); + } else { + return false; + } + } + public String getName() { return mName; } -- cgit v1.1