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/autocomplete/autocomplete_classifier_factory.h" | 5 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" | 8 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" | 9 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h" |
10 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" | 10 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h" |
11 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" | 11 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h" |
12 #include "chrome/browser/profiles/incognito_helpers.h" | 12 #include "chrome/browser/profiles/incognito_helpers.h" |
13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
14 #include "chrome/browser/search_engines/template_url_service_factory.h" | 14 #include "chrome/browser/search_engines/template_url_service_factory.h" |
15 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 15 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
16 #include "components/omnibox/browser/autocomplete_classifier.h" | 16 #include "components/omnibox/browser/autocomplete_classifier.h" |
17 #include "components/omnibox/browser/autocomplete_controller.h" | 17 #include "components/omnibox/browser/autocomplete_controller.h" |
| 18 #include "extensions/features/features.h" |
18 | 19 |
19 #if defined(ENABLE_EXTENSIONS) | 20 #if BUILDFLAG(ENABLE_EXTENSIONS) |
20 #include "extensions/browser/extension_system_provider.h" | 21 #include "extensions/browser/extension_system_provider.h" |
21 #include "extensions/browser/extensions_browser_client.h" | 22 #include "extensions/browser/extensions_browser_client.h" |
22 #endif | 23 #endif |
23 | 24 |
24 // static | 25 // static |
25 AutocompleteClassifier* AutocompleteClassifierFactory::GetForProfile( | 26 AutocompleteClassifier* AutocompleteClassifierFactory::GetForProfile( |
26 Profile* profile) { | 27 Profile* profile) { |
27 return static_cast<AutocompleteClassifier*>( | 28 return static_cast<AutocompleteClassifier*>( |
28 GetInstance()->GetServiceForBrowserContext(profile, true)); | 29 GetInstance()->GetServiceForBrowserContext(profile, true)); |
29 } | 30 } |
(...skipping 12 matching lines...) Expand all Loading... |
42 base::WrapUnique(new ChromeAutocompleteProviderClient(profile)), NULL, | 43 base::WrapUnique(new ChromeAutocompleteProviderClient(profile)), NULL, |
43 AutocompleteClassifier::kDefaultOmniboxProviders)), | 44 AutocompleteClassifier::kDefaultOmniboxProviders)), |
44 std::unique_ptr<AutocompleteSchemeClassifier>( | 45 std::unique_ptr<AutocompleteSchemeClassifier>( |
45 new ChromeAutocompleteSchemeClassifier(profile))); | 46 new ChromeAutocompleteSchemeClassifier(profile))); |
46 } | 47 } |
47 | 48 |
48 AutocompleteClassifierFactory::AutocompleteClassifierFactory() | 49 AutocompleteClassifierFactory::AutocompleteClassifierFactory() |
49 : BrowserContextKeyedServiceFactory( | 50 : BrowserContextKeyedServiceFactory( |
50 "AutocompleteClassifier", | 51 "AutocompleteClassifier", |
51 BrowserContextDependencyManager::GetInstance()) { | 52 BrowserContextDependencyManager::GetInstance()) { |
52 #if defined(ENABLE_EXTENSIONS) | 53 #if BUILDFLAG(ENABLE_EXTENSIONS) |
53 DependsOn( | 54 DependsOn( |
54 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 55 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
55 #endif | 56 #endif |
56 DependsOn(TemplateURLServiceFactory::GetInstance()); | 57 DependsOn(TemplateURLServiceFactory::GetInstance()); |
57 // TODO(pkasting): Uncomment these once they exist. | 58 // TODO(pkasting): Uncomment these once they exist. |
58 // DependsOn(PrefServiceFactory::GetInstance()); | 59 // DependsOn(PrefServiceFactory::GetInstance()); |
59 DependsOn(ShortcutsBackendFactory::GetInstance()); | 60 DependsOn(ShortcutsBackendFactory::GetInstance()); |
60 DependsOn(InMemoryURLIndexFactory::GetInstance()); | 61 DependsOn(InMemoryURLIndexFactory::GetInstance()); |
61 } | 62 } |
62 | 63 |
63 AutocompleteClassifierFactory::~AutocompleteClassifierFactory() { | 64 AutocompleteClassifierFactory::~AutocompleteClassifierFactory() { |
64 } | 65 } |
65 | 66 |
66 content::BrowserContext* AutocompleteClassifierFactory::GetBrowserContextToUse( | 67 content::BrowserContext* AutocompleteClassifierFactory::GetBrowserContextToUse( |
67 content::BrowserContext* context) const { | 68 content::BrowserContext* context) const { |
68 return chrome::GetBrowserContextRedirectedInIncognito(context); | 69 return chrome::GetBrowserContextRedirectedInIncognito(context); |
69 } | 70 } |
70 | 71 |
71 bool AutocompleteClassifierFactory::ServiceIsNULLWhileTesting() const { | 72 bool AutocompleteClassifierFactory::ServiceIsNULLWhileTesting() const { |
72 return true; | 73 return true; |
73 } | 74 } |
74 | 75 |
75 KeyedService* AutocompleteClassifierFactory::BuildServiceInstanceFor( | 76 KeyedService* AutocompleteClassifierFactory::BuildServiceInstanceFor( |
76 content::BrowserContext* profile) const { | 77 content::BrowserContext* profile) const { |
77 return BuildInstanceFor(static_cast<Profile*>(profile)).release(); | 78 return BuildInstanceFor(static_cast<Profile*>(profile)).release(); |
78 } | 79 } |
OLD | NEW |