summaryrefslogtreecommitdiffstats
path: root/chrome/browser/notifications/extension_welcome_notification_factory.cc
blob: 0402eb6a0ac60c41c603731f987f820ad59e3b0a (plain)
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
// Copyright 2014 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/notifications/extension_welcome_notification_factory.h"

#include "chrome/browser/notifications/extension_welcome_notification.h"
#include "chrome/browser/notifications/notifier_state_tracker_factory.h"
#include "chrome/browser/profiles/incognito_helpers.h"
#include "chrome/browser/profiles/profile.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
#include "content/public/browser/browser_thread.h"

// static
ExtensionWelcomeNotification*
ExtensionWelcomeNotificationFactory::GetForBrowserContext(
    content::BrowserContext* context) {
  DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
  return static_cast<ExtensionWelcomeNotification*>(
      GetInstance()->GetServiceForBrowserContext(context, true));
}

// static
ExtensionWelcomeNotificationFactory*
ExtensionWelcomeNotificationFactory::GetInstance() {
  return base::Singleton<ExtensionWelcomeNotificationFactory>::get();
}

ExtensionWelcomeNotificationFactory::ExtensionWelcomeNotificationFactory()
    : BrowserContextKeyedServiceFactory(
        "ExtensionWelcomeNotification",
        BrowserContextDependencyManager::GetInstance()) {
  DependsOn(NotifierStateTrackerFactory::GetInstance());
}

ExtensionWelcomeNotificationFactory::~ExtensionWelcomeNotificationFactory() {}

KeyedService* ExtensionWelcomeNotificationFactory::BuildServiceInstanceFor(
    content::BrowserContext* context) const {
  return ExtensionWelcomeNotification::Create(static_cast<Profile*>(context));
}

content::BrowserContext*
ExtensionWelcomeNotificationFactory::GetBrowserContextToUse(
    content::BrowserContext* context) const {
  return chrome::GetBrowserContextOwnInstanceInIncognito(context);
}