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/search_engines/template_url_service_factory.h" | 5 #include "chrome/browser/search_engines/template_url_service_factory.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
12 #include "chrome/browser/google/google_url_tracker_factory.h" | 12 #include "chrome/browser/google/google_url_tracker_factory.h" |
13 #include "chrome/browser/history/history_service_factory.h" | 13 #include "chrome/browser/history/history_service_factory.h" |
14 #include "chrome/browser/profiles/incognito_helpers.h" | 14 #include "chrome/browser/profiles/incognito_helpers.h" |
15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
16 #include "chrome/browser/rlz/rlz.h" | |
17 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" | 16 #include "chrome/browser/search_engines/chrome_template_url_service_client.h" |
18 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 17 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
19 #include "chrome/browser/web_data_service_factory.h" | 18 #include "chrome/browser/web_data_service_factory.h" |
20 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 19 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
21 #include "components/pref_registry/pref_registry_syncable.h" | 20 #include "components/pref_registry/pref_registry_syncable.h" |
22 #include "components/search_engines/default_search_manager.h" | 21 #include "components/search_engines/default_search_manager.h" |
23 #include "components/search_engines/search_engines_pref_names.h" | 22 #include "components/search_engines/search_engines_pref_names.h" |
24 #include "components/search_engines/template_url_service.h" | 23 #include "components/search_engines/template_url_service.h" |
25 | 24 |
| 25 #if defined(ENABLE_RLZ) |
| 26 #include "components/rlz/rlz_tracker.h" |
| 27 #endif |
| 28 |
26 // static | 29 // static |
27 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { | 30 TemplateURLService* TemplateURLServiceFactory::GetForProfile(Profile* profile) { |
28 return static_cast<TemplateURLService*>( | 31 return static_cast<TemplateURLService*>( |
29 GetInstance()->GetServiceForBrowserContext(profile, true)); | 32 GetInstance()->GetServiceForBrowserContext(profile, true)); |
30 } | 33 } |
31 | 34 |
32 // static | 35 // static |
33 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { | 36 TemplateURLServiceFactory* TemplateURLServiceFactory::GetInstance() { |
34 return Singleton<TemplateURLServiceFactory>::get(); | 37 return Singleton<TemplateURLServiceFactory>::get(); |
35 } | 38 } |
36 | 39 |
37 // static | 40 // static |
38 scoped_ptr<KeyedService> TemplateURLServiceFactory::BuildInstanceFor( | 41 scoped_ptr<KeyedService> TemplateURLServiceFactory::BuildInstanceFor( |
39 content::BrowserContext* context) { | 42 content::BrowserContext* context) { |
40 base::Closure dsp_change_callback; | 43 base::Closure dsp_change_callback; |
41 #if defined(ENABLE_RLZ) | 44 #if defined(ENABLE_RLZ) |
42 dsp_change_callback = | 45 dsp_change_callback = base::Bind( |
43 base::Bind(base::IgnoreResult(&RLZTracker::RecordProductEvent), | 46 base::IgnoreResult(&rlz::RLZTracker::RecordProductEvent), rlz_lib::CHROME, |
44 rlz_lib::CHROME, | 47 rlz::RLZTracker::ChromeOmnibox(), rlz_lib::SET_TO_GOOGLE); |
45 RLZTracker::ChromeOmnibox(), | |
46 rlz_lib::SET_TO_GOOGLE); | |
47 #endif | 48 #endif |
48 Profile* profile = static_cast<Profile*>(context); | 49 Profile* profile = static_cast<Profile*>(context); |
49 return make_scoped_ptr(new TemplateURLService( | 50 return make_scoped_ptr(new TemplateURLService( |
50 profile->GetPrefs(), | 51 profile->GetPrefs(), |
51 scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)), | 52 scoped_ptr<SearchTermsData>(new UIThreadSearchTermsData(profile)), |
52 WebDataServiceFactory::GetKeywordWebDataForProfile( | 53 WebDataServiceFactory::GetKeywordWebDataForProfile( |
53 profile, ServiceAccessType::EXPLICIT_ACCESS), | 54 profile, ServiceAccessType::EXPLICIT_ACCESS), |
54 scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient( | 55 scoped_ptr<TemplateURLServiceClient>(new ChromeTemplateURLServiceClient( |
55 HistoryServiceFactory::GetForProfile( | 56 HistoryServiceFactory::GetForProfile( |
56 profile, ServiceAccessType::EXPLICIT_ACCESS))), | 57 profile, ServiceAccessType::EXPLICIT_ACCESS))), |
(...skipping 24 matching lines...) Expand all Loading... |
81 } | 82 } |
82 | 83 |
83 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( | 84 content::BrowserContext* TemplateURLServiceFactory::GetBrowserContextToUse( |
84 content::BrowserContext* context) const { | 85 content::BrowserContext* context) const { |
85 return chrome::GetBrowserContextRedirectedInIncognito(context); | 86 return chrome::GetBrowserContextRedirectedInIncognito(context); |
86 } | 87 } |
87 | 88 |
88 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { | 89 bool TemplateURLServiceFactory::ServiceIsNULLWhileTesting() const { |
89 return true; | 90 return true; |
90 } | 91 } |
OLD | NEW |