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

Unified Diff: chrome/browser/extensions/api/push_messaging/push_messaging_api.h

Issue 275383002: Use ExtensionRegistryObserver instead of deprecated extension notification from c/b/e/api. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address review 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/push_messaging/push_messaging_api.h
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_api.h b/chrome/browser/extensions/api/push_messaging/push_messaging_api.h
index 0b5884b92cc4cfbca6db2a39ba0b1afcfb89facb..9600a289be2967bb93110d855f2ee04aa601f488 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.h
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.h
@@ -11,6 +11,7 @@
#include "base/compiler_specific.h"
#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
+#include "base/scoped_observer.h"
#include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.h"
#include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidation_handler_delegate.h"
#include "chrome/browser/extensions/chrome_extension_function.h"
@@ -18,6 +19,7 @@
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/browser_context_keyed_api_factory.h"
+#include "extensions/browser/extension_registry_observer.h"
#include "google_apis/gaia/google_service_auth_error.h"
#include "google_apis/gaia/oauth2_token_service.h"
@@ -28,7 +30,7 @@ class BrowserContext;
}
namespace extensions {
-
+class ExtensionRegistry;
class PushMessagingInvalidationMapper;
// Observes a single InvalidationHandler and generates onMessage events.
@@ -109,7 +111,8 @@ class PushMessagingGetChannelIdFunction
};
class PushMessagingAPI : public BrowserContextKeyedAPI,
- public content::NotificationObserver {
+ public content::NotificationObserver,
+ public ExtensionRegistryObserver {
public:
explicit PushMessagingAPI(content::BrowserContext* context);
virtual ~PushMessagingAPI();
@@ -146,6 +149,17 @@ class PushMessagingAPI : public BrowserContextKeyedAPI,
const content::NotificationSource& source,
const content::NotificationDetails& details) OVERRIDE;
+ // Overridden from ExtensionRegistryObserver.
+ virtual void OnExtensionLoaded(content::BrowserContext* browser_context,
+ const Extension* extension) OVERRIDE;
+ virtual void OnExtensionUnloaded(
+ content::BrowserContext* browser_context,
+ const Extension* extension,
+ UnloadedExtensionInfo::Reason reason) OVERRIDE;
+
+ // Initialize |event_router_| and |handler_|.
+ bool InitEventRouterAndHandler();
+
// Created lazily when an app or extension with the push messaging permission
// is loaded.
scoped_ptr<PushMessagingEventRouter> event_router_;
@@ -153,6 +167,10 @@ class PushMessagingAPI : public BrowserContextKeyedAPI,
content::NotificationRegistrar registrar_;
+ // Listen to extension load, unload notifications.
+ ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+ extension_registry_observer_;
+
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(PushMessagingAPI);
« no previous file with comments | « chrome/browser/extensions/api/idle/idle_manager.cc ('k') | chrome/browser/extensions/api/push_messaging/push_messaging_api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698