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/prefs/pref_member.h" | 7 #include "base/prefs/pref_member.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "base/synchronization/waitable_event.h" | 10 #include "base/synchronization/waitable_event.h" |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 registrar_.Add(this, | 67 registrar_.Add(this, |
68 content::NOTIFICATION_RENDERER_PROCESS_CREATED, | 68 content::NOTIFICATION_RENDERER_PROCESS_CREATED, |
69 content::NotificationService::AllSources()); | 69 content::NotificationService::AllSources()); |
70 } | 70 } |
71 | 71 |
72 SpellcheckService::~SpellcheckService() { | 72 SpellcheckService::~SpellcheckService() { |
73 // Remove pref observers | 73 // Remove pref observers |
74 pref_change_registrar_.RemoveAll(); | 74 pref_change_registrar_.RemoveAll(); |
75 } | 75 } |
76 | 76 |
| 77 base::WeakPtr<SpellcheckService> SpellcheckService::GetWeakPtr() { |
| 78 return weak_ptr_factory_.GetWeakPtr(); |
| 79 } |
| 80 |
77 // static | 81 // static |
78 int SpellcheckService::GetSpellCheckLanguages( | 82 int SpellcheckService::GetSpellCheckLanguages( |
79 content::BrowserContext* context, | 83 content::BrowserContext* context, |
80 std::vector<std::string>* languages) { | 84 std::vector<std::string>* languages) { |
81 PrefService* prefs = user_prefs::UserPrefs::Get(context); | 85 PrefService* prefs = user_prefs::UserPrefs::Get(context); |
82 StringPrefMember accept_languages_pref; | 86 StringPrefMember accept_languages_pref; |
83 StringPrefMember dictionary_language_pref; | 87 StringPrefMember dictionary_language_pref; |
84 accept_languages_pref.Init(prefs::kAcceptLanguages, prefs); | 88 accept_languages_pref.Init(prefs::kAcceptLanguages, prefs); |
85 dictionary_language_pref.Init(prefs::kSpellCheckDictionary, prefs); | 89 dictionary_language_pref.Init(prefs::kSpellCheckDictionary, prefs); |
86 std::string dictionary_language = dictionary_language_pref.GetValue(); | 90 std::string dictionary_language = dictionary_language_pref.GetValue(); |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 hunspell_dictionary_->AddObserver(this); | 283 hunspell_dictionary_->AddObserver(this); |
280 hunspell_dictionary_->Load(); | 284 hunspell_dictionary_->Load(); |
281 } | 285 } |
282 | 286 |
283 void SpellcheckService::OnUseSpellingServiceChanged() { | 287 void SpellcheckService::OnUseSpellingServiceChanged() { |
284 bool enabled = pref_change_registrar_.prefs()->GetBoolean( | 288 bool enabled = pref_change_registrar_.prefs()->GetBoolean( |
285 prefs::kSpellCheckUseSpellingService); | 289 prefs::kSpellCheckUseSpellingService); |
286 if (metrics_) | 290 if (metrics_) |
287 metrics_->RecordSpellingServiceStats(enabled); | 291 metrics_->RecordSpellingServiceStats(enabled); |
288 } | 292 } |
OLD | NEW |