Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3031)

Unified Diff: chrome/browser/spellchecker/spelling_service_client.cc

Issue 10536141: Add SpellingServiceClient::IsAvailable(). (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/spellchecker/spelling_service_client.cc
===================================================================
--- chrome/browser/spellchecker/spelling_service_client.cc (revision 142020)
+++ chrome/browser/spellchecker/spelling_service_client.cc (working copy)
@@ -72,7 +72,7 @@
uloc_getLanguage(id, language, arraysize(language), &error);
country = uloc_getISO3Country(id);
}
- if (type == SPELLCHECK && base::strcasecmp(language, ULOC_ENGLISH))
+ if (!IsAvailable(profile, SPELLCHECK))
return false;
// Format the JSON request to be sent to the Spelling service.
@@ -112,6 +112,22 @@
return true;
}
+bool SpellingServiceClient::IsAvailable(Profile* profile, ServiceType type) {
+ const PrefService* pref = profile->GetPrefs();
+ if (!pref->GetBoolean(prefs::kEnableSpellCheck) ||
+ !pref->GetBoolean(prefs::kSpellCheckUseSpellingService))
+ return false;
+
+ // Enable the suggest service only on languages not supported by the
+ // spellcheck service. When this client calls the spellcheck service, it
+ // returns not only spellcheck results but also spelling suggestions provided
+ // by the suggest service. That is, it is not useful to use the suggest
+ // service when this client can use the spellcheck service.
+ std::string locale = pref->GetString(prefs::kSpellCheckDictionary);
+ bool spellcheck_available = locale.empty() || !locale.compare(0, 2, "en");
+ return type == SUGGEST ? !spellcheck_available : spellcheck_available;
+}
+
void SpellingServiceClient::OnURLFetchComplete(
const net::URLFetcher* source) {
scoped_ptr<net::URLFetcher> clean_up_fetcher(fetcher_.release());
« no previous file with comments | « chrome/browser/spellchecker/spelling_service_client.h ('k') | chrome/browser/spellchecker/spelling_service_client_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698