1 // Copyright 2019 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/chromeos/crostini/ansible/ansible_management_service_factory.h"
6 
7 #include "chrome/browser/chromeos/crostini/ansible/ansible_management_service.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "components/keyed_service/content/browser_context_dependency_manager.h"
10 
11 namespace crostini {
12 
13 // static
GetForProfile(Profile * profile)14 AnsibleManagementService* AnsibleManagementServiceFactory::GetForProfile(
15     Profile* profile) {
16   return static_cast<AnsibleManagementService*>(
17       GetInstance()->GetServiceForBrowserContext(profile, true));
18 }
19 
20 // static
21 AnsibleManagementServiceFactory*
GetInstance()22 AnsibleManagementServiceFactory::GetInstance() {
23   static base::NoDestructor<AnsibleManagementServiceFactory> factory;
24   return factory.get();
25 }
26 
AnsibleManagementServiceFactory()27 AnsibleManagementServiceFactory::AnsibleManagementServiceFactory()
28     : BrowserContextKeyedServiceFactory(
29           "AnsibleManagementService",
30           BrowserContextDependencyManager::GetInstance()) {}
31 
32 AnsibleManagementServiceFactory::~AnsibleManagementServiceFactory() = default;
33 
34 // BrowserContextKeyedServiceFactory:
BuildServiceInstanceFor(content::BrowserContext * context) const35 KeyedService* AnsibleManagementServiceFactory::BuildServiceInstanceFor(
36     content::BrowserContext* context) const {
37   Profile* profile = Profile::FromBrowserContext(context);
38   return new AnsibleManagementService(profile);
39 }
40 
41 }  // namespace crostini
42