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