OLD | NEW |
---|---|
(Empty) | |
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/extensions/extension_welcome_notification _factory.h" | |
6 | |
7 #include "chrome/browser/notifications/extensions/extension_welcome_notification .h" | |
8 #include "chrome/browser/profiles/incognito_helpers.h" | |
9 #include "chrome/browser/profiles/profile.h" | |
10 #include "components/keyed_service/content/browser_context_dependency_manager.h" | |
11 #include "content/public/browser/browser_thread.h" | |
12 | |
13 // static | |
14 ExtensionWelcomeNotification* | |
15 ExtensionWelcomeNotificationFactory::GetForBrowserContext( | |
16 content::BrowserContext* context) { | |
17 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
18 return static_cast<ExtensionWelcomeNotification*>( | |
19 GetInstance()->GetServiceForBrowserContext(context, true)); | |
20 } | |
21 | |
22 // static | |
23 ExtensionWelcomeNotificationFactory* | |
24 ExtensionWelcomeNotificationFactory::GetInstance() { | |
25 return Singleton<ExtensionWelcomeNotificationFactory>::get(); | |
26 } | |
27 | |
28 ExtensionWelcomeNotificationFactory::ExtensionWelcomeNotificationFactory() | |
29 : BrowserContextKeyedServiceFactory( | |
30 "ExtensionWelcomeNotification", | |
31 BrowserContextDependencyManager::GetInstance()) {} | |
Jun Mukai
2014/09/18 17:53:48
DependsOn(DesktopNotificationServiceFactory::GetIn
Peter Beverloo
2014/09/19 13:01:22
Done.
| |
32 | |
33 ExtensionWelcomeNotificationFactory::~ExtensionWelcomeNotificationFactory() {} | |
34 | |
35 KeyedService* ExtensionWelcomeNotificationFactory::BuildServiceInstanceFor( | |
36 content::BrowserContext* context) const { | |
37 scoped_ptr<ExtensionWelcomeNotification> welcome_notification = | |
38 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
| |
39 | |
40 return welcome_notification.release(); | |
41 } | |
42 | |
43 content::BrowserContext* | |
44 ExtensionWelcomeNotificationFactory::GetBrowserContextToUse( | |
45 content::BrowserContext* context) const { | |
46 return chrome::GetBrowserContextOwnInstanceInIncognito(context); | |
47 } | |
OLD | NEW |