Chromium Code Reviews| Index: chrome/browser/notifications/extensions/extension_welcome_notification_factory.cc |
| diff --git a/chrome/browser/notifications/extensions/extension_welcome_notification_factory.cc b/chrome/browser/notifications/extensions/extension_welcome_notification_factory.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..7f10fbbe065baed1ac04428bfe387b5804ebf437 |
| --- /dev/null |
| +++ b/chrome/browser/notifications/extensions/extension_welcome_notification_factory.cc |
| @@ -0,0 +1,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/extensions/extension_welcome_notification_factory.h" |
| + |
| +#include "chrome/browser/notifications/extensions/extension_welcome_notification.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(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| + return static_cast<ExtensionWelcomeNotification*>( |
| + GetInstance()->GetServiceForBrowserContext(context, true)); |
| +} |
| + |
| +// static |
| +ExtensionWelcomeNotificationFactory* |
| +ExtensionWelcomeNotificationFactory::GetInstance() { |
| + return Singleton<ExtensionWelcomeNotificationFactory>::get(); |
| +} |
| + |
| +ExtensionWelcomeNotificationFactory::ExtensionWelcomeNotificationFactory() |
| + : BrowserContextKeyedServiceFactory( |
| + "ExtensionWelcomeNotification", |
| + BrowserContextDependencyManager::GetInstance()) {} |
|
Jun Mukai
2014/09/18 17:53:48
DependsOn(DesktopNotificationServiceFactory::GetIn
Peter Beverloo
2014/09/19 13:01:22
Done.
|
| + |
| +ExtensionWelcomeNotificationFactory::~ExtensionWelcomeNotificationFactory() {} |
| + |
| +KeyedService* ExtensionWelcomeNotificationFactory::BuildServiceInstanceFor( |
| + content::BrowserContext* context) const { |
| + scoped_ptr<ExtensionWelcomeNotification> welcome_notification = |
| + ExtensionWelcomeNotification::Create(static_cast<Profile*>(context)); |
|
Jun Mukai
2014/09/18 17:53:48
It's better to cleanup the initialization -- chang
Peter Beverloo
2014/09/19 13:01:22
I'm inclined to disagree. Returning a scoped_ptr i
|
| + |
| + return welcome_notification.release(); |
| +} |
| + |
| +content::BrowserContext* |
| +ExtensionWelcomeNotificationFactory::GetBrowserContextToUse( |
| + content::BrowserContext* context) const { |
| + return chrome::GetBrowserContextOwnInstanceInIncognito(context); |
| +} |