| 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 "components/spellcheck/browser/spelling_service_client.h" | 5 #include "components/spellcheck/browser/spelling_service_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 bool SpellingServiceClient::IsAvailable(content::BrowserContext* context, | 120 bool SpellingServiceClient::IsAvailable(content::BrowserContext* context, |
| 121 ServiceType type) { | 121 ServiceType type) { |
| 122 const PrefService* pref = user_prefs::UserPrefs::Get(context); | 122 const PrefService* pref = user_prefs::UserPrefs::Get(context); |
| 123 DCHECK(pref); | 123 DCHECK(pref); |
| 124 // If prefs don't allow spellchecking, if the context is off the record, or if | 124 // If prefs don't allow spellchecking, if the context is off the record, or if |
| 125 // multilingual spellchecking is enabled the spelling service should be | 125 // multilingual spellchecking is enabled the spelling service should be |
| 126 // unavailable. | 126 // unavailable. |
| 127 if (!pref->GetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck) || | 127 if (!pref->GetBoolean(spellcheck::prefs::kEnableSpellcheck) || |
| 128 !pref->GetBoolean(spellcheck::prefs::kSpellCheckUseSpellingService) || | 128 !pref->GetBoolean(spellcheck::prefs::kSpellCheckUseSpellingService) || |
| 129 context->IsOffTheRecord()) | 129 context->IsOffTheRecord()) |
| 130 return false; | 130 return false; |
| 131 | 131 |
| 132 // If the locale for spelling has not been set, the user has not decided to | 132 // If the locale for spelling has not been set, the user has not decided to |
| 133 // use spellcheck so we don't do anything remote (suggest or spelling). | 133 // use spellcheck so we don't do anything remote (suggest or spelling). |
| 134 std::string locale; | 134 std::string locale; |
| 135 pref->GetList(spellcheck::prefs::kSpellCheckDictionaries) | 135 pref->GetList(spellcheck::prefs::kSpellCheckDictionaries) |
| 136 ->GetString(0, &locale); | 136 ->GetString(0, &locale); |
| 137 if (locale.empty()) | 137 if (locale.empty()) |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 | 265 |
| 266 // The callback may release the last (transitive) dependency on |this|. It | 266 // The callback may release the last (transitive) dependency on |this|. It |
| 267 // MUST be the last function called. | 267 // MUST be the last function called. |
| 268 callback_data->callback.Run(success, callback_data->text, results); | 268 callback_data->callback.Run(success, callback_data->text, results); |
| 269 } | 269 } |
| 270 | 270 |
| 271 std::unique_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( | 271 std::unique_ptr<net::URLFetcher> SpellingServiceClient::CreateURLFetcher( |
| 272 const GURL& url) { | 272 const GURL& url) { |
| 273 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); | 273 return net::URLFetcher::Create(url, net::URLFetcher::POST, this); |
| 274 } | 274 } |
| OLD | NEW |