Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(541)

Side by Side Diff: chrome/browser/extensions/api/push_messaging/push_messaging_api.cc

Issue 298883006: Rename NOTIFICATION_EXTENSION_INSTALLED to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 : extension_registry_observer_(this), 290 : extension_registry_observer_(this),
291 profile_(Profile::FromBrowserContext(context)) { 291 profile_(Profile::FromBrowserContext(context)) {
292 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_)); 292 extension_registry_observer_.Add(ExtensionRegistry::Get(profile_));
293 registrar_.Add(this, chrome::NOTIFICATION_EXTENSION_INSTALLED, 293 registrar_.Add(this,
294 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED,
294 content::Source<Profile>(profile_->GetOriginalProfile())); 295 content::Source<Profile>(profile_->GetOriginalProfile()));
295 } 296 }
296 297
297 PushMessagingAPI::~PushMessagingAPI() { 298 PushMessagingAPI::~PushMessagingAPI() {
298 } 299 }
299 300
300 // static 301 // static
301 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) { 302 PushMessagingAPI* PushMessagingAPI::Get(content::BrowserContext* context) {
302 return BrowserContextKeyedAPIFactory<PushMessagingAPI>::Get(context); 303 return BrowserContextKeyedAPIFactory<PushMessagingAPI>::Get(context);
303 } 304 }
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
351 return; 352 return;
352 353
353 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { 354 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) {
354 handler_->UnregisterExtension(extension->id()); 355 handler_->UnregisterExtension(extension->id());
355 } 356 }
356 } 357 }
357 358
358 void PushMessagingAPI::Observe(int type, 359 void PushMessagingAPI::Observe(int type,
359 const content::NotificationSource& source, 360 const content::NotificationSource& source,
360 const content::NotificationDetails& details) { 361 const content::NotificationDetails& details) {
361 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_INSTALLED); 362 DCHECK_EQ(type, chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED);
362 if (!InitEventRouterAndHandler()) 363 if (!InitEventRouterAndHandler())
363 return; 364 return;
364 365
365 const Extension* extension = 366 const Extension* extension =
366 content::Details<const InstalledExtensionInfo>(details)->extension; 367 content::Details<const InstalledExtensionInfo>(details)->extension;
367 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) { 368 if (extension->HasAPIPermission(APIPermission::kPushMessaging)) {
368 handler_->SuppressInitialInvalidationsForExtension(extension->id()); 369 handler_->SuppressInitialInvalidationsForExtension(extension->id());
369 } 370 }
370 } 371 }
371 372
372 void PushMessagingAPI::SetMapperForTest( 373 void PushMessagingAPI::SetMapperForTest(
373 scoped_ptr<PushMessagingInvalidationMapper> mapper) { 374 scoped_ptr<PushMessagingInvalidationMapper> mapper) {
374 handler_ = mapper.Pass(); 375 handler_ = mapper.Pass();
375 } 376 }
376 377
377 template <> 378 template <>
378 void 379 void
379 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { 380 BrowserContextKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() {
380 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory()); 381 DependsOn(ExtensionsBrowserClient::Get()->GetExtensionSystemFactory());
381 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); 382 DependsOn(invalidation::InvalidationServiceFactory::GetInstance());
382 } 383 }
383 384
384 } // namespace extensions 385 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698