diff options
author | Victoria Lease <violets@google.com> | 2012-03-14 14:43:06 -0700 |
---|---|---|
committer | Victoria Lease <violets@google.com> | 2012-03-14 15:05:32 -0700 |
commit | 043e72f70ae61f1a62aefef6d137c4916206d3c9 (patch) | |
tree | 173a989036144de4a7d5f285545175188d19f937 /src | |
parent | b901986739155a423884055f0f8c8511a097194b (diff) | |
download | packages_apps_Browser-043e72f70ae61f1a62aefef6d137c4916206d3c9.zip packages_apps_Browser-043e72f70ae61f1a62aefef6d137c4916206d3c9.tar.gz packages_apps_Browser-043e72f70ae61f1a62aefef6d137c4916206d3c9.tar.bz2 |
fix hl parameter for incognito search
Bug: 5777487
Change-Id: I34ea2e3aac0659cb5fe29732b30a117a289a4b72
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/browser/search/SearchEngineInfo.java | 25 |
1 files changed, 20 insertions, 5 deletions
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; } |