autocomplete_classifier_factory.cc revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
1c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org// Copyright (c) 2012 The Chromium Authors. All rights reserved. 2c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org// Use of this source code is governed by a BSD-style license that can be 3c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org// found in the LICENSE file. 4c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org 5c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org#include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" 6c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org 7c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org#include "chrome/browser/autocomplete/autocomplete_classifier.h" 8c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org#include "chrome/browser/extensions/extension_system_factory.h" 9c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org#include "chrome/browser/history/shortcuts_backend_factory.h" 10c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org#include "chrome/browser/profiles/incognito_helpers.h" 11c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org#include "chrome/browser/profiles/profile.h" 12c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org#include "chrome/browser/search_engines/template_url_service_factory.h" 13c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org#include "components/browser_context_keyed_service/browser_context_dependency_manager.h" 1477e079af1a909ee9d14306db48561d77e2f9fcabcommit-bot@chromium.org 1577e079af1a909ee9d14306db48561d77e2f9fcabcommit-bot@chromium.org 16c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org// static 178b0e8ac5f582de80356019406e2975079bf0829dcommit-bot@chromium.orgAutocompleteClassifier* AutocompleteClassifierFactory::GetForProfile( 18c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org Profile* profile) { 19c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org return static_cast<AutocompleteClassifier*>( 20c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org GetInstance()->GetServiceForBrowserContext(profile, true)); 21c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org} 22c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org 238f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.org// static 24025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.orgAutocompleteClassifierFactory* AutocompleteClassifierFactory::GetInstance() { 25025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org return Singleton<AutocompleteClassifierFactory>::get(); 26025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org} 27025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org 28025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org// static 298f457e3230f1a4ce737f512ffbb5c919b8d02407commit-bot@chromium.orgBrowserContextKeyedService* AutocompleteClassifierFactory::BuildInstanceFor( 30025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org content::BrowserContext* profile) { 31025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org return new AutocompleteClassifier(static_cast<Profile*>(profile)); 32c2e9db30d393862bd3485cfe57b4ac06433f2f32commit-bot@chromium.org} 33c2e9db30d393862bd3485cfe57b4ac06433f2f32commit-bot@chromium.org 34c2e9db30d393862bd3485cfe57b4ac06433f2f32commit-bot@chromium.orgAutocompleteClassifierFactory::AutocompleteClassifierFactory() 35c2e9db30d393862bd3485cfe57b4ac06433f2f32commit-bot@chromium.org : BrowserContextKeyedServiceFactory( 36c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org "AutocompleteClassifier", 37025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org BrowserContextDependencyManager::GetInstance()) { 38c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org DependsOn(extensions::ExtensionSystemFactory::GetInstance()); 39c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org DependsOn(TemplateURLServiceFactory::GetInstance()); 40c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org // TODO(pkasting): Uncomment these once they exist. 41c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org // DependsOn(PrefServiceFactory::GetInstance()); 42c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org DependsOn(ShortcutsBackendFactory::GetInstance()); 43c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org} 44c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org 45c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.orgAutocompleteClassifierFactory::~AutocompleteClassifierFactory() { 46025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org} 47c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org 48c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.orgcontent::BrowserContext* AutocompleteClassifierFactory::GetBrowserContextToUse( 49c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org content::BrowserContext* context) const { 50c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org return chrome::GetBrowserContextRedirectedInIncognito(context); 51c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org} 52c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org 53c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.orgbool AutocompleteClassifierFactory::ServiceIsNULLWhileTesting() const { 54c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org return true; 55c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org} 56c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.org 57c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.orgBrowserContextKeyedService* 58c0b7e10c6a68f59e1653e6c18e6bc954b3c3f0cfcommit-bot@chromium.orgAutocompleteClassifierFactory::BuildServiceInstanceFor( 59d594dbec0407343b7ac13af9c4580ec5933ab060commit-bot@chromium.org content::BrowserContext* profile) const { 60d594dbec0407343b7ac13af9c4580ec5933ab060commit-bot@chromium.org return BuildInstanceFor(static_cast<Profile*>(profile)); 61025128811219dc45fd99b6c4d1d14f833cf7a26ecommit-bot@chromium.org} 62d594dbec0407343b7ac13af9c4580ec5933ab060commit-bot@chromium.org