Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / api / system_indicator / system_indicator_manager.h
index fb67740..a7d7eda 100644 (file)
@@ -9,12 +9,13 @@
 #include <string>
 
 #include "base/memory/linked_ptr.h"
+#include "base/scoped_observer.h"
 #include "base/threading/thread_checker.h"
 #include "chrome/browser/extensions/extension_action_icon_factory.h"
 #include "components/keyed_service/core/keyed_service.h"
 #include "content/public/browser/notification_observer.h"
 #include "content/public/browser/notification_registrar.h"
-#include "extensions/browser/event_router.h"
+#include "extensions/browser/extension_registry_observer.h"
 
 class ExtensionAction;
 class Profile;
@@ -23,13 +24,14 @@ class StatusTray;
 FORWARD_DECLARE_TEST(SystemIndicatorApiTest, SystemIndicator);
 
 namespace extensions {
-
 class ExtensionIndicatorIcon;
+class ExtensionRegistry;
 
 // Keeps track of all the systemIndicator icons created for a given Profile
 // that are currently visible in the UI.  Use SystemIndicatorManagerFactory to
 // create a SystemIndicatorManager object.
 class SystemIndicatorManager : public content::NotificationObserver,
+                               public ExtensionRegistryObserver,
                                public KeyedService {
  public:
   SystemIndicatorManager(Profile* profile, StatusTray* status_tray);
@@ -38,13 +40,19 @@ class SystemIndicatorManager : public content::NotificationObserver,
   // KeyedService implementation.
   virtual void Shutdown() OVERRIDE;
 
+ private:
+  FRIEND_TEST_ALL_PREFIXES(::SystemIndicatorApiTest, SystemIndicator);
+
   // content::NotificationDelegate implementation.
   virtual void Observe(int type,
                        const content::NotificationSource& source,
                        const content::NotificationDetails& details) OVERRIDE;
 
- private:
-  FRIEND_TEST_ALL_PREFIXES(::SystemIndicatorApiTest, SystemIndicator);
+  // ExtensionRegistryObserver implementation.
+  virtual void OnExtensionUnloaded(
+      content::BrowserContext* browser_context,
+      const Extension* extension,
+      UnloadedExtensionInfo::Reason reason) OVERRIDE;
 
   // Determines whether the indicator should be hidden or shown and calls the
   // appropriate function.
@@ -72,6 +80,10 @@ class SystemIndicatorManager : public content::NotificationObserver,
   content::NotificationRegistrar registrar_;
   base::ThreadChecker thread_checker_;
 
+  // Listen to extension unloaded notifications.
+  ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+      extension_registry_observer_;
+
   DISALLOW_COPY_AND_ASSIGN(SystemIndicatorManager);
 };