cygprofile: increase timeouts to allow showing web contents
[chromium-blink-merge.git] / ios / chrome / browser / autocomplete / autocomplete_classifier_factory.cc
blob7696b1e4739d7886744671ab5f04d2c598e094d0
1 // Copyright 2015 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 "ios/chrome/browser/autocomplete/autocomplete_classifier_factory.h"
7 #include "base/memory/singleton.h"
8 #include "components/keyed_service/ios/browser_state_dependency_manager.h"
9 #include "components/omnibox/browser/autocomplete_classifier.h"
10 #include "components/omnibox/browser/autocomplete_controller.h"
11 #include "ios/chrome/browser/autocomplete/autocomplete_provider_client_impl.h"
12 #include "ios/chrome/browser/autocomplete/autocomplete_scheme_classifier_impl.h"
13 #include "ios/chrome/browser/autocomplete/in_memory_url_index_factory.h"
14 #include "ios/chrome/browser/autocomplete/shortcuts_backend_factory.h"
15 #include "ios/chrome/browser/browser_state/browser_state_otr_helper.h"
16 #include "ios/chrome/browser/search_engines/template_url_service_factory.h"
17 #include "ios/public/provider/chrome/browser/browser_state/chrome_browser_state.h"
19 namespace ios {
20 namespace {
22 scoped_ptr<KeyedService> BuildAutocompleteClassifier(
23 web::BrowserState* context) {
24 ios::ChromeBrowserState* browser_state =
25 ios::ChromeBrowserState::FromBrowserState(context);
26 return make_scoped_ptr(new AutocompleteClassifier(
27 make_scoped_ptr(new AutocompleteController(
28 make_scoped_ptr(new AutocompleteProviderClientImpl(browser_state)),
29 nullptr, AutocompleteClassifier::kDefaultOmniboxProviders)),
30 make_scoped_ptr(new AutocompleteSchemeClassifierImpl)));
33 } // namespace
35 // static
36 AutocompleteClassifier* AutocompleteClassifierFactory::GetForBrowserState(
37 ios::ChromeBrowserState* browser_state) {
38 return static_cast<AutocompleteClassifier*>(
39 GetInstance()->GetServiceForBrowserState(browser_state, true));
42 // static
43 AutocompleteClassifierFactory* AutocompleteClassifierFactory::GetInstance() {
44 return Singleton<AutocompleteClassifierFactory>::get();
47 // static
48 BrowserStateKeyedServiceFactory::TestingFactoryFunction
49 AutocompleteClassifierFactory::GetDefaultFactory() {
50 return &BuildAutocompleteClassifier;
53 AutocompleteClassifierFactory::AutocompleteClassifierFactory()
54 : BrowserStateKeyedServiceFactory(
55 "AutocompleteClassifier",
56 BrowserStateDependencyManager::GetInstance()) {
57 DependsOn(ios::InMemoryURLIndexFactory::GetInstance());
58 DependsOn(ios::TemplateURLServiceFactory::GetInstance());
59 DependsOn(ios::ShortcutsBackendFactory::GetInstance());
62 AutocompleteClassifierFactory::~AutocompleteClassifierFactory() {}
64 scoped_ptr<KeyedService> AutocompleteClassifierFactory::BuildServiceInstanceFor(
65 web::BrowserState* context) const {
66 return BuildAutocompleteClassifier(context);
69 web::BrowserState* AutocompleteClassifierFactory::GetBrowserStateToUse(
70 web::BrowserState* context) const {
71 return GetBrowserStateRedirectedInIncognito(context);
74 bool AutocompleteClassifierFactory::ServiceIsNULLWhileTesting() const {
75 return true;
78 } // namespace ios