OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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. |
| 4 |
| 5 #include "chrome/browser/ssl/chrome_ssl_host_state_decisions_factory.h" |
| 6 |
| 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_decisions.h" |
| 11 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 12 #include "components/keyed_service/content/browser_context_keyed_service_factory
.h" |
| 13 |
| 14 namespace { |
| 15 |
| 16 class Service : public KeyedService { |
| 17 public: |
| 18 explicit Service(Profile* profile) |
| 19 : decisions_(new ChromeSSLHostStateDecisions(profile)) {} |
| 20 |
| 21 ChromeSSLHostStateDecisions* decisions() { return decisions_.get(); } |
| 22 |
| 23 virtual void Shutdown() OVERRIDE { decisions_->ShutdownOnUIThread(); } |
| 24 |
| 25 private: |
| 26 scoped_ptr<ChromeSSLHostStateDecisions> decisions_; |
| 27 |
| 28 DISALLOW_COPY_AND_ASSIGN(Service); |
| 29 }; |
| 30 |
| 31 } // namespace |
| 32 |
| 33 // static |
| 34 ChromeSSLHostStateDecisions* ChromeSSLHostStateDecisionsFactory::GetForProfile( |
| 35 Profile* profile) { |
| 36 return static_cast<Service*>(GetInstance()->GetServiceForBrowserContext( |
| 37 profile, true))->decisions(); |
| 38 } |
| 39 |
| 40 // static |
| 41 ChromeSSLHostStateDecisionsFactory* |
| 42 ChromeSSLHostStateDecisionsFactory::GetInstance() { |
| 43 return Singleton<ChromeSSLHostStateDecisionsFactory>::get(); |
| 44 } |
| 45 |
| 46 ChromeSSLHostStateDecisionsFactory::ChromeSSLHostStateDecisionsFactory() |
| 47 : BrowserContextKeyedServiceFactory( |
| 48 "ChromeSSLHostStateDecisions", |
| 49 BrowserContextDependencyManager::GetInstance()) { |
| 50 } |
| 51 |
| 52 ChromeSSLHostStateDecisionsFactory::~ChromeSSLHostStateDecisionsFactory() { |
| 53 } |
| 54 |
| 55 KeyedService* ChromeSSLHostStateDecisionsFactory::BuildServiceInstanceFor( |
| 56 content::BrowserContext* profile) const { |
| 57 return new Service(static_cast<Profile*>(profile)); |
| 58 } |
| 59 |
| 60 void ChromeSSLHostStateDecisionsFactory::RegisterProfilePrefs( |
| 61 user_prefs::PrefRegistrySyncable* registry) { |
| 62 } |
| 63 |
| 64 content::BrowserContext* |
| 65 ChromeSSLHostStateDecisionsFactory::GetBrowserContextToUse( |
| 66 content::BrowserContext* context) const { |
| 67 return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| 68 } |
OLD | NEW |