Chromium Code Reviews| 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/spellcheck_service.h" | 5 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_member.h" | 8 #include "base/prefs/pref_member.h" |
| 9 #include "base/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 | 41 |
| 42 SpellcheckService::SpellcheckService(content::BrowserContext* context) | 42 SpellcheckService::SpellcheckService(content::BrowserContext* context) |
| 43 : context_(context), | 43 : context_(context), |
| 44 weak_ptr_factory_(this) { | 44 weak_ptr_factory_(this) { |
| 45 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 45 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 46 PrefService* prefs = user_prefs::UserPrefs::Get(context); | 46 PrefService* prefs = user_prefs::UserPrefs::Get(context); |
| 47 pref_change_registrar_.Init(prefs); | 47 pref_change_registrar_.Init(prefs); |
| 48 StringListPrefMember dictionaries_pref; | 48 StringListPrefMember dictionaries_pref; |
| 49 dictionaries_pref.Init(prefs::kSpellCheckDictionaries, prefs); | 49 dictionaries_pref.Init(prefs::kSpellCheckDictionaries, prefs); |
| 50 std::string first_of_dictionaries; | 50 std::string first_of_dictionaries; |
| 51 | |
| 52 #if defined(USE_BROWSER_SPELLCHECKER) | |
| 53 dictionaries_pref.SetValue(std::vector<std::string>( | |
| 54 1, spellcheck_platform::GetSpellCheckerLanguage())); | |
| 55 first_of_dictionaries = dictionaries_pref.GetValue().front(); | |
|
groby-ooo-7-16
2016/01/26 01:30:10
Can you add a short explanation what either code s
please use gerrit instead
2016/01/26 20:54:34
Done.
| |
| 56 #else | |
| 51 if (!dictionaries_pref.GetValue().empty()) | 57 if (!dictionaries_pref.GetValue().empty()) |
| 52 first_of_dictionaries = dictionaries_pref.GetValue().front(); | 58 first_of_dictionaries = dictionaries_pref.GetValue().front(); |
| 53 | 59 |
| 54 // For preference migration, set the new preference kSpellCheckDictionaries | 60 // For preference migration, set the new preference kSpellCheckDictionaries |
| 55 // to be the same as the old kSpellCheckDictionary. | 61 // to be the same as the old kSpellCheckDictionary. |
| 56 StringPrefMember single_dictionary_pref; | 62 StringPrefMember single_dictionary_pref; |
| 57 single_dictionary_pref.Init(prefs::kSpellCheckDictionary, prefs); | 63 single_dictionary_pref.Init(prefs::kSpellCheckDictionary, prefs); |
| 58 std::string single_dictionary = single_dictionary_pref.GetValue(); | 64 std::string single_dictionary = single_dictionary_pref.GetValue(); |
| 59 | 65 |
| 60 if (first_of_dictionaries.empty() && !single_dictionary.empty()) { | 66 if (first_of_dictionaries.empty() && !single_dictionary.empty()) { |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 73 prefs->SetBoolean(prefs::kEnableContinuousSpellcheck, true); | 79 prefs->SetBoolean(prefs::kEnableContinuousSpellcheck, true); |
| 74 } | 80 } |
| 75 | 81 |
| 76 // If a user goes back to single language spellchecking make sure there is | 82 // If a user goes back to single language spellchecking make sure there is |
| 77 // only one language in the dictionaries preference. | 83 // only one language in the dictionaries preference. |
| 78 if (!chrome::spellcheck_common::IsMultilingualSpellcheckEnabled() && | 84 if (!chrome::spellcheck_common::IsMultilingualSpellcheckEnabled() && |
| 79 dictionaries_pref.GetValue().size() > 1) { | 85 dictionaries_pref.GetValue().size() > 1) { |
| 80 dictionaries_pref.SetValue( | 86 dictionaries_pref.SetValue( |
| 81 std::vector<std::string>(1, first_of_dictionaries)); | 87 std::vector<std::string>(1, first_of_dictionaries)); |
| 82 } | 88 } |
| 89 #endif // defined(USE_BROWSER_SPELLCHECKER) | |
| 83 | 90 |
| 84 std::string language_code; | 91 std::string language_code; |
| 85 std::string country_code; | 92 std::string country_code; |
| 86 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( | 93 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( |
| 87 first_of_dictionaries, | 94 first_of_dictionaries, |
| 88 &language_code, | 95 &language_code, |
| 89 &country_code); | 96 &country_code); |
| 90 feedback_sender_.reset(new spellcheck::FeedbackSender( | 97 feedback_sender_.reset(new spellcheck::FeedbackSender( |
| 91 context->GetRequestContext(), language_code, country_code)); | 98 context->GetRequestContext(), language_code, country_code)); |
| 92 | 99 |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 } | 342 } |
| 336 | 343 |
| 337 void SpellcheckService::UpdateFeedbackSenderState() { | 344 void SpellcheckService::UpdateFeedbackSenderState() { |
| 338 if (SpellingServiceClient::IsAvailable( | 345 if (SpellingServiceClient::IsAvailable( |
| 339 context_, SpellingServiceClient::SPELLCHECK)) { | 346 context_, SpellingServiceClient::SPELLCHECK)) { |
| 340 feedback_sender_->StartFeedbackCollection(); | 347 feedback_sender_->StartFeedbackCollection(); |
| 341 } else { | 348 } else { |
| 342 feedback_sender_->StopFeedbackCollection(); | 349 feedback_sender_->StopFeedbackCollection(); |
| 343 } | 350 } |
| 344 } | 351 } |
| OLD | NEW |