1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
|
// Copyright 2019 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/notifications/platform_notification_service_factory.h"
#include <memory>
#include "base/memory/ptr_util.h"
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
#include "chrome/browser/metrics/ukm_background_recorder_service.h"
#include "chrome/browser/notifications/metrics/notification_metrics_logger_factory.h"
#include "chrome/browser/notifications/notification_display_service_factory.h"
#include "chrome/browser/notifications/platform_notification_service_impl.h"
#include "chrome/browser/profiles/profile.h"
// static
PlatformNotificationServiceImpl*
PlatformNotificationServiceFactory::GetForProfile(Profile* profile) {
return static_cast<PlatformNotificationServiceImpl*>(
GetInstance()->GetServiceForBrowserContext(profile, /* create= */ true));
}
// static
PlatformNotificationServiceFactory*
PlatformNotificationServiceFactory::GetInstance() {
static base::NoDestructor<PlatformNotificationServiceFactory> instance;
return instance.get();
}
PlatformNotificationServiceFactory::PlatformNotificationServiceFactory()
: ProfileKeyedServiceFactory(
"PlatformNotificationService",
ProfileSelections::Builder()
.WithRegular(ProfileSelection::kOwnInstance)
// TODO(crbug.com/40257657): Check if this service is needed in
// Guest mode.
.WithGuest(ProfileSelection::kOwnInstance)
// TODO(crbug.com/41488885): Check if this service is needed for
// Ash Internals.
.WithAshInternals(ProfileSelection::kOwnInstance)
.Build()) {
DependsOn(HostContentSettingsMapFactory::GetInstance());
DependsOn(NotificationDisplayServiceFactory::GetInstance());
DependsOn(NotificationMetricsLoggerFactory::GetInstance());
DependsOn(ukm::UkmBackgroundRecorderFactory::GetInstance());
}
std::unique_ptr<KeyedService>
PlatformNotificationServiceFactory::BuildServiceInstanceForBrowserContext(
content::BrowserContext* context) const {
return std::make_unique<PlatformNotificationServiceImpl>(
Profile::FromBrowserContext(context));
}
|