sammc@chromium.org | 961745f | 2013-05-25 14:09:24 | [diff] [blame] | 1 | // Copyright 2013 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 "apps/saved_files_service_factory.h" |
| 6 | |
| 7 | #include "apps/saved_files_service.h" |
blundell@chromium.org | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 8 | #include "components/keyed_service/content/browser_context_dependency_manager.h" |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 9 | #include "content/public/browser/browser_context.h" |
sammc@chromium.org | 961745f | 2013-05-25 14:09:24 | [diff] [blame] | 10 | |
| 11 | namespace apps { |
| 12 | |
| 13 | // static |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 14 | SavedFilesService* SavedFilesServiceFactory::GetForBrowserContext( |
| 15 | content::BrowserContext* context) { |
sammc@chromium.org | 961745f | 2013-05-25 14:09:24 | [diff] [blame] | 16 | return static_cast<SavedFilesService*>( |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 17 | GetInstance()->GetServiceForBrowserContext(context, true)); |
sammc@chromium.org | 961745f | 2013-05-25 14:09:24 | [diff] [blame] | 18 | } |
| 19 | |
| 20 | // static |
michaelpg | dbdcdcc | 2017-04-06 01:40:56 | [diff] [blame^] | 21 | SavedFilesService* SavedFilesServiceFactory::GetForBrowserContextIfExists( |
| 22 | content::BrowserContext* context) { |
| 23 | return static_cast<SavedFilesService*>( |
| 24 | GetInstance()->GetServiceForBrowserContext(context, false)); |
| 25 | } |
| 26 | |
| 27 | // static |
sammc@chromium.org | 961745f | 2013-05-25 14:09:24 | [diff] [blame] | 28 | SavedFilesServiceFactory* SavedFilesServiceFactory::GetInstance() { |
olli.raula | 36aa8be | 2015-09-10 11:14:22 | [diff] [blame] | 29 | return base::Singleton<SavedFilesServiceFactory>::get(); |
sammc@chromium.org | 961745f | 2013-05-25 14:09:24 | [diff] [blame] | 30 | } |
| 31 | |
| 32 | SavedFilesServiceFactory::SavedFilesServiceFactory() |
| 33 | : BrowserContextKeyedServiceFactory( |
| 34 | "SavedFilesService", |
| 35 | BrowserContextDependencyManager::GetInstance()) {} |
| 36 | |
| 37 | SavedFilesServiceFactory::~SavedFilesServiceFactory() {} |
| 38 | |
blundell@chromium.org | 12b7af3 | 2014-03-13 05:28:20 | [diff] [blame] | 39 | KeyedService* SavedFilesServiceFactory::BuildServiceInstanceFor( |
michaelpg | 4d80e56 | 2017-04-04 01:48:14 | [diff] [blame] | 40 | content::BrowserContext* context) const { |
| 41 | return new SavedFilesService(context); |
sammc@chromium.org | 961745f | 2013-05-25 14:09:24 | [diff] [blame] | 42 | } |
| 43 | |
| 44 | } // namespace apps |