summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/spellchecker/spelling_service_client.cc28
-rw-r--r--chrome/common/spellcheck_common.cc21
-rw-r--r--chrome/common/spellcheck_common.h8
3 files changed, 31 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);
diff --git a/chrome/common/spellcheck_common.cc b/chrome/common/spellcheck_common.cc
index 0f0282e..601a38e 100644
--- a/chrome/common/spellcheck_common.cc
+++ b/chrome/common/spellcheck_common.cc
@@ -5,6 +5,8 @@
#include "chrome/common/spellcheck_common.h"
#include "base/files/file_path.h"
+#include "base/logging.h"
+#include "third_party/icu/public/common/unicode/uloc.h"
namespace chrome {
namespace spellcheck_common {
@@ -147,5 +149,24 @@ void SpellCheckLanguages(std::vector<std::string>* languages) {
}
}
+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 spellcheck_common
} // namespace chrome
diff --git a/chrome/common/spellcheck_common.h b/chrome/common/spellcheck_common.h
index 607ef64..1bed570 100644
--- a/chrome/common/spellcheck_common.h
+++ b/chrome/common/spellcheck_common.h
@@ -41,6 +41,14 @@ std::string GetCorrespondingSpellCheckLanguage(const std::string& language);
// Get SpellChecker supported languages.
void SpellCheckLanguages(std::vector<std::string>* languages);
+// 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);
+
} // namespace spellcheck_common
} // namespace chrome