diff options
author | rouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 05:19:35 +0000 |
---|---|---|
committer | rouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-05-14 05:19:35 +0000 |
commit | 028fa84323015a2a25b9599c0146da20a96782c3 (patch) | |
tree | 7c5a49cc91ef2e90122be3ab20283cc24bf8000c /chrome/browser/spellchecker/spelling_service_client.cc | |
parent | 2c5a747e4176dc01961090cef09401d7146785b9 (diff) | |
download | chromium_src-028fa84323015a2a25b9599c0146da20a96782c3.zip chromium_src-028fa84323015a2a25b9599c0146da20a96782c3.tar.gz chromium_src-028fa84323015a2a25b9599c0146da20a96782c3.tar.bz2 |
Move GetISOLanguageCountryCodeFromLocale() to common to be shared
This CL moves GetISOLanguageCountryCodeFromLocale() to spellheck_common to be
shared among spelling service client and spellcheck service.
BUG=170514
Review URL: https://chromiumcodereview.appspot.com/14876027
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@199913 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/spellchecker/spelling_service_client.cc')
-rw-r--r-- | chrome/browser/spellchecker/spelling_service_client.cc | 28 |
1 files changed, 2 insertions, 26 deletions
diff --git a/chrome/browser/spellchecker/spelling_service_client.cc b/chrome/browser/spellchecker/spelling_service_client.cc index 5b120ca..9eeeb1b 100644 --- a/chrome/browser/spellchecker/spelling_service_client.cc +++ b/chrome/browser/spellchecker/spelling_service_client.cc @@ -17,41 +17,17 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/common/chrome_switches.h" #include "chrome/common/pref_names.h" +#include "chrome/common/spellcheck_common.h" #include "chrome/common/spellcheck_result.h" #include "google_apis/google_api_keys.h" #include "net/base/load_flags.h" #include "net/url_request/url_fetcher.h" -#include "third_party/icu/public/common/unicode/uloc.h" namespace { // The URL for requesting spell checking and sending user feedback. const char kSpellingServiceURL[] = "https://www.googleapis.com/rpc"; -// Gets the ISO codes for the language and country of this |locale|. The -// |locale| is an ISO locale ID that may not include a country ID, e.g., "fr" or -// "de". This method converts the UI locale to a full locale ID and converts the -// full locale ID to an ISO language code and an ISO3 country code. -void GetISOLanguageCountryCodeFromLocale( - const std::string& locale, - std::string* language_code, - std::string* country_code) { - DCHECK(language_code); - DCHECK(country_code); - char language[ULOC_LANG_CAPACITY] = ULOC_ENGLISH; - const char* country = "USA"; - if (!locale.empty()) { - UErrorCode error = U_ZERO_ERROR; - char id[ULOC_LANG_CAPACITY + ULOC_SCRIPT_CAPACITY + ULOC_COUNTRY_CAPACITY]; - uloc_addLikelySubtags(locale.c_str(), id, arraysize(id), &error); - error = U_ZERO_ERROR; - uloc_getLanguage(id, language, arraysize(language), &error); - country = uloc_getISO3Country(id); - } - *language_code = std::string(language); - *country_code = std::string(country); -} - } // namespace SpellingServiceClient::SpellingServiceClient() { @@ -75,7 +51,7 @@ bool SpellingServiceClient::RequestTextCheck( std::string language_code; std::string country_code; - GetISOLanguageCountryCodeFromLocale( + chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( profile->GetPrefs()->GetString(prefs::kSpellCheckDictionary), &language_code, &country_code); |