• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2013 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/drive/drive_notification_manager_factory.h"
6 
7 #include "chrome/browser/drive/drive_notification_manager.h"
8 #include "chrome/browser/invalidation/invalidation_service_factory.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/sync/profile_sync_service.h"
11 #include "chrome/browser/sync/profile_sync_service_factory.h"
12 #include "components/browser_context_keyed_service/browser_context_dependency_manager.h"
13 
14 namespace drive {
15 
16 // static
17 DriveNotificationManager*
GetForBrowserContext(content::BrowserContext * context)18 DriveNotificationManagerFactory::GetForBrowserContext(
19     content::BrowserContext* context) {
20   if (!ProfileSyncService::IsSyncEnabled())
21     return NULL;
22 
23   return static_cast<DriveNotificationManager*>(
24       GetInstance()->GetServiceForBrowserContext(context, true));
25 }
26 
27 // static
28 DriveNotificationManagerFactory*
GetInstance()29 DriveNotificationManagerFactory::GetInstance() {
30   return Singleton<DriveNotificationManagerFactory>::get();
31 }
32 
DriveNotificationManagerFactory()33 DriveNotificationManagerFactory::DriveNotificationManagerFactory()
34     : BrowserContextKeyedServiceFactory(
35         "DriveNotificationManager",
36         BrowserContextDependencyManager::GetInstance()) {
37   DependsOn(ProfileSyncServiceFactory::GetInstance());
38   DependsOn(invalidation::InvalidationServiceFactory::GetInstance());
39 }
40 
~DriveNotificationManagerFactory()41 DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {}
42 
43 BrowserContextKeyedService*
BuildServiceInstanceFor(content::BrowserContext * context) const44 DriveNotificationManagerFactory::BuildServiceInstanceFor(
45     content::BrowserContext* context) const {
46   return new DriveNotificationManager(
47       invalidation::InvalidationServiceFactory::GetForProfile(
48           Profile::FromBrowserContext(context)));
49 }
50 
51 }  // namespace drive
52