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
3 // found in the LICENSE file.
5 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate_factory.h"
7 #include "base/memory/scoped_ptr.h"
8 #include "chrome/browser/profiles/incognito_helpers.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ssl/chrome_ssl_host_state_delegate.h"
11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
12 #include "components/keyed_service/content/browser_context_keyed_service_factory.h"
16 class Service : public KeyedService {
18 explicit Service(Profile* profile)
19 : decisions_(new ChromeSSLHostStateDelegate(profile)) {}
21 ChromeSSLHostStateDelegate* decisions() { return decisions_.get(); }
23 virtual void Shutdown() OVERRIDE {}
26 scoped_ptr<ChromeSSLHostStateDelegate> decisions_;
28 DISALLOW_COPY_AND_ASSIGN(Service);
34 ChromeSSLHostStateDelegate* ChromeSSLHostStateDelegateFactory::GetForProfile(
36 return static_cast<Service*>(GetInstance()->GetServiceForBrowserContext(
37 profile, true))->decisions();
41 ChromeSSLHostStateDelegateFactory*
42 ChromeSSLHostStateDelegateFactory::GetInstance() {
43 return Singleton<ChromeSSLHostStateDelegateFactory>::get();
46 ChromeSSLHostStateDelegateFactory::ChromeSSLHostStateDelegateFactory()
47 : BrowserContextKeyedServiceFactory(
48 "ChromeSSLHostStateDelegate",
49 BrowserContextDependencyManager::GetInstance()) {
52 ChromeSSLHostStateDelegateFactory::~ChromeSSLHostStateDelegateFactory() {
55 KeyedService* ChromeSSLHostStateDelegateFactory::BuildServiceInstanceFor(
56 content::BrowserContext* profile) const {
57 return new Service(static_cast<Profile*>(profile));
60 void ChromeSSLHostStateDelegateFactory::RegisterProfilePrefs(
61 user_prefs::PrefRegistrySyncable* registry) {
64 content::BrowserContext*
65 ChromeSSLHostStateDelegateFactory::GetBrowserContextToUse(
66 content::BrowserContext* context) const {
67 return chrome::GetBrowserContextOwnInstanceInIncognito(context);