Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(330)

Side by Side Diff: chrome/browser/spellchecker/spellcheck_service.cc

Issue 12335019: [Spellcheck] Add UMA stat for SpellingService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/prefs/public/pref_member.h" 9 #include "base/prefs/public/pref_member.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 30 matching lines...) Expand all
41 pref_change_registrar_.Init(prefs); 41 pref_change_registrar_.Init(prefs);
42 42
43 pref_change_registrar_.Add( 43 pref_change_registrar_.Add(
44 prefs::kEnableAutoSpellCorrect, 44 prefs::kEnableAutoSpellCorrect,
45 base::Bind(&SpellcheckService::OnEnableAutoSpellCorrectChanged, 45 base::Bind(&SpellcheckService::OnEnableAutoSpellCorrectChanged,
46 base::Unretained(this))); 46 base::Unretained(this)));
47 pref_change_registrar_.Add( 47 pref_change_registrar_.Add(
48 prefs::kSpellCheckDictionary, 48 prefs::kSpellCheckDictionary,
49 base::Bind(&SpellcheckService::OnSpellCheckDictionaryChanged, 49 base::Bind(&SpellcheckService::OnSpellCheckDictionaryChanged,
50 base::Unretained(this))); 50 base::Unretained(this)));
51 pref_change_registrar_.Add(
52 prefs::kSpellCheckUseSpellingService,
53 base::Bind(&SpellcheckService::OnUseSpellingServiceChanged,
54 base::Unretained(this)));
51 pref_change_registrar_.Add( 55 pref_change_registrar_.Add(
52 prefs::kEnableContinuousSpellcheck, 56 prefs::kEnableContinuousSpellcheck,
53 base::Bind(&SpellcheckService::InitForAllRenderers, 57 base::Bind(&SpellcheckService::InitForAllRenderers,
54 base::Unretained(this))); 58 base::Unretained(this)));
55 59
56 OnSpellCheckDictionaryChanged(); 60 OnSpellCheckDictionaryChanged();
57 61
58 custom_dictionary_.reset(new SpellcheckCustomDictionary(profile_->GetPath())); 62 custom_dictionary_.reset(new SpellcheckCustomDictionary(profile_->GetPath()));
59 custom_dictionary_->AddObserver(this); 63 custom_dictionary_->AddObserver(this);
60 custom_dictionary_->Load(); 64 custom_dictionary_->Load();
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 if (!g_status_event) 136 if (!g_status_event)
133 return false; 137 return false;
134 g_status_type = status_type; 138 g_status_type = status_type;
135 g_status_event->Signal(); 139 g_status_event->Signal();
136 return true; 140 return true;
137 } 141 }
138 142
139 void SpellcheckService::StartRecordingMetrics(bool spellcheck_enabled) { 143 void SpellcheckService::StartRecordingMetrics(bool spellcheck_enabled) {
140 metrics_.reset(new SpellCheckHostMetrics()); 144 metrics_.reset(new SpellCheckHostMetrics());
141 metrics_->RecordEnabledStats(spellcheck_enabled); 145 metrics_->RecordEnabledStats(spellcheck_enabled);
146 OnUseSpellingServiceChanged();
142 } 147 }
143 148
144 void SpellcheckService::InitForRenderer(content::RenderProcessHost* process) { 149 void SpellcheckService::InitForRenderer(content::RenderProcessHost* process) {
145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 150 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
146 151
147 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext()); 152 Profile* profile = Profile::FromBrowserContext(process->GetBrowserContext());
148 if (SpellcheckServiceFactory::GetForProfile(profile) != this) 153 if (SpellcheckServiceFactory::GetForProfile(profile) != this)
149 return; 154 return;
150 155
151 PrefService* prefs = profile->GetPrefs(); 156 PrefService* prefs = profile->GetPrefs();
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 void SpellcheckService::OnSpellCheckDictionaryChanged() { 269 void SpellcheckService::OnSpellCheckDictionaryChanged() {
265 if (hunspell_dictionary_.get()) 270 if (hunspell_dictionary_.get())
266 hunspell_dictionary_->RemoveObserver(this); 271 hunspell_dictionary_->RemoveObserver(this);
267 hunspell_dictionary_.reset(new SpellcheckHunspellDictionary( 272 hunspell_dictionary_.reset(new SpellcheckHunspellDictionary(
268 profile_->GetPrefs()->GetString(prefs::kSpellCheckDictionary), 273 profile_->GetPrefs()->GetString(prefs::kSpellCheckDictionary),
269 profile_->GetRequestContext(), 274 profile_->GetRequestContext(),
270 this)); 275 this));
271 hunspell_dictionary_->AddObserver(this); 276 hunspell_dictionary_->AddObserver(this);
272 hunspell_dictionary_->Load(); 277 hunspell_dictionary_->Load();
273 } 278 }
279
280 void SpellcheckService::OnUseSpellingServiceChanged() {
281 bool enabled = pref_change_registrar_.prefs()->GetBoolean(
282 prefs::kSpellCheckUseSpellingService);
283 if (metrics_)
284 metrics_->RecordSpellingServiceStats(enabled);
285 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698