blob: 31935d00120c8f57f5d7be1df89be41040a7a4fd [file] [log] [blame]
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/offline_items_collection/offline_content_aggregator_factory.h"
#include "base/memory/singleton.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "components/offline_items_collection/core/offline_content_aggregator.h"
#include "content/public/browser/browser_context.h"
// static
OfflineContentAggregatorFactory*
OfflineContentAggregatorFactory::GetInstance() {
return base::Singleton<OfflineContentAggregatorFactory>::get();
}
// static
offline_items_collection::OfflineContentAggregator*
OfflineContentAggregatorFactory::GetForBrowserContext(
content::BrowserContext* context) {
return static_cast<offline_items_collection::OfflineContentAggregator*>(
GetInstance()->GetServiceForBrowserContext(context, true));
}
OfflineContentAggregatorFactory::OfflineContentAggregatorFactory()
: BrowserContextKeyedServiceFactory(
"offline_items_collection::OfflineContentAggregator",
BrowserContextDependencyManager::GetInstance()) {}
OfflineContentAggregatorFactory::~OfflineContentAggregatorFactory() = default;
KeyedService* OfflineContentAggregatorFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
DCHECK(!context->IsOffTheRecord());
return new offline_items_collection::OfflineContentAggregator();
}
content::BrowserContext*
OfflineContentAggregatorFactory::GetBrowserContextToUse(
content::BrowserContext* context) const {
return chrome::GetBrowserContextRedirectedInIncognito(context);
}