summaryrefslogtreecommitdiffstats
path: root/chrome/browser/google_apis/drive_notification_manager_factory.cc
blob: 71c85f06478f6180bcb8c50e729961e94538f5b5 (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
// Copyright 2013 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/google_apis/drive_notification_manager_factory.h"

#include "chrome/browser/google_apis/drive_notification_manager.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_dependency_manager.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"

namespace google_apis {

// static
DriveNotificationManager*
DriveNotificationManagerFactory::GetForProfile(Profile* profile) {
  if (!ProfileSyncService::IsSyncEnabled())
    return NULL;

  return static_cast<DriveNotificationManager*>(
      GetInstance()->GetServiceForProfile(profile, true));
}

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

DriveNotificationManagerFactory::DriveNotificationManagerFactory()
    : ProfileKeyedServiceFactory("DriveNotificationManager",
                                 ProfileDependencyManager::GetInstance()) {
  DependsOn(ProfileSyncServiceFactory::GetInstance());
}

DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {}

ProfileKeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor(
    content::BrowserContext* profile) const {
  return new DriveNotificationManager(static_cast<Profile*>(profile));
}

}  // namespace google_apis