OLD | NEW |
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/command_line.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/string_escape.h" | 9 #include "base/json/string_escape.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 108 |
109 // If the locale for spelling has not been set, the user has not decided to | 109 // If the locale for spelling has not been set, the user has not decided to |
110 // use spellcheck so we don't do anything remote (suggest or spelling). | 110 // use spellcheck so we don't do anything remote (suggest or spelling). |
111 std::string locale = pref->GetString(prefs::kSpellCheckDictionary); | 111 std::string locale = pref->GetString(prefs::kSpellCheckDictionary); |
112 if (locale.empty()) | 112 if (locale.empty()) |
113 return false; | 113 return false; |
114 | 114 |
115 // If we do not have the spelling service enabled, then we are only available | 115 // If we do not have the spelling service enabled, then we are only available |
116 // for SUGGEST. | 116 // for SUGGEST. |
117 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 117 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
118 if (!command_line->HasSwitch(switches::kUseSpellingService)) | 118 if (command_line->HasSwitch(switches::kUseSpellingSuggestions)) |
119 return type == SUGGEST; | 119 return type == SUGGEST; |
120 | 120 |
121 // Finally, if all options are available, we only enable only SUGGEST | 121 // Finally, if all options are available, we only enable only SUGGEST |
122 // if SPELLCHECK is not available for our language because SPELLCHECK results | 122 // if SPELLCHECK is not available for our language because SPELLCHECK results |
123 // are a superset of SUGGEST results. | 123 // are a superset of SUGGEST results. |
124 // TODO(rlp): Only available for English right now. Fix this line to include | 124 // TODO(rlp): Only available for English right now. Fix this line to include |
125 // all languages SPELLCHECK covers. | 125 // all languages SPELLCHECK covers. |
126 bool language_available = !locale.compare(0, 2, "en"); | 126 bool language_available = !locale.compare(0, 2, "en"); |
127 if (language_available) { | 127 if (language_available) { |
128 // Either SUGGEST or SPELLCHECK are allowed. | 128 // Either SUGGEST or SPELLCHECK are allowed. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 if (!suggestions->GetDictionary(0, &suggestion) || | 220 if (!suggestions->GetDictionary(0, &suggestion) || |
221 !suggestion->GetString("suggestion", &replacement)) { | 221 !suggestion->GetString("suggestion", &replacement)) { |
222 return false; | 222 return false; |
223 } | 223 } |
224 SpellCheckResult result( | 224 SpellCheckResult result( |
225 SpellCheckResult::SPELLING, start, length, replacement); | 225 SpellCheckResult::SPELLING, start, length, replacement); |
226 results->push_back(result); | 226 results->push_back(result); |
227 } | 227 } |
228 return true; | 228 return true; |
229 } | 229 } |
OLD | NEW |