| 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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 } | 274 } |
| 275 return; | 275 return; |
| 276 } | 276 } |
| 277 default: | 277 default: |
| 278 // Return error to caller. | 278 // Return error to caller. |
| 279 ReportResult(std::string(), error_text); | 279 ReportResult(std::string(), error_text); |
| 280 return; | 280 return; |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 | 283 |
| 284 PushMessagingAPI::PushMessagingAPI(Profile* profile) : profile_(profile) { | 284 PushMessagingAPI::PushMessagingAPI(content::BrowserContext* context) |
| 285 : profile_(Profile::FromBrowserContext(context)) { |
| 285 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, | 286 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 286 content::Source<Profile>(profile_->GetOriginalProfile())); | 287 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 287 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, | 288 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
| 288 content::Source<Profile>(profile_->GetOriginalProfile())); | 289 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 289 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, | 290 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED, |
| 290 content::Source<Profile>(profile_->GetOriginalProfile())); | 291 content::Source<Profile>(profile_->GetOriginalProfile())); |
| 291 } | 292 } |
| 292 | 293 |
| 293 PushMessagingAPI::~PushMessagingAPI() { | 294 PushMessagingAPI::~PushMessagingAPI() { |
| 294 } | 295 } |
| 295 | 296 |
| 296 // static | 297 // static |
| 297 PushMessagingAPI* PushMessagingAPI::Get(Profile* profile) { | 298 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) { |
| 298 return ProfileKeyedAPIFactory<PushMessagingAPI>::GetForProfile(profile); | 299 return ProfileKeyedAPIFactory<PushMessagingAPI>::GetForProfile(context); |
| 299 } | 300 } |
| 300 | 301 |
| 301 void PushMessagingAPI::Shutdown() { | 302 void PushMessagingAPI::Shutdown() { |
| 302 event_router_.reset(); | 303 event_router_.reset(); |
| 303 handler_.reset(); | 304 handler_.reset(); |
| 304 } | 305 } |
| 305 | 306 |
| 306 static base::LazyInstance<ProfileKeyedAPIFactory<PushMessagingAPI> > | 307 static base::LazyInstance<ProfileKeyedAPIFactory<PushMessagingAPI> > |
| 307 g_factory = LAZY_INSTANCE_INITIALIZER; | 308 g_factory = LAZY_INSTANCE_INITIALIZER; |
| 308 | 309 |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 handler_ = mapper.Pass(); | 363 handler_ = mapper.Pass(); |
| 363 } | 364 } |
| 364 | 365 |
| 365 template <> | 366 template <> |
| 366 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { | 367 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { |
| 367 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); | 368 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); |
| 368 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); | 369 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); |
| 369 } | 370 } |
| 370 | 371 |
| 371 } // namespace extensions | 372 } // namespace extensions |
| OLD | NEW |