OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/suggestions/suggestions_service_factory.h" | 5 #include "chrome/browser/search/suggestions/suggestions_service_factory.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/incognito_helpers.h" | 9 #include "chrome/browser/profiles/incognito_helpers.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "components/suggestions/suggestions_store.h" | 21 #include "components/suggestions/suggestions_store.h" |
22 #include "content/public/browser/browser_context.h" | 22 #include "content/public/browser/browser_context.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 | 24 |
25 using content::BrowserThread; | 25 using content::BrowserThread; |
26 | 26 |
27 namespace suggestions { | 27 namespace suggestions { |
28 | 28 |
29 // static | 29 // static |
30 SuggestionsService* SuggestionsServiceFactory::GetForProfile(Profile* profile) { | 30 SuggestionsService* SuggestionsServiceFactory::GetForProfile(Profile* profile) { |
31 if (profile->IsOffTheRecord()) | |
32 return NULL; | |
33 | |
34 return static_cast<SuggestionsService*>( | 31 return static_cast<SuggestionsService*>( |
35 GetInstance()->GetServiceForBrowserContext(profile, true)); | 32 GetInstance()->GetServiceForBrowserContext(profile, true)); |
36 } | 33 } |
37 | 34 |
38 // static | 35 // static |
39 SuggestionsServiceFactory* SuggestionsServiceFactory::GetInstance() { | 36 SuggestionsServiceFactory* SuggestionsServiceFactory::GetInstance() { |
40 return Singleton<SuggestionsServiceFactory>::get(); | 37 return Singleton<SuggestionsServiceFactory>::get(); |
41 } | 38 } |
42 | 39 |
43 SuggestionsServiceFactory::SuggestionsServiceFactory() | 40 SuggestionsServiceFactory::SuggestionsServiceFactory() |
44 : BrowserContextKeyedServiceFactory( | 41 : BrowserContextKeyedServiceFactory( |
45 "SuggestionsService", | 42 "SuggestionsService", |
46 BrowserContextDependencyManager::GetInstance()) { | 43 BrowserContextDependencyManager::GetInstance()) { |
47 // No dependencies. | 44 // No dependencies. |
48 } | 45 } |
49 | 46 |
50 SuggestionsServiceFactory::~SuggestionsServiceFactory() {} | 47 SuggestionsServiceFactory::~SuggestionsServiceFactory() {} |
51 | 48 |
52 content::BrowserContext* SuggestionsServiceFactory::GetBrowserContextToUse( | |
53 content::BrowserContext* context) const { | |
54 return chrome::GetBrowserContextRedirectedInIncognito(context); | |
55 } | |
56 | |
57 KeyedService* SuggestionsServiceFactory::BuildServiceInstanceFor( | 49 KeyedService* SuggestionsServiceFactory::BuildServiceInstanceFor( |
58 content::BrowserContext* profile) const { | 50 content::BrowserContext* profile) const { |
59 scoped_refptr<base::SequencedTaskRunner> background_task_runner = | 51 scoped_refptr<base::SequencedTaskRunner> background_task_runner = |
60 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( | 52 BrowserThread::GetBlockingPool()->GetSequencedTaskRunner( |
61 BrowserThread::GetBlockingPool()->GetSequenceToken()); | 53 BrowserThread::GetBlockingPool()->GetSequenceToken()); |
62 | 54 |
63 Profile* the_profile = static_cast<Profile*>(profile); | 55 Profile* the_profile = static_cast<Profile*>(profile); |
64 scoped_ptr<SuggestionsStore> suggestions_store( | 56 scoped_ptr<SuggestionsStore> suggestions_store( |
65 new SuggestionsStore(the_profile->GetPrefs())); | 57 new SuggestionsStore(the_profile->GetPrefs())); |
66 scoped_ptr<BlacklistStore> blacklist_store( | 58 scoped_ptr<BlacklistStore> blacklist_store( |
(...skipping 13 matching lines...) Expand all Loading... |
80 the_profile->GetRequestContext(), suggestions_store.Pass(), | 72 the_profile->GetRequestContext(), suggestions_store.Pass(), |
81 thumbnail_manager.Pass(), blacklist_store.Pass()); | 73 thumbnail_manager.Pass(), blacklist_store.Pass()); |
82 } | 74 } |
83 | 75 |
84 void SuggestionsServiceFactory::RegisterProfilePrefs( | 76 void SuggestionsServiceFactory::RegisterProfilePrefs( |
85 user_prefs::PrefRegistrySyncable* registry) { | 77 user_prefs::PrefRegistrySyncable* registry) { |
86 SuggestionsService::RegisterProfilePrefs(registry); | 78 SuggestionsService::RegisterProfilePrefs(registry); |
87 } | 79 } |
88 | 80 |
89 } // namespace suggestions | 81 } // namespace suggestions |
OLD | NEW |