BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / autocomplete / autocomplete_classifier_factory.cc
blob35cab6f5a4ab418dcd926f1d5f95914a83c862c2
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.
5 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h"
7 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
8 #include "chrome/browser/autocomplete/chrome_autocomplete_scheme_classifier.h"
9 #include "chrome/browser/autocomplete/in_memory_url_index_factory.h"
10 #include "chrome/browser/autocomplete/shortcuts_backend_factory.h"
11 #include "chrome/browser/profiles/incognito_helpers.h"
12 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/browser/search_engines/template_url_service_factory.h"
14 #include "components/keyed_service/content/browser_context_dependency_manager.h"
15 #include "components/omnibox/browser/autocomplete_classifier.h"
16 #include "components/omnibox/browser/autocomplete_controller.h"
18 #if defined(ENABLE_EXTENSIONS)
19 #include "extensions/browser/extension_system_provider.h"
20 #include "extensions/browser/extensions_browser_client.h"
21 #endif
23 // static
24 AutocompleteClassifier* AutocompleteClassifierFactory::GetForProfile(
25 Profile* profile) {
26 return static_cast<AutocompleteClassifier*>(
27 GetInstance()->GetServiceForBrowserContext(profile, true));
30 // static
31 AutocompleteClassifierFactory* AutocompleteClassifierFactory::GetInstance() {
32 return base::Singleton<AutocompleteClassifierFactory>::get();
35 // static
36 scoped_ptr<KeyedService> AutocompleteClassifierFactory::BuildInstanceFor(
37 content::BrowserContext* context) {
38 Profile* profile = static_cast<Profile*>(context);
39 return make_scoped_ptr(new AutocompleteClassifier(
40 make_scoped_ptr(new AutocompleteController(
41 make_scoped_ptr(new ChromeAutocompleteProviderClient(profile)), NULL,
42 AutocompleteClassifier::kDefaultOmniboxProviders)),
43 scoped_ptr<AutocompleteSchemeClassifier>(
44 new ChromeAutocompleteSchemeClassifier(profile))));
47 AutocompleteClassifierFactory::AutocompleteClassifierFactory()
48 : BrowserContextKeyedServiceFactory(
49 "AutocompleteClassifier",
50 BrowserContextDependencyManager::GetInstance()) {
51 #if defined(ENABLE_EXTENSIONS)
52 DependsOn(
53 extensions::ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
54 #endif
55 DependsOn(TemplateURLServiceFactory::GetInstance());
56 // TODO(pkasting): Uncomment these once they exist.
57 // DependsOn(PrefServiceFactory::GetInstance());
58 DependsOn(ShortcutsBackendFactory::GetInstance());
59 DependsOn(InMemoryURLIndexFactory::GetInstance());
62 AutocompleteClassifierFactory::~AutocompleteClassifierFactory() {
65 content::BrowserContext* AutocompleteClassifierFactory::GetBrowserContextToUse(
66 content::BrowserContext* context) const {
67 return chrome::GetBrowserContextRedirectedInIncognito(context);
70 bool AutocompleteClassifierFactory::ServiceIsNULLWhileTesting() const {
71 return true;
74 KeyedService* AutocompleteClassifierFactory::BuildServiceInstanceFor(
75 content::BrowserContext* profile) const {
76 return BuildInstanceFor(static_cast<Profile*>(profile)).release();