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

Side by Side Diff: chrome/browser/spellchecker/spelling_service_client.cc

Issue 10753023: Disable the spellcheck service when asynchronous spellchecking is disabled. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/spellchecker/spelling_service_client.h" 5 #include "chrome/browser/spellchecker/spelling_service_client.h"
6 6
7 #include "base/command_line.h"
7 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
8 #include "base/json/string_escape.h" 9 #include "base/json/string_escape.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/string_util.h" 11 #include "base/string_util.h"
11 #include "base/stringprintf.h" 12 #include "base/stringprintf.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "chrome/browser/prefs/pref_service.h" 15 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 16 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/common/chrome_switches.h"
16 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
17 #include "chrome/common/spellcheck_result.h" 19 #include "chrome/common/spellcheck_result.h"
18 #include "content/public/browser/browser_thread.h" 20 #include "content/public/browser/browser_thread.h"
19 #include "net/base/load_flags.h" 21 #include "net/base/load_flags.h"
20 #include "net/url_request/url_fetcher.h" 22 #include "net/url_request/url_fetcher.h"
21 #include "unicode/uloc.h" 23 #include "unicode/uloc.h"
22 24
23 #if defined(GOOGLE_CHROME_BUILD) 25 #if defined(GOOGLE_CHROME_BUILD)
24 #include "chrome/browser/spellchecker/internal/spellcheck_internal.h" 26 #include "chrome/browser/spellchecker/internal/spellcheck_internal.h"
25 #endif 27 #endif
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 callback_ = callback; 113 callback_ = callback;
112 return true; 114 return true;
113 } 115 }
114 116
115 bool SpellingServiceClient::IsAvailable(Profile* profile, ServiceType type) { 117 bool SpellingServiceClient::IsAvailable(Profile* profile, ServiceType type) {
116 const PrefService* pref = profile->GetPrefs(); 118 const PrefService* pref = profile->GetPrefs();
117 if (!pref->GetBoolean(prefs::kEnableSpellCheck) || 119 if (!pref->GetBoolean(prefs::kEnableSpellCheck) ||
118 !pref->GetBoolean(prefs::kSpellCheckUseSpellingService)) 120 !pref->GetBoolean(prefs::kSpellCheckUseSpellingService))
119 return false; 121 return false;
120 122
123 // The spellchecking service should be avilable only when asynchronous
124 // spellchecking is enabled because this service depends on it.
125 const CommandLine* command_line = CommandLine::ForCurrentProcess();
126 if (command_line->HasSwitch(switches::kDisableAsynchronousSpellChecking))
127 return type == SUGGEST;
128
121 // Enable the suggest service only on languages not supported by the 129 // Enable the suggest service only on languages not supported by the
122 // spellcheck service. When this client calls the spellcheck service, it 130 // spellcheck service. When this client calls the spellcheck service, it
123 // returns not only spellcheck results but also spelling suggestions provided 131 // returns not only spellcheck results but also spelling suggestions provided
124 // by the suggest service. That is, it is not useful to use the suggest 132 // by the suggest service. That is, it is not useful to use the suggest
125 // service when this client can use the spellcheck service. 133 // service when this client can use the spellcheck service.
126 std::string locale = pref->GetString(prefs::kSpellCheckDictionary); 134 std::string locale = pref->GetString(prefs::kSpellCheckDictionary);
127 #if defined(OS_MACOSX) 135 #if defined(OS_MACOSX)
128 bool spellcheck_available = locale.empty(); 136 bool spellcheck_available = locale.empty();
129 #else 137 #else
130 bool spellcheck_available = locale.empty() || !locale.compare(0, 2, "en"); 138 bool spellcheck_available = locale.empty() || !locale.compare(0, 2, "en");
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 if (!suggestions->GetDictionary(0, &suggestion) || 227 if (!suggestions->GetDictionary(0, &suggestion) ||
220 !suggestion->GetString("suggestion", &replacement)) { 228 !suggestion->GetString("suggestion", &replacement)) {
221 return false; 229 return false;
222 } 230 }
223 SpellCheckResult result( 231 SpellCheckResult result(
224 SpellCheckResult::SPELLING, start, length, replacement); 232 SpellCheckResult::SPELLING, start, length, replacement);
225 results->push_back(result); 233 results->push_back(result);
226 } 234 }
227 return true; 235 return true;
228 } 236 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698