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 #include "chrome/browser/offline_items_collection/offline_content_aggregator_fac
tory.h" |
| 6 |
| 7 #include "base/memory/singleton.h" |
| 8 #include "chrome/browser/profiles/incognito_helpers.h" |
| 9 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 10 #include "components/offline_items_collection/core/offline_content_aggregator.h" |
| 11 #include "content/public/browser/browser_context.h" |
| 12 |
| 13 namespace offline_items_collection { |
| 14 |
| 15 // static |
| 16 OfflineContentAggregatorFactory* |
| 17 OfflineContentAggregatorFactory::GetInstance() { |
| 18 return base::Singleton<OfflineContentAggregatorFactory>::get(); |
| 19 } |
| 20 |
| 21 // static |
| 22 OfflineContentAggregator* OfflineContentAggregatorFactory::GetForBrowserContext( |
| 23 content::BrowserContext* context) { |
| 24 DCHECK(!context->IsOffTheRecord()); |
| 25 return static_cast<offline_items_collection::OfflineContentAggregator*>( |
| 26 GetInstance()->GetServiceForBrowserContext(context, true)); |
| 27 } |
| 28 |
| 29 OfflineContentAggregatorFactory::OfflineContentAggregatorFactory() |
| 30 : BrowserContextKeyedServiceFactory( |
| 31 "offline_items_collection::OfflineContentAggregator", |
| 32 BrowserContextDependencyManager::GetInstance()) {} |
| 33 |
| 34 OfflineContentAggregatorFactory::~OfflineContentAggregatorFactory() = default; |
| 35 |
| 36 KeyedService* OfflineContentAggregatorFactory::BuildServiceInstanceFor( |
| 37 content::BrowserContext* context) const { |
| 38 return new offline_items_collection::OfflineContentAggregator(); |
| 39 } |
| 40 |
| 41 content::BrowserContext* |
| 42 OfflineContentAggregatorFactory::GetBrowserContextToUse( |
| 43 content::BrowserContext* context) const { |
| 44 return chrome::GetBrowserContextRedirectedInIncognito(context); |
| 45 } |
| 46 |
| 47 } // namespace offline_items_collection |
OLD | NEW |