| 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/command_line.h" |
| 7 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" | 9 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "chrome/browser/spellchecker/spellcheck_service.h" | 10 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 11 #include "chrome/common/chrome_switches.h" |
| 10 #include "chrome/common/pref_names.h" | 12 #include "chrome/common/pref_names.h" |
| 11 #include "chrome/grit/locale_settings.h" | 13 #include "chrome/grit/locale_settings.h" |
| 12 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 14 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 13 #include "components/pref_registry/pref_registry_syncable.h" | 15 #include "components/pref_registry/pref_registry_syncable.h" |
| 14 #include "components/user_prefs/user_prefs.h" | 16 #include "components/user_prefs/user_prefs.h" |
| 15 #include "content/public/browser/render_process_host.h" | 17 #include "content/public/browser/render_process_host.h" |
| 16 | 18 |
| 17 // static | 19 // static |
| 18 SpellcheckService* SpellcheckServiceFactory::GetForContext( | 20 SpellcheckService* SpellcheckServiceFactory::GetForContext( |
| 19 content::BrowserContext* context) { | 21 content::BrowserContext* context) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Instantiates Metrics object for spellchecking for use. | 62 // Instantiates Metrics object for spellchecking for use. |
| 61 spellcheck->StartRecordingMetrics( | 63 spellcheck->StartRecordingMetrics( |
| 62 prefs->GetBoolean(prefs::kEnableContinuousSpellcheck)); | 64 prefs->GetBoolean(prefs::kEnableContinuousSpellcheck)); |
| 63 | 65 |
| 64 return spellcheck; | 66 return spellcheck; |
| 65 } | 67 } |
| 66 | 68 |
| 67 void SpellcheckServiceFactory::RegisterProfilePrefs( | 69 void SpellcheckServiceFactory::RegisterProfilePrefs( |
| 68 user_prefs::PrefRegistrySyncable* user_prefs) { | 70 user_prefs::PrefRegistrySyncable* user_prefs) { |
| 69 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string. | 71 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string. |
| 72 |
| 73 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 74 if (command_line->HasSwitch(switches::kEnableMultilingualSpellChecker)) { |
| 75 user_prefs->RegisterLocalizedStringPref( |
| 76 prefs::kSpellCheckDictionaries, |
| 77 IDS_SPELLCHECK_DICTIONARY, |
| 78 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 79 } |
| 80 |
| 70 user_prefs->RegisterLocalizedStringPref( | 81 user_prefs->RegisterLocalizedStringPref( |
| 71 prefs::kSpellCheckDictionary, | 82 prefs::kSpellCheckDictionary, |
| 72 IDS_SPELLCHECK_DICTIONARY, | 83 IDS_SPELLCHECK_DICTIONARY, |
| 73 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 84 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 85 |
| 74 user_prefs->RegisterBooleanPref( | 86 user_prefs->RegisterBooleanPref( |
| 75 prefs::kSpellCheckUseSpellingService, | 87 prefs::kSpellCheckUseSpellingService, |
| 76 false, | 88 false, |
| 77 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); | 89 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF); |
| 78 user_prefs->RegisterBooleanPref( | 90 user_prefs->RegisterBooleanPref( |
| 79 prefs::kEnableContinuousSpellcheck, | 91 prefs::kEnableContinuousSpellcheck, |
| 80 true, | 92 true, |
| 81 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 93 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 82 user_prefs->RegisterBooleanPref( | 94 user_prefs->RegisterBooleanPref( |
| 83 prefs::kEnableAutoSpellCorrect, | 95 prefs::kEnableAutoSpellCorrect, |
| 84 false, | 96 false, |
| 85 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); | 97 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); |
| 86 } | 98 } |
| 87 | 99 |
| 88 content::BrowserContext* SpellcheckServiceFactory::GetBrowserContextToUse( | 100 content::BrowserContext* SpellcheckServiceFactory::GetBrowserContextToUse( |
| 89 content::BrowserContext* context) const { | 101 content::BrowserContext* context) const { |
| 90 return chrome::GetBrowserContextRedirectedInIncognito(context); | 102 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 91 } | 103 } |
| 92 | 104 |
| 93 bool SpellcheckServiceFactory::ServiceIsNULLWhileTesting() const { | 105 bool SpellcheckServiceFactory::ServiceIsNULLWhileTesting() const { |
| 94 return true; | 106 return true; |
| 95 } | 107 } |
| OLD | NEW |