blob: f170b691ec07add70635396010c5cb24f0285278 [file] [log] [blame]
Avi Drissman4a8573c2022-09-09 19:35:541// Copyright 2022 The Chromium Authors
Kamila1c047fd2022-05-13 17:20:362// 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/permissions/notifications_engagement_service_factory.h"
6
7#include "base/memory/singleton.h"
8#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
9#include "chrome/browser/profiles/profile.h"
Kamila1c047fd2022-05-13 17:20:3610#include "components/permissions/notifications_engagement_service.h"
11
12// static
13NotificationsEngagementServiceFactory*
14NotificationsEngagementServiceFactory::GetInstance() {
15 return base::Singleton<NotificationsEngagementServiceFactory>::get();
16}
17
18// static
19permissions::NotificationsEngagementService*
20NotificationsEngagementServiceFactory::GetForProfile(Profile* profile) {
21 return static_cast<permissions::NotificationsEngagementService*>(
22 GetInstance()->GetServiceForBrowserContext(profile, true));
23}
24
25NotificationsEngagementServiceFactory::NotificationsEngagementServiceFactory()
Ryan Sultanem9cc258162023-02-24 11:18:3426 : ProfileKeyedServiceFactory(
27 "NotificationsEngagementService",
28 ProfileSelections::Builder()
29 .WithRegular(ProfileSelection::kOriginalOnly)
30 // TODO(crbug.com/1418376): Check if this service is needed in
31 // Guest mode.
32 .WithGuest(ProfileSelection::kOriginalOnly)
33 .Build()) {
Kamila1c047fd2022-05-13 17:20:3634 DependsOn(HostContentSettingsMapFactory::GetInstance());
35}
36
37NotificationsEngagementServiceFactory::
38 ~NotificationsEngagementServiceFactory() = default;
39
40KeyedService* NotificationsEngagementServiceFactory::BuildServiceInstanceFor(
41 content::BrowserContext* context) const {
42 Profile* profile = Profile::FromBrowserContext(context);
43 return new permissions::NotificationsEngagementService(context,
44 profile->GetPrefs());
45}