| 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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 !pref->GetBoolean(prefs::kSpellCheckUseSpellingService) || | 113 !pref->GetBoolean(prefs::kSpellCheckUseSpellingService) || |
| 114 context->IsOffTheRecord()) | 114 context->IsOffTheRecord()) |
| 115 return false; | 115 return false; |
| 116 | 116 |
| 117 // If the locale for spelling has not been set, the user has not decided to | 117 // If the locale for spelling has not been set, the user has not decided to |
| 118 // use spellcheck so we don't do anything remote (suggest or spelling). | 118 // use spellcheck so we don't do anything remote (suggest or spelling). |
| 119 std::string locale = pref->GetString(prefs::kSpellCheckDictionary); | 119 std::string locale = pref->GetString(prefs::kSpellCheckDictionary); |
| 120 if (locale.empty()) | 120 if (locale.empty()) |
| 121 return false; | 121 return false; |
| 122 | 122 |
| 123 // If we do not have the spelling service enabled, then we are only available | |
| 124 // for SUGGEST. | |
| 125 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 126 if (command_line->HasSwitch(switches::kUseSpellingSuggestions)) | |
| 127 return type == SUGGEST; | |
| 128 | |
| 129 // Finally, if all options are available, we only enable only SUGGEST | 123 // Finally, if all options are available, we only enable only SUGGEST |
| 130 // if SPELLCHECK is not available for our language because SPELLCHECK results | 124 // if SPELLCHECK is not available for our language because SPELLCHECK results |
| 131 // are a superset of SUGGEST results. | 125 // are a superset of SUGGEST results. |
| 132 // TODO(rlp): Only available for English right now. Fix this line to include | 126 // TODO(rlp): Only available for English right now. Fix this line to include |
| 133 // all languages SPELLCHECK covers. | 127 // all languages SPELLCHECK covers. |
| 134 bool language_available = !locale.compare(0, 2, "en"); | 128 bool language_available = !locale.compare(0, 2, "en"); |
| 135 if (language_available) { | 129 if (language_available) { |
| 136 return type == SPELLCHECK; | 130 return type == SPELLCHECK; |
| 137 } else { | 131 } else { |
| 138 // Only SUGGEST is allowed. | 132 // Only SUGGEST is allowed. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 spellcheck_fetchers_.erase(fetcher.get()); | 251 spellcheck_fetchers_.erase(fetcher.get()); |
| 258 | 252 |
| 259 // The callback may release the last (transitive) dependency on |this|. It | 253 // The callback may release the last (transitive) dependency on |this|. It |
| 260 // MUST be the last function called. | 254 // MUST be the last function called. |
| 261 callback_data->callback.Run(success, callback_data->text, results); | 255 callback_data->callback.Run(success, callback_data->text, results); |
| 262 } | 256 } |
| 263 | 257 |
| 264 net::URLFetcher* SpellingServiceClient::CreateURLFetcher(const GURL& url) { | 258 net::URLFetcher* SpellingServiceClient::CreateURLFetcher(const GURL& url) { |
| 265 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); | 259 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); |
| 266 } | 260 } |
| OLD | NEW |