| 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 <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 base::Bind(&SpellcheckService::OnSpellCheckDictionariesChanged, | 96 base::Bind(&SpellcheckService::OnSpellCheckDictionariesChanged, |
| 97 base::Unretained(this))); | 97 base::Unretained(this))); |
| 98 pref_change_registrar_.Add( | 98 pref_change_registrar_.Add( |
| 99 spellcheck::prefs::kSpellCheckUseSpellingService, | 99 spellcheck::prefs::kSpellCheckUseSpellingService, |
| 100 base::Bind(&SpellcheckService::OnUseSpellingServiceChanged, | 100 base::Bind(&SpellcheckService::OnUseSpellingServiceChanged, |
| 101 base::Unretained(this))); | 101 base::Unretained(this))); |
| 102 pref_change_registrar_.Add( | 102 pref_change_registrar_.Add( |
| 103 prefs::kAcceptLanguages, | 103 prefs::kAcceptLanguages, |
| 104 base::Bind(&SpellcheckService::OnAcceptLanguagesChanged, | 104 base::Bind(&SpellcheckService::OnAcceptLanguagesChanged, |
| 105 base::Unretained(this))); | 105 base::Unretained(this))); |
| 106 pref_change_registrar_.Add(spellcheck::prefs::kEnableContinuousSpellcheck, | 106 pref_change_registrar_.Add(spellcheck::prefs::kEnableSpellcheck, |
| 107 base::Bind(&SpellcheckService::InitForAllRenderers, | 107 base::Bind(&SpellcheckService::InitForAllRenderers, |
| 108 base::Unretained(this))); | 108 base::Unretained(this))); |
| 109 | 109 |
| 110 custom_dictionary_.reset(new SpellcheckCustomDictionary(context_->GetPath())); | 110 custom_dictionary_.reset(new SpellcheckCustomDictionary(context_->GetPath())); |
| 111 custom_dictionary_->AddObserver(this); | 111 custom_dictionary_->AddObserver(this); |
| 112 custom_dictionary_->Load(); | 112 custom_dictionary_->Load(); |
| 113 | 113 |
| 114 registrar_.Add(this, | 114 registrar_.Add(this, |
| 115 content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 115 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
| 116 content::NotificationService::AllSources()); | 116 content::NotificationService::AllSources()); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 bdict_languages.back().language = hunspell_dictionary->GetLanguage(); | 192 bdict_languages.back().language = hunspell_dictionary->GetLanguage(); |
| 193 bdict_languages.back().file = | 193 bdict_languages.back().file = |
| 194 hunspell_dictionary->GetDictionaryFile().IsValid() | 194 hunspell_dictionary->GetDictionaryFile().IsValid() |
| 195 ? IPC::GetPlatformFileForTransit( | 195 ? IPC::GetPlatformFileForTransit( |
| 196 hunspell_dictionary->GetDictionaryFile().GetPlatformFile(), | 196 hunspell_dictionary->GetDictionaryFile().GetPlatformFile(), |
| 197 false) | 197 false) |
| 198 : IPC::InvalidPlatformFileForTransit(); | 198 : IPC::InvalidPlatformFileForTransit(); |
| 199 } | 199 } |
| 200 | 200 |
| 201 bool enabled = | 201 bool enabled = |
| 202 prefs->GetBoolean(spellcheck::prefs::kEnableContinuousSpellcheck) && | 202 prefs->GetBoolean(spellcheck::prefs::kEnableSpellcheck) && |
| 203 !bdict_languages.empty(); | 203 !bdict_languages.empty(); |
| 204 process->Send(new SpellCheckMsg_Init( | 204 process->Send(new SpellCheckMsg_Init( |
| 205 bdict_languages, | 205 bdict_languages, |
| 206 enabled ? custom_dictionary_->GetWords() : std::set<std::string>())); | 206 enabled ? custom_dictionary_->GetWords() : std::set<std::string>())); |
| 207 process->Send(new SpellCheckMsg_EnableSpellCheck(enabled)); | 207 process->Send(new SpellCheckMsg_EnableSpellCheck(enabled)); |
| 208 } | 208 } |
| 209 | 209 |
| 210 SpellCheckHostMetrics* SpellcheckService::GetMetrics() const { | 210 SpellCheckHostMetrics* SpellcheckService::GetMetrics() const { |
| 211 return metrics_.get(); | 211 return metrics_.get(); |
| 212 } | 212 } |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 374 spellcheck::GetISOLanguageCountryCodeFromLocale( | 374 spellcheck::GetISOLanguageCountryCodeFromLocale( |
| 375 feedback_language, &language_code, &country_code); | 375 feedback_language, &language_code, &country_code); |
| 376 feedback_sender_->OnLanguageCountryChange(language_code, country_code); | 376 feedback_sender_->OnLanguageCountryChange(language_code, country_code); |
| 377 if (SpellingServiceClient::IsAvailable( | 377 if (SpellingServiceClient::IsAvailable( |
| 378 context_, SpellingServiceClient::SPELLCHECK)) { | 378 context_, SpellingServiceClient::SPELLCHECK)) { |
| 379 feedback_sender_->StartFeedbackCollection(); | 379 feedback_sender_->StartFeedbackCollection(); |
| 380 } else { | 380 } else { |
| 381 feedback_sender_->StopFeedbackCollection(); | 381 feedback_sender_->StopFeedbackCollection(); |
| 382 } | 382 } |
| 383 } | 383 } |
| OLD | NEW |