1 // Copyright 2018 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/crostini_mime_types_service_factory.h"
6 
7 #include "chrome/browser/chromeos/crostini/crostini_mime_types_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 CrostiniMimeTypesService* CrostiniMimeTypesServiceFactory::GetForProfile(
15     Profile* profile) {
16   return static_cast<CrostiniMimeTypesService*>(
17       GetInstance()->GetServiceForBrowserContext(profile, true));
18 }
19 
20 // static
21 CrostiniMimeTypesServiceFactory*
GetInstance()22 CrostiniMimeTypesServiceFactory::GetInstance() {
23   static base::NoDestructor<CrostiniMimeTypesServiceFactory> factory;
24   return factory.get();
25 }
26 
CrostiniMimeTypesServiceFactory()27 CrostiniMimeTypesServiceFactory::CrostiniMimeTypesServiceFactory()
28     : BrowserContextKeyedServiceFactory(
29           "CrostiniMimeTypesService",
30           BrowserContextDependencyManager::GetInstance()) {}
31 
32 CrostiniMimeTypesServiceFactory::~CrostiniMimeTypesServiceFactory() = default;
33 
BuildServiceInstanceFor(content::BrowserContext * context) const34 KeyedService* CrostiniMimeTypesServiceFactory::BuildServiceInstanceFor(
35     content::BrowserContext* context) const {
36   Profile* profile = Profile::FromBrowserContext(context);
37   return new CrostiniMimeTypesService(profile);
38 }
39 
40 }  // namespace crostini
41