| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 // Return error to caller. | 283 // Return error to caller. |
| 284 ReportResult(std::string(), error_text); | 284 ReportResult(std::string(), error_text); |
| 285 return; | 285 return; |
| 286 } | 286 } |
| 287 } | 287 } |
| 288 | 288 |
| 289 PushMessagingAPI::PushMessagingAPI(content::BrowserContext* context) | 289 PushMessagingAPI::PushMessagingAPI(content::BrowserContext* context) |
| 290 : profile_(Profile::FromBrowserContext(context)) { | 290 : profile_(Profile::FromBrowserContext(context)) { |
| 291 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 291 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 292 content::Source<Profile>(profile_->GetOriginalProfile())); | 292 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 293 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 293 registrar_.Add(this, |
| 294 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
| 294 content::Source<Profile>(profile_->GetOriginalProfile())); | 295 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 295 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 296 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
| 296 content::Source<Profile>(profile_->GetOriginalProfile())); | 297 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 297 } | 298 } |
| 298 | 299 |
| 299 PushMessagingAPI::~PushMessagingAPI() { | 300 PushMessagingAPI::~PushMessagingAPI() { |
| 300 } | 301 } |
| 301 | 302 |
| 302 // static | 303 // static |
| 303 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) { | 304 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 334 } | 335 } |
| 335 switch (type) { | 336 switch (type) { |
| 336 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { | 337 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { |
| 337 const Extension* extension = | 338 const Extension* extension = |
| 338 content::Details<const InstalledExtensionInfo>(details)->extension; | 339 content::Details<const InstalledExtensionInfo>(details)->extension; |
| 339 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { | 340 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { |
| 340 handler_->SuppressInitialInvalidationsForExtension(extension->id()); | 341 handler_->SuppressInitialInvalidationsForExtension(extension->id()); |
| 341 } | 342 } |
| 342 break; | 343 break; |
| 343 } | 344 } |
| 344 case chrome::NOTIFICATION_EXTENSION_LOADED: { | 345 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { |
| 345 const Extension* extension = content::Details<Extension>(details).ptr(); | 346 const Extension* extension = content::Details<Extension>(details).ptr(); |
| 346 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { | 347 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { |
| 347 handler_->RegisterExtension(extension->id()); | 348 handler_->RegisterExtension(extension->id()); |
| 348 } | 349 } |
| 349 break; | 350 break; |
| 350 } | 351 } |
| 351 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { | 352 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { |
| 352 const Extension* extension = | 353 const Extension* extension = |
| 353 content::Details<UnloadedExtensionInfo>(details)->extension; | 354 content::Details<UnloadedExtensionInfo>(details)->extension; |
| 354 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { | 355 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 367 } | 368 } |
| 368 | 369 |
| 369 template <> | 370 template <> |
| 370 void | 371 void |
| 371 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { | 372 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { |
| 372 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 373 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 373 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); | 374 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); |
| 374 } | 375 } |
| 375 | 376 |
| 376 } // namespace extensions | 377 } // namespace extensions |
| OLD | NEW |