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/platform_file.h" | 7 #include "base/platform_file.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" |
11 #include "base/synchronization/waitable_event.h" | 11 #include "base/synchronization/waitable_event.h" |
12 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 12 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
13 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" | 13 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" |
14 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" | 14 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" |
15 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" | 15 #include "chrome/browser/spellchecker/spellcheck_platform_mac.h" |
| 16 #include "chrome/browser/spellchecker/spelling_service_client.h" |
16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
17 #include "chrome/common/spellcheck_messages.h" | 18 #include "chrome/common/spellcheck_messages.h" |
18 #include "components/user_prefs/user_prefs.h" | 19 #include "components/user_prefs/user_prefs.h" |
19 #include "content/public/browser/browser_context.h" | 20 #include "content/public/browser/browser_context.h" |
20 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
21 #include "content/public/browser/notification_service.h" | 22 #include "content/public/browser/notification_service.h" |
22 #include "content/public/browser/notification_types.h" | 23 #include "content/public/browser/notification_types.h" |
23 #include "content/public/browser/render_process_host.h" | 24 #include "content/public/browser/render_process_host.h" |
24 #include "ipc/ipc_platform_file.h" | 25 #include "ipc/ipc_platform_file.h" |
25 | 26 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 prefs->GetString(prefs::kSpellCheckDictionary); | 301 prefs->GetString(prefs::kSpellCheckDictionary); |
301 hunspell_dictionary_.reset(new SpellcheckHunspellDictionary( | 302 hunspell_dictionary_.reset(new SpellcheckHunspellDictionary( |
302 dictionary, context_->GetRequestContext(), this)); | 303 dictionary, context_->GetRequestContext(), this)); |
303 hunspell_dictionary_->AddObserver(this); | 304 hunspell_dictionary_->AddObserver(this); |
304 hunspell_dictionary_->Load(); | 305 hunspell_dictionary_->Load(); |
305 std::string language_code; | 306 std::string language_code; |
306 std::string country_code; | 307 std::string country_code; |
307 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( | 308 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( |
308 dictionary, &language_code, &country_code); | 309 dictionary, &language_code, &country_code); |
309 feedback_sender_->OnLanguageCountryChange(language_code, country_code); | 310 feedback_sender_->OnLanguageCountryChange(language_code, country_code); |
| 311 UpdateFeedbackSenderState(); |
310 } | 312 } |
311 | 313 |
312 void SpellcheckService::OnUseSpellingServiceChanged() { | 314 void SpellcheckService::OnUseSpellingServiceChanged() { |
313 bool enabled = pref_change_registrar_.prefs()->GetBoolean( | 315 bool enabled = pref_change_registrar_.prefs()->GetBoolean( |
314 prefs::kSpellCheckUseSpellingService); | 316 prefs::kSpellCheckUseSpellingService); |
315 if (metrics_) | 317 if (metrics_) |
316 metrics_->RecordSpellingServiceStats(enabled); | 318 metrics_->RecordSpellingServiceStats(enabled); |
| 319 UpdateFeedbackSenderState(); |
317 } | 320 } |
| 321 |
| 322 void SpellcheckService::UpdateFeedbackSenderState() { |
| 323 if (SpellingServiceClient::IsAvailable( |
| 324 context_, SpellingServiceClient::SPELLCHECK)) { |
| 325 feedback_sender_->StartFeedbackCollection(); |
| 326 } else { |
| 327 feedback_sender_->StopFeedbackCollection(); |
| 328 } |
| 329 } |
OLD | NEW |