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

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

Issue 2244083002: Componentize spellcheck [4]: spellcheck/browser and android java-side. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 4 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
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 "chrome/browser/profiles/incognito_helpers.h" 7 #include "chrome/browser/profiles/incognito_helpers.h"
8 #include "chrome/browser/spellchecker/spellcheck_service.h" 8 #include "chrome/browser/spellchecker/spellcheck_service.h"
9 #include "chrome/common/pref_names.h"
10 #include "chrome/grit/locale_settings.h" 9 #include "chrome/grit/locale_settings.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h" 10 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "components/pref_registry/pref_registry_syncable.h" 11 #include "components/pref_registry/pref_registry_syncable.h"
13 #include "components/prefs/pref_service.h" 12 #include "components/prefs/pref_service.h"
13 #include "components/spellcheck/browser/pref_names.h"
14 #include "components/user_prefs/user_prefs.h" 14 #include "components/user_prefs/user_prefs.h"
15 #include "content/public/browser/browser_context.h" 15 #include "content/public/browser/browser_context.h"
16 #include "content/public/browser/render_process_host.h" 16 #include "content/public/browser/render_process_host.h"
17 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
18 18
19 // static 19 // static
20 SpellcheckService* SpellcheckServiceFactory::GetForContext( 20 SpellcheckService* SpellcheckServiceFactory::GetForContext(
21 content::BrowserContext* context) { 21 content::BrowserContext* context) {
22 return static_cast<SpellcheckService*>( 22 return static_cast<SpellcheckService*>(
23 GetInstance()->GetServiceForBrowserContext(context, true)); 23 GetInstance()->GetServiceForBrowserContext(context, true));
(...skipping 30 matching lines...) Expand all
54 KeyedService* SpellcheckServiceFactory::BuildServiceInstanceFor( 54 KeyedService* SpellcheckServiceFactory::BuildServiceInstanceFor(
55 content::BrowserContext* context) const { 55 content::BrowserContext* context) const {
56 // Many variables are initialized from the |context| in the SpellcheckService. 56 // Many variables are initialized from the |context| in the SpellcheckService.
57 SpellcheckService* spellcheck = new SpellcheckService(context); 57 SpellcheckService* spellcheck = new SpellcheckService(context);
58 58
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(spellcheck::prefs::kEnableContinuousSpellcheck));
65 65
66 return spellcheck; 66 return spellcheck;
67 } 67 }
68 68
69 void SpellcheckServiceFactory::RegisterProfilePrefs( 69 void SpellcheckServiceFactory::RegisterProfilePrefs(
70 user_prefs::PrefRegistrySyncable* user_prefs) { 70 user_prefs::PrefRegistrySyncable* user_prefs) {
71 user_prefs->RegisterListPref(prefs::kSpellCheckDictionaries, 71 user_prefs->RegisterListPref(spellcheck::prefs::kSpellCheckDictionaries,
72 new base::ListValue); 72 new base::ListValue);
73 // Continue registering kSpellCheckDictionary for preference migration. 73 // Continue registering kSpellCheckDictionary for preference migration.
74 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string. 74 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string.
75 user_prefs->RegisterStringPref( 75 user_prefs->RegisterStringPref(
76 prefs::kSpellCheckDictionary, 76 spellcheck::prefs::kSpellCheckDictionary,
77 l10n_util::GetStringUTF8(IDS_SPELLCHECK_DICTIONARY)); 77 l10n_util::GetStringUTF8(IDS_SPELLCHECK_DICTIONARY));
78 user_prefs->RegisterBooleanPref(prefs::kSpellCheckUseSpellingService, false); 78 user_prefs->RegisterBooleanPref(
79 spellcheck::prefs::kSpellCheckUseSpellingService, false);
79 #if defined(OS_IOS) || defined(OS_ANDROID) 80 #if defined(OS_IOS) || defined(OS_ANDROID)
80 uint32_t flags = PrefRegistry::NO_REGISTRATION_FLAGS; 81 uint32_t flags = PrefRegistry::NO_REGISTRATION_FLAGS;
81 #else 82 #else
82 uint32_t flags = user_prefs::PrefRegistrySyncable::SYNCABLE_PREF; 83 uint32_t flags = user_prefs::PrefRegistrySyncable::SYNCABLE_PREF;
83 #endif 84 #endif
84 user_prefs->RegisterBooleanPref(prefs::kEnableContinuousSpellcheck, true, 85 user_prefs->RegisterBooleanPref(
85 flags); 86 spellcheck::prefs::kEnableContinuousSpellcheck, true, flags);
86 } 87 }
87 88
88 content::BrowserContext* SpellcheckServiceFactory::GetBrowserContextToUse( 89 content::BrowserContext* SpellcheckServiceFactory::GetBrowserContextToUse(
89 content::BrowserContext* context) const { 90 content::BrowserContext* context) const {
90 return chrome::GetBrowserContextRedirectedInIncognito(context); 91 return chrome::GetBrowserContextRedirectedInIncognito(context);
91 } 92 }
92 93
93 bool SpellcheckServiceFactory::ServiceIsNULLWhileTesting() const { 94 bool SpellcheckServiceFactory::ServiceIsNULLWhileTesting() const {
94 return true; 95 return true;
95 } 96 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698