Chromium Code Reviews| 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_factory.h" | 5 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "chrome/browser/spellchecker/spellcheck_service.h" | 9 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/common/spellcheck_common.h" | |
| 11 #include "chrome/grit/locale_settings.h" | 12 #include "chrome/grit/locale_settings.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 13 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "components/pref_registry/pref_registry_syncable.h" | 14 #include "components/pref_registry/pref_registry_syncable.h" |
| 14 #include "components/user_prefs/user_prefs.h" | 15 #include "components/user_prefs/user_prefs.h" |
| 15 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
| 17 #include "ui/base/l10n/l10n_util.h" | 18 #include "ui/base/l10n/l10n_util.h" |
| 18 | 19 |
| 19 // static | 20 // static |
| 20 SpellcheckService* SpellcheckServiceFactory::GetForContext( | 21 SpellcheckService* SpellcheckServiceFactory::GetForContext( |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 48 // TODO(erg): Uncomment these as they are initialized. | 49 // TODO(erg): Uncomment these as they are initialized. |
| 49 // DependsOn(RequestContextFactory::GetInstance()); | 50 // DependsOn(RequestContextFactory::GetInstance()); |
| 50 } | 51 } |
| 51 | 52 |
| 52 SpellcheckServiceFactory::~SpellcheckServiceFactory() {} | 53 SpellcheckServiceFactory::~SpellcheckServiceFactory() {} |
| 53 | 54 |
| 54 KeyedService* SpellcheckServiceFactory::BuildServiceInstanceFor( | 55 KeyedService* SpellcheckServiceFactory::BuildServiceInstanceFor( |
| 55 content::BrowserContext* context) const { | 56 content::BrowserContext* context) const { |
| 56 // Many variables are initialized from the |context| in the SpellcheckService. | 57 // Many variables are initialized from the |context| in the SpellcheckService. |
| 57 SpellcheckService* spellcheck = new SpellcheckService(context); | 58 SpellcheckService* spellcheck = new SpellcheckService(context); |
| 58 | |
|
please use gerrit instead
2015/06/16 00:31:16
These whitespace changes or not necessary.
Julius
2015/06/17 00:59:52
Done.
| |
| 59 PrefService* prefs = user_prefs::UserPrefs::Get(context); | 59 PrefService* prefs = user_prefs::UserPrefs::Get(context); |
| 60 DCHECK(prefs); | 60 DCHECK(prefs); |
| 61 | 61 |
| 62 // Instantiates Metrics object for spellchecking for use. | 62 // Instantiates Metrics object for spellchecking for use. |
| 63 spellcheck->StartRecordingMetrics( | 63 spellcheck->StartRecordingMetrics( |
| 64 prefs->GetBoolean(prefs::kEnableContinuousSpellcheck)); | 64 prefs->GetBoolean(prefs::kEnableContinuousSpellcheck)); |
| 65 | |
| 66 return spellcheck; | 65 return spellcheck; |
| 67 } | 66 } |
| 68 | 67 |
| 69 void SpellcheckServiceFactory::RegisterProfilePrefs( | 68 void SpellcheckServiceFactory::RegisterProfilePrefs( |
| 70 user_prefs::PrefRegistrySyncable* user_prefs) { | 69 user_prefs::PrefRegistrySyncable* user_prefs) { |
| 71 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string. | 70 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string. |
| 71 | |
| 72 // TODO(juliusa): Implement preference migration between multilingual | |
| 73 // spellchecking and single-language spellchecking. | |
|
please use gerrit instead
2015/06/16 00:31:16
You can put this on your own todo list, but let's
Julius
2015/06/17 00:59:52
Done.
| |
| 74 if (chrome::spellcheck_common::MultilingualSpellcheckIsEnabled()) { | |
| 75 user_prefs->RegisterStringPref( | |
| 76 prefs::kSpellCheckDictionaries, | |
| 77 l10n_util::GetStringUTF8(IDS_SPELLCHECK_DICTIONARY), | |
| 78 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
| 79 } else { | |
|
please use gerrit instead
2015/06/16 00:31:16
Is that an empty else{} block?
Julius
2015/06/17 00:59:52
Done.
| |
| 80 } | |
| 72 user_prefs->RegisterStringPref( | 81 user_prefs->RegisterStringPref( |
| 73 prefs::kSpellCheckDictionary, | 82 prefs::kSpellCheckDictionary, |
| 74 l10n_util::GetStringUTF8(IDS_SPELLCHECK_DICTIONARY)); | 83 l10n_util::GetStringUTF8(IDS_SPELLCHECK_DICTIONARY), |
| 84 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | |
| 85 | |
| 75 user_prefs->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService, false); | 86 user_prefs->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService, false); |
| 76 user_prefs->RegisterBooleanPref( | 87 user_prefs->RegisterBooleanPref( |
| 77 prefs::kEnableContinuousSpellcheck, | 88 prefs::kEnableContinuousSpellcheck, |
| 78 true, | 89 true, |
| 79 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 90 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 80 user_prefs->RegisterBooleanPref( | 91 user_prefs->RegisterBooleanPref( |
| 81 prefs::kEnableAutoSpellCorrect, | 92 prefs::kEnableAutoSpellCorrect, |
| 82 false, | 93 false, |
| 83 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 94 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 84 } | 95 } |
| 85 | 96 |
| 86 content::BrowserContext* SpellcheckServiceFactory::GetBrowserContextToUse( | 97 content::BrowserContext* SpellcheckServiceFactory::GetBrowserContextToUse( |
| 87 content::BrowserContext* context) const { | 98 content::BrowserContext* context) const { |
| 88 return chrome::GetBrowserContextRedirectedInIncognito(context); | 99 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 89 } | 100 } |
| 90 | 101 |
| 91 bool SpellcheckServiceFactory::ServiceIsNULLWhileTesting() const { | 102 bool SpellcheckServiceFactory::ServiceIsNULLWhileTesting() const { |
| 92 return true; | 103 return true; |
| 93 } | 104 } |
| OLD | NEW |