OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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/subresource_filter/subresource_filter_profile_context_f
actory.h" | 5 #include "chrome/browser/subresource_filter/subresource_filter_profile_context_f
actory.h" |
6 | 6 |
7 #include "base/memory/singleton.h" | 7 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" |
8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/browser/subresource_filter/subresource_filter_profile_context.h
" | 10 #include "chrome/browser/subresource_filter/subresource_filter_profile_context.h
" |
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
11 #include "components/keyed_service/core/keyed_service.h" | 12 #include "components/keyed_service/core/keyed_service.h" |
12 | 13 |
13 // static | 14 // static |
14 void SubresourceFilterProfileContextFactory::EnsureForProfile( | 15 SubresourceFilterProfileContext* |
15 Profile* profile) { | 16 SubresourceFilterProfileContextFactory::GetForProfile(Profile* profile) { |
16 GetInstance()->GetServiceForBrowserContext(profile, true /* create */); | 17 return static_cast<SubresourceFilterProfileContext*>( |
| 18 GetInstance()->GetServiceForBrowserContext(profile, true /* create */)); |
17 } | 19 } |
18 | 20 |
19 // static | 21 // static |
20 SubresourceFilterProfileContextFactory* | 22 SubresourceFilterProfileContextFactory* |
21 SubresourceFilterProfileContextFactory::GetInstance() { | 23 SubresourceFilterProfileContextFactory::GetInstance() { |
22 return base::Singleton<SubresourceFilterProfileContextFactory>::get(); | 24 return base::Singleton<SubresourceFilterProfileContextFactory>::get(); |
23 } | 25 } |
24 | 26 |
25 SubresourceFilterProfileContextFactory::SubresourceFilterProfileContextFactory() | 27 SubresourceFilterProfileContextFactory::SubresourceFilterProfileContextFactory() |
26 : BrowserContextKeyedServiceFactory( | 28 : BrowserContextKeyedServiceFactory( |
27 "SubresourceFilterProfileContext", | 29 "SubresourceFilterProfileContext", |
28 BrowserContextDependencyManager::GetInstance()) {} | 30 BrowserContextDependencyManager::GetInstance()) {} |
29 | 31 |
30 KeyedService* SubresourceFilterProfileContextFactory::BuildServiceInstanceFor( | 32 KeyedService* SubresourceFilterProfileContextFactory::BuildServiceInstanceFor( |
31 content::BrowserContext* profile) const { | 33 content::BrowserContext* profile) const { |
32 return new SubresourceFilterProfileContext(static_cast<Profile*>(profile)); | 34 return new SubresourceFilterProfileContext(static_cast<Profile*>(profile)); |
33 } | 35 } |
| 36 |
| 37 content::BrowserContext* |
| 38 SubresourceFilterProfileContextFactory::GetBrowserContextToUse( |
| 39 content::BrowserContext* context) const { |
| 40 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 41 } |
OLD | NEW |