Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / extensions / install_tracker.h
index d3101d2..8342ec9 100644 (file)
@@ -7,24 +7,34 @@
 
 #include "base/observer_list.h"
 #include "base/prefs/pref_change_registrar.h"
+#include "base/scoped_observer.h"
 #include "chrome/browser/extensions/install_observer.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/extension_registry_observer.h"
 
 class Profile;
 
+namespace content {
+class BrowserContext;
+}
+
 namespace extensions {
 
 class ExtensionPrefs;
+class ExtensionRegistry;
 
 class InstallTracker : public KeyedService,
-                       public content::NotificationObserver {
+                       public content::NotificationObserver,
+                       public ExtensionRegistryObserver {
  public:
   InstallTracker(Profile* profile,
                  extensions::ExtensionPrefs* prefs);
   virtual ~InstallTracker();
 
+  static InstallTracker* Get(content::BrowserContext* context);
+
   void AddObserver(InstallObserver* observer);
   void RemoveObserver(InstallObserver* observer);
 
@@ -34,23 +44,36 @@ class InstallTracker : public KeyedService,
   void OnDownloadProgress(const std::string& extension_id,
                           int percent_downloaded);
   void OnBeginCrxInstall(const std::string& extension_id);
+  void OnFinishCrxInstall(const std::string& extension_id, bool success);
   void OnInstallFailure(const std::string& extension_id);
 
-  // Overriddes for KeyedService:
+  // Overriddes for KeyedService.
   virtual void Shutdown() OVERRIDE;
 
-  // content::NotificationObserver
+ private:
+  void OnAppsReordered();
+
+  // content::NotificationObserver.
   virtual void Observe(int type,
                        const content::NotificationSource& source,
                        const content::NotificationDetails& details) OVERRIDE;
 
- private:
-  void OnAppsReordered();
+  // ExtensionRegistryObserver implementation.
+  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;
 
   ObserverList<InstallObserver> observers_;
   content::NotificationRegistrar registrar_;
   PrefChangeRegistrar pref_change_registrar_;
 
+  // Listen to extension load, unloaded notifications.
+  ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
+      extension_registry_observer_;
+
   DISALLOW_COPY_AND_ASSIGN(InstallTracker);
 };