OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" | 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/lazy_instance.h" |
10 #include "base/logging.h" | 11 #include "base/logging.h" |
11 #include "base/string_number_conversions.h" | 12 #include "base/string_number_conversions.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api_factor
y.h" | |
14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler.h" | 14 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati
on_handler.h" |
15 #include "chrome/browser/extensions/event_names.h" | 15 #include "chrome/browser/extensions/event_names.h" |
16 #include "chrome/browser/extensions/event_router.h" | 16 #include "chrome/browser/extensions/event_router.h" |
17 #include "chrome/browser/extensions/extension_service.h" | 17 #include "chrome/browser/extensions/extension_service.h" |
18 #include "chrome/browser/extensions/extension_system.h" | 18 #include "chrome/browser/extensions/extension_system.h" |
| 19 #include "chrome/browser/extensions/extension_system_factory.h" |
19 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/browser/signin/token_service.h" | 21 #include "chrome/browser/signin/token_service.h" |
21 #include "chrome/browser/signin/token_service_factory.h" | 22 #include "chrome/browser/signin/token_service_factory.h" |
22 #include "chrome/browser/sync/profile_sync_service.h" | 23 #include "chrome/browser/sync/profile_sync_service.h" |
23 #include "chrome/browser/sync/profile_sync_service_factory.h" | 24 #include "chrome/browser/sync/profile_sync_service_factory.h" |
24 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 25 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
25 #include "chrome/common/chrome_notification_types.h" | 26 #include "chrome/common/chrome_notification_types.h" |
26 #include "chrome/common/extensions/api/push_messaging.h" | 27 #include "chrome/common/extensions/api/push_messaging.h" |
27 #include "chrome/common/extensions/extension.h" | 28 #include "chrome/common/extensions/extension.h" |
28 #include "chrome/common/extensions/extension_set.h" | 29 #include "chrome/common/extensions/extension_set.h" |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 | 281 |
281 PushMessagingAPI::PushMessagingAPI(Profile* profile) | 282 PushMessagingAPI::PushMessagingAPI(Profile* profile) |
282 : push_messaging_event_router_(new PushMessagingEventRouter(profile)) { | 283 : push_messaging_event_router_(new PushMessagingEventRouter(profile)) { |
283 } | 284 } |
284 | 285 |
285 PushMessagingAPI::~PushMessagingAPI() { | 286 PushMessagingAPI::~PushMessagingAPI() { |
286 } | 287 } |
287 | 288 |
288 // static | 289 // static |
289 PushMessagingAPI* PushMessagingAPI::Get(Profile* profile) { | 290 PushMessagingAPI* PushMessagingAPI::Get(Profile* profile) { |
290 return PushMessagingAPIFactory::GetForProfile(profile); | 291 return ProfileKeyedAPIFactory<PushMessagingAPI>::GetForProfile(profile); |
291 } | 292 } |
292 | 293 |
293 void PushMessagingAPI::Shutdown() { | 294 void PushMessagingAPI::Shutdown() { |
294 push_messaging_event_router_.reset(); | 295 push_messaging_event_router_.reset(); |
295 } | 296 } |
296 | 297 |
| 298 static base::LazyInstance<ProfileKeyedAPIFactory<PushMessagingAPI> > |
| 299 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 300 |
| 301 // static |
| 302 ProfileKeyedAPIFactory<PushMessagingAPI>* |
| 303 PushMessagingAPI::GetFactoryInstance() { |
| 304 return &g_factory.Get(); |
| 305 } |
| 306 |
297 PushMessagingEventRouter* PushMessagingAPI::GetEventRouterForTest() { | 307 PushMessagingEventRouter* PushMessagingAPI::GetEventRouterForTest() { |
298 return push_messaging_event_router_.get(); | 308 return push_messaging_event_router_.get(); |
299 } | 309 } |
300 | 310 |
| 311 template <> |
| 312 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { |
| 313 DependsOn(ExtensionSystemFactory::GetInstance()); |
| 314 DependsOn(ProfileSyncServiceFactory::GetInstance()); |
| 315 } |
| 316 |
301 } // namespace extensions | 317 } // namespace extensions |
OLD | NEW |