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

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

Issue 9289007: Profiles: Move the Spelling system onto a ProfileKeyedServiceFactory. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove stray mark Created 8 years, 11 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/spellchecker/spellcheck_factory.h"
6
7 #include "chrome/browser/browser_process.h"
8 #include "chrome/browser/metrics/metrics_service.h"
9 #include "chrome/browser/prefs/pref_service.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "chrome/browser/profiles/profile_dependency_manager.h"
12 #include "chrome/browser/spellchecker/spellcheck_profile.h"
13 #include "chrome/common/pref_names.h"
14 #include "grit/locale_settings.h"
15
16 // static
17 SpellCheckHost* SpellCheckFactory::GetHostForProfile(Profile* profile) {
18 return GetInstance()->GetSpellCheckProfile(profile)->GetHost();
19 }
20
21 // static
22 void SpellCheckFactory::ReinitializeSpellCheckHost(Profile* profile,
23 bool force) {
24 GetInstance()->GetSpellCheckProfile(profile)->
25 ReinitializeSpellCheckHost(force);
26 }
27
28 // static
29 SpellCheckFactory* SpellCheckFactory::GetInstance() {
30 return Singleton<SpellCheckFactory>::get();
31 }
32
33 SpellCheckFactory::SpellCheckFactory()
34 : ProfileKeyedServiceFactory("SpellCheckProfile",
35 ProfileDependencyManager::GetInstance()) {
36 // TODO(erg): Uncomment these as they are initialized.
37 //
38 // DependsOn(RequestContextFactory::GetInstance());
39 }
40
41 SpellCheckFactory::~SpellCheckFactory() {}
42
43 SpellCheckProfile* SpellCheckFactory::GetSpellCheckProfile(
44 Profile* profile) {
45 return static_cast<SpellCheckProfile*>(
46 GetInstance()->GetServiceForProfile(profile, true));
47 }
48
49 ProfileKeyedService* SpellCheckFactory::BuildServiceInstanceFor(
50 Profile* profile) const {
51 SpellCheckProfile* spell_check_profile = new SpellCheckProfile(profile);
52
53 // Instantiates Metrics object for spellchecking for use.
54 if (g_browser_process->metrics_service() &&
55 g_browser_process->metrics_service()->recording_active())
56 spell_check_profile->StartRecordingMetrics(
57 profile->GetPrefs()->GetBoolean(prefs::kEnableSpellCheck));
58
59 return spell_check_profile;
60 }
61
62 void SpellCheckFactory::RegisterUserPrefs(PrefService* user_prefs) {
63 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string.
64 user_prefs->RegisterLocalizedStringPref(prefs::kSpellCheckDictionary,
65 IDS_SPELLCHECK_DICTIONARY,
66 PrefService::UNSYNCABLE_PREF);
67 user_prefs->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService,
68 false,
69 PrefService::UNSYNCABLE_PREF);
70 user_prefs->RegisterBooleanPref(prefs::kEnableSpellCheck,
71 true,
72 PrefService::SYNCABLE_PREF);
73 user_prefs->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect,
74 true,
75 PrefService::UNSYNCABLE_PREF);
76 }
77
78 bool SpellCheckFactory::ServiceRedirectedInIncognito() {
79 return true;
80 }
81
82 bool SpellCheckFactory::ServiceIsNULLWhileTesting() {
83 return true;
84 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698