Home | History | Annotate | Download | only in notifications
      1 // Copyright 2014 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/notifications/extension_welcome_notification_factory.h"
      6 
      7 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
      8 #include "chrome/browser/notifications/extension_welcome_notification.h"
      9 #include "chrome/browser/profiles/incognito_helpers.h"
     10 #include "chrome/browser/profiles/profile.h"
     11 #include "components/keyed_service/content/browser_context_dependency_manager.h"
     12 #include "content/public/browser/browser_thread.h"
     13 
     14 // static
     15 ExtensionWelcomeNotification*
     16 ExtensionWelcomeNotificationFactory::GetForBrowserContext(
     17     content::BrowserContext* context) {
     18   DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
     19   return static_cast<ExtensionWelcomeNotification*>(
     20       GetInstance()->GetServiceForBrowserContext(context, true));
     21 }
     22 
     23 // static
     24 ExtensionWelcomeNotificationFactory*
     25 ExtensionWelcomeNotificationFactory::GetInstance() {
     26   return Singleton<ExtensionWelcomeNotificationFactory>::get();
     27 }
     28 
     29 ExtensionWelcomeNotificationFactory::ExtensionWelcomeNotificationFactory()
     30     : BrowserContextKeyedServiceFactory(
     31         "ExtensionWelcomeNotification",
     32         BrowserContextDependencyManager::GetInstance()) {
     33   DependsOn(DesktopNotificationServiceFactory::GetInstance());
     34 }
     35 
     36 ExtensionWelcomeNotificationFactory::~ExtensionWelcomeNotificationFactory() {}
     37 
     38 KeyedService* ExtensionWelcomeNotificationFactory::BuildServiceInstanceFor(
     39     content::BrowserContext* context) const {
     40   return ExtensionWelcomeNotification::Create(static_cast<Profile*>(context));
     41 }
     42 
     43 content::BrowserContext*
     44 ExtensionWelcomeNotificationFactory::GetBrowserContextToUse(
     45     content::BrowserContext* context) const {
     46   return chrome::GetBrowserContextOwnInstanceInIncognito(context);
     47 }
     48