[email protected] | 810ffba | 2012-06-12 01:07:48 | [diff] [blame] | 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/autocomplete/autocomplete_classifier_factory.h" | ||||
6 | |||||
7 | #include "chrome/browser/autocomplete/autocomplete_classifier.h" | ||||
8 | #include "chrome/browser/extensions/extension_system_factory.h" | ||||
[email protected] | 1467cfe | 2012-07-04 01:19:15 | [diff] [blame] | 9 | #include "chrome/browser/history/shortcuts_backend_factory.h" |
[email protected] | 018bf65 | 2013-05-03 23:18:34 | [diff] [blame^] | 10 | #include "chrome/browser/profiles/incognito_helpers.h" |
[email protected] | c7fa436 | 2013-04-26 18:09:02 | [diff] [blame] | 11 | #include "chrome/browser/profiles/profile.h" |
[email protected] | 810ffba | 2012-06-12 01:07:48 | [diff] [blame] | 12 | #include "chrome/browser/profiles/profile_dependency_manager.h" |
13 | #include "chrome/browser/search_engines/template_url_service_factory.h" | ||||
14 | |||||
15 | |||||
16 | // static | ||||
17 | AutocompleteClassifier* AutocompleteClassifierFactory::GetForProfile( | ||||
18 | Profile* profile) { | ||||
19 | return static_cast<AutocompleteClassifier*>( | ||||
20 | GetInstance()->GetServiceForProfile(profile, true)); | ||||
21 | } | ||||
22 | |||||
23 | // static | ||||
24 | AutocompleteClassifierFactory* AutocompleteClassifierFactory::GetInstance() { | ||||
25 | return Singleton<AutocompleteClassifierFactory>::get(); | ||||
26 | } | ||||
27 | |||||
28 | // static | ||||
29 | ProfileKeyedService* AutocompleteClassifierFactory::BuildInstanceFor( | ||||
[email protected] | c7fa436 | 2013-04-26 18:09:02 | [diff] [blame] | 30 | content::BrowserContext* profile) { |
31 | return new AutocompleteClassifier(static_cast<Profile*>(profile)); | ||||
[email protected] | 810ffba | 2012-06-12 01:07:48 | [diff] [blame] | 32 | } |
33 | |||||
34 | AutocompleteClassifierFactory::AutocompleteClassifierFactory() | ||||
35 | : ProfileKeyedServiceFactory("AutocompleteClassifier", | ||||
36 | ProfileDependencyManager::GetInstance()) { | ||||
[email protected] | bd30672 | 2012-07-11 20:43:59 | [diff] [blame] | 37 | DependsOn(extensions::ExtensionSystemFactory::GetInstance()); |
[email protected] | 810ffba | 2012-06-12 01:07:48 | [diff] [blame] | 38 | DependsOn(TemplateURLServiceFactory::GetInstance()); |
39 | // TODO(pkasting): Uncomment these once they exist. | ||||
40 | // DependsOn(PrefServiceFactory::GetInstance()); | ||||
[email protected] | 1467cfe | 2012-07-04 01:19:15 | [diff] [blame] | 41 | DependsOn(ShortcutsBackendFactory::GetInstance()); |
[email protected] | 810ffba | 2012-06-12 01:07:48 | [diff] [blame] | 42 | } |
43 | |||||
44 | AutocompleteClassifierFactory::~AutocompleteClassifierFactory() { | ||||
45 | } | ||||
46 | |||||
[email protected] | 018bf65 | 2013-05-03 23:18:34 | [diff] [blame^] | 47 | content::BrowserContext* AutocompleteClassifierFactory::GetBrowserContextToUse( |
48 | content::BrowserContext* context) const { | ||||
49 | return chrome::GetBrowserContextRedirectedInIncognito(context); | ||||
[email protected] | 810ffba | 2012-06-12 01:07:48 | [diff] [blame] | 50 | } |
51 | |||||
[email protected] | bb05cae1 | 2012-09-06 00:37:52 | [diff] [blame] | 52 | bool AutocompleteClassifierFactory::ServiceIsNULLWhileTesting() const { |
[email protected] | 810ffba | 2012-06-12 01:07:48 | [diff] [blame] | 53 | return true; |
54 | } | ||||
55 | |||||
56 | ProfileKeyedService* AutocompleteClassifierFactory::BuildServiceInstanceFor( | ||||
[email protected] | c7fa436 | 2013-04-26 18:09:02 | [diff] [blame] | 57 | content::BrowserContext* profile) const { |
58 | return BuildInstanceFor(static_cast<Profile*>(profile)); | ||||
[email protected] | 810ffba | 2012-06-12 01:07:48 | [diff] [blame] | 59 | } |