OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import "ios/clean/chrome/browser/ui/overlays/overlay_service_factory.h" |
| 6 |
| 7 #include <memory> |
| 8 |
| 9 #include "base/logging.h" |
| 10 #include "base/memory/ptr_util.h" |
| 11 #include "base/memory/singleton.h" |
| 12 #include "components/keyed_service/ios/browser_state_dependency_manager.h" |
| 13 #include "ios/chrome/browser/browser_state/chrome_browser_state.h" |
| 14 #import "ios/clean/chrome/browser/ui/overlays/overlay_service_impl.h" |
| 15 #import "ios/shared/chrome/browser/ui/browser_list/browser_list.h" |
| 16 #import "ios/web/public/certificate_policy_cache.h" |
| 17 #import "ios/web/public/web_state/session_certificate_policy_cache.h" |
| 18 |
| 19 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 20 #error "This file requires ARC support." |
| 21 #endif |
| 22 |
| 23 // static |
| 24 OverlayService* OverlayServiceFactory::GetForBrowserState( |
| 25 ios::ChromeBrowserState* browser_state) { |
| 26 return static_cast<OverlayService*>( |
| 27 GetInstance()->GetServiceForBrowserState(browser_state, true)); |
| 28 } |
| 29 |
| 30 // static |
| 31 OverlayServiceFactory* OverlayServiceFactory::GetInstance() { |
| 32 return base::Singleton<OverlayServiceFactory>::get(); |
| 33 } |
| 34 |
| 35 OverlayServiceFactory::OverlayServiceFactory() |
| 36 : BrowserStateKeyedServiceFactory( |
| 37 "OverlayService", |
| 38 BrowserStateDependencyManager::GetInstance()) {} |
| 39 |
| 40 OverlayServiceFactory::~OverlayServiceFactory() {} |
| 41 |
| 42 std::unique_ptr<KeyedService> OverlayServiceFactory::BuildServiceInstanceFor( |
| 43 web::BrowserState* context) const { |
| 44 ios::ChromeBrowserState* browser_state = |
| 45 ios::ChromeBrowserState::FromBrowserState(context); |
| 46 // It is safe to use base::Unretained here as OverlayServiceImpl |
| 47 // will be destroyed before the ChromeBrowserState (as it is a KeyedService). |
| 48 return base::MakeUnique<OverlayServiceImpl>( |
| 49 BrowserList::FromBrowserState(browser_state)); |
| 50 } |
OLD | NEW |