| 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/memory/ptr_util.h" |
| 7 #include "chrome/browser/profiles/incognito_helpers.h" | 8 #include "chrome/browser/profiles/incognito_helpers.h" |
| 8 #include "chrome/browser/spellchecker/spellcheck_service.h" | 9 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 9 #include "chrome/grit/locale_settings.h" | 10 #include "chrome/grit/locale_settings.h" |
| 10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 11 #include "components/pref_registry/pref_registry_syncable.h" | 12 #include "components/pref_registry/pref_registry_syncable.h" |
| 12 #include "components/prefs/pref_service.h" | 13 #include "components/prefs/pref_service.h" |
| 13 #include "components/spellcheck/browser/pref_names.h" | 14 #include "components/spellcheck/browser/pref_names.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" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 // Instantiates Metrics object for spellchecking for use. | 63 // Instantiates Metrics object for spellchecking for use. |
| 63 spellcheck->StartRecordingMetrics( | 64 spellcheck->StartRecordingMetrics( |
| 64 prefs->GetBoolean(spellcheck::prefs::kEnableSpellcheck)); | 65 prefs->GetBoolean(spellcheck::prefs::kEnableSpellcheck)); |
| 65 | 66 |
| 66 return spellcheck; | 67 return spellcheck; |
| 67 } | 68 } |
| 68 | 69 |
| 69 void SpellcheckServiceFactory::RegisterProfilePrefs( | 70 void SpellcheckServiceFactory::RegisterProfilePrefs( |
| 70 user_prefs::PrefRegistrySyncable* user_prefs) { | 71 user_prefs::PrefRegistrySyncable* user_prefs) { |
| 71 user_prefs->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, | 72 user_prefs->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries, |
| 72 new base::ListValue); | 73 base::MakeUnique<base::ListValue>()); |
| 73 // Continue registering kSpellCheckDictionary for preference migration. | 74 // Continue registering kSpellCheckDictionary for preference migration. |
| 74 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string. | 75 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string. |
| 75 user_prefs->RegisterStringPref( | 76 user_prefs->RegisterStringPref( |
| 76 spellcheck::prefs::kSpellCheckDictionary, | 77 spellcheck::prefs::kSpellCheckDictionary, |
| 77 l10n_util::GetStringUTF8(IDS_SPELLCHECK_DICTIONARY)); | 78 l10n_util::GetStringUTF8(IDS_SPELLCHECK_DICTIONARY)); |
| 78 user_prefs->RegisterBooleanPref( | 79 user_prefs->RegisterBooleanPref( |
| 79 spellcheck::prefs::kSpellCheckUseSpellingService, false); | 80 spellcheck::prefs::kSpellCheckUseSpellingService, false); |
| 80 #if defined(OS_IOS) || defined(OS_ANDROID) | 81 #if defined(OS_IOS) || defined(OS_ANDROID) |
| 81 uint32_t flags = PrefRegistry::NO_REGISTRATION_FLAGS; | 82 uint32_t flags = PrefRegistry::NO_REGISTRATION_FLAGS; |
| 82 #else | 83 #else |
| 83 uint32_t flags = user_prefs::PrefRegistrySyncable::SYNCABLE_PREF; | 84 uint32_t flags = user_prefs::PrefRegistrySyncable::SYNCABLE_PREF; |
| 84 #endif | 85 #endif |
| 85 user_prefs->RegisterBooleanPref( | 86 user_prefs->RegisterBooleanPref( |
| 86 spellcheck::prefs::kEnableSpellcheck, true, flags); | 87 spellcheck::prefs::kEnableSpellcheck, true, flags); |
| 87 } | 88 } |
| 88 | 89 |
| 89 content::BrowserContext* SpellcheckServiceFactory::GetBrowserContextToUse( | 90 content::BrowserContext* SpellcheckServiceFactory::GetBrowserContextToUse( |
| 90 content::BrowserContext* context) const { | 91 content::BrowserContext* context) const { |
| 91 return chrome::GetBrowserContextRedirectedInIncognito(context); | 92 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 92 } | 93 } |
| 93 | 94 |
| 94 bool SpellcheckServiceFactory::ServiceIsNULLWhileTesting() const { | 95 bool SpellcheckServiceFactory::ServiceIsNULLWhileTesting() const { |
| 95 return true; | 96 return true; |
| 96 } | 97 } |
| OLD | NEW |