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/lazy_instance.h" |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 return; | 280 return; |
281 } | 281 } |
282 } | 282 } |
283 | 283 |
284 PushMessagingAPI::PushMessagingAPI(content::BrowserContext* context) | 284 PushMessagingAPI::PushMessagingAPI(content::BrowserContext* context) |
285 : profile_(Profile::FromBrowserContext(context)) { | 285 : profile_(Profile::FromBrowserContext(context)) { |
286 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 286 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
287 content::Source<Profile>(profile_->GetOriginalProfile())); | 287 content::Source<Profile>(profile_->GetOriginalProfile())); |
288 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 288 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
289 content::Source<Profile>(profile_->GetOriginalProfile())); | 289 content::Source<Profile>(profile_->GetOriginalProfile())); |
290 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 290 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
291 content::Source<Profile>(profile_->GetOriginalProfile())); | 291 content::Source<Profile>(profile_->GetOriginalProfile())); |
292 } | 292 } |
293 | 293 |
294 PushMessagingAPI::~PushMessagingAPI() { | 294 PushMessagingAPI::~PushMessagingAPI() { |
295 } | 295 } |
296 | 296 |
297 // static | 297 // static |
298 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) { | 298 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) { |
299 return BrowserContextKeyedAPIFactory<PushMessagingAPI>::Get(context); | 299 return BrowserContextKeyedAPIFactory<PushMessagingAPI>::Get(context); |
300 } | 300 } |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 } | 338 } |
339 break; | 339 break; |
340 } | 340 } |
341 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 341 case chrome::NOTIFICATION_EXTENSION_LOADED: { |
342 const Extension* extension = content::Details<Extension>(details).ptr(); | 342 const Extension* extension = content::Details<Extension>(details).ptr(); |
343 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { | 343 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { |
344 handler_->RegisterExtension(extension->id()); | 344 handler_->RegisterExtension(extension->id()); |
345 } | 345 } |
346 break; | 346 break; |
347 } | 347 } |
348 case chrome::NOTIFICATION_EXTENSION_UNLOADED: { | 348 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
349 const Extension* extension = | 349 const Extension* extension = |
350 content::Details<UnloadedExtensionInfo>(details)->extension; | 350 content::Details<UnloadedExtensionInfo>(details)->extension; |
351 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { | 351 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { |
352 handler_->UnregisterExtension(extension->id()); | 352 handler_->UnregisterExtension(extension->id()); |
353 } | 353 } |
354 break; | 354 break; |
355 } | 355 } |
356 default: | 356 default: |
357 NOTREACHED(); | 357 NOTREACHED(); |
358 } | 358 } |
359 } | 359 } |
360 | 360 |
361 void PushMessagingAPI::SetMapperForTest( | 361 void PushMessagingAPI::SetMapperForTest( |
362 scoped_ptr<PushMessagingInvalidationMapper> mapper) { | 362 scoped_ptr<PushMessagingInvalidationMapper> mapper) { |
363 handler_ = mapper.Pass(); | 363 handler_ = mapper.Pass(); |
364 } | 364 } |
365 | 365 |
366 template <> | 366 template <> |
367 void | 367 void |
368 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { | 368 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { |
369 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 369 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
370 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); | 370 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); |
371 } | 371 } |
372 | 372 |
373 } // namespace extensions | 373 } // namespace extensions |
OLD | NEW |