blob: bec2c9ca8972dfb44fc25b791a16ebad1fddca27 (
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
// 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/drive/drive_notification_manager_factory.h"
#include "base/logging.h"
#include "chrome/browser/drive/drive_notification_manager.h"
#include "chrome/browser/invalidation/invalidation_service_factory.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_factory.h"
#include "components/keyed_service/content/browser_context_dependency_manager.h"
namespace drive {
// static
DriveNotificationManager*
DriveNotificationManagerFactory::FindForBrowserContext(
content::BrowserContext* context) {
return static_cast<DriveNotificationManager*>(
GetInstance()->GetServiceForBrowserContext(context, false));
}
// static
DriveNotificationManager*
DriveNotificationManagerFactory::GetForBrowserContext(
content::BrowserContext* context) {
if (!ProfileSyncService::IsSyncEnabled())
return NULL;
if (!invalidation::InvalidationServiceFactory::GetForProfile(
Profile::FromBrowserContext(context))) {
// Do not create a DriveNotificationManager for |context|s that do not
// support invalidation.
return NULL;
}
return static_cast<DriveNotificationManager*>(
GetInstance()->GetServiceForBrowserContext(context, true));
}
// static
DriveNotificationManagerFactory*
DriveNotificationManagerFactory::GetInstance() {
return Singleton<DriveNotificationManagerFactory>::get();
}
DriveNotificationManagerFactory::DriveNotificationManagerFactory()
: BrowserContextKeyedServiceFactory(
"DriveNotificationManager",
BrowserContextDependencyManager::GetInstance()) {
DependsOn(ProfileSyncServiceFactory::GetInstance());
DependsOn(invalidation::InvalidationServiceFactory::GetInstance());
}
DriveNotificationManagerFactory::~DriveNotificationManagerFactory() {}
KeyedService* DriveNotificationManagerFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
invalidation::InvalidationService* invalidation_service =
invalidation::InvalidationServiceFactory::GetForProfile(
Profile::FromBrowserContext(context));
DCHECK(invalidation_service);
return new DriveNotificationManager(invalidation_service);
}
} // namespace drive
|