Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / background / background_contents_service.h
index 05f0953..382cb42 100644 (file)
 
 #include "base/gtest_prod_util.h"
 #include "base/memory/ref_counted.h"
+#include "base/scoped_observer.h"
 #include "chrome/browser/tab_contents/background_contents.h"
 #include "components/keyed_service/core/keyed_service.h"
 #include "content/public/browser/notification_observer.h"
 #include "content/public/browser/notification_registrar.h"
 #include "content/public/common/window_container_type.h"
+#include "extensions/browser/extension_registry_observer.h"
 #include "ui/base/window_open_disposition.h"
 #include "url/gurl.h"
 
@@ -33,6 +35,7 @@ class SessionStorageNamespace;
 
 namespace extensions {
 class Extension;
+class ExtensionRegistry;
 }
 
 namespace gfx {
@@ -50,20 +53,21 @@ struct BackgroundContentsOpenedDetails;
 // BackgroundContents and their parent app, and shutting them down when the
 // parent app is unloaded.
 class BackgroundContentsService : private content::NotificationObserver,
+                                  public extensions::ExtensionRegistryObserver,
                                   public BackgroundContents::Delegate,
                                   public KeyedService {
  public:
   BackgroundContentsService(Profile* profile,
                             const base::CommandLine* command_line);
-  virtual ~BackgroundContentsService();
+  ~BackgroundContentsService() override;
 
   // Allows tests to reduce the time between a force-installed app/extension
   // crashing and when we reload it.
   static void SetRestartDelayForForceInstalledAppsAndExtensionsForTesting(
       int restart_delay_in_ms);
 
-  // Get the crash notification's id for the extension.
-  static std::string GetNotificationIdForExtensionForTesting(
+  // Get the crash notification's delegate id for the extension.
+  static std::string GetNotificationDelegateIdForExtensionForTesting(
       const std::string& extension_id);
 
   // Show a popup notification balloon with a crash message for a given app/
@@ -85,11 +89,11 @@ class BackgroundContentsService : private content::NotificationObserver,
   std::vector<BackgroundContents*> GetBackgroundContents() const;
 
   // BackgroundContents::Delegate implementation.
-  virtual void AddWebContents(content::WebContents* new_contents,
-                              WindowOpenDisposition disposition,
-                              const gfx::Rect& initial_pos,
-                              bool user_gesture,
-                              bool* was_blocked) OVERRIDE;
+  void AddWebContents(content::WebContents* new_contents,
+                      WindowOpenDisposition disposition,
+                      const gfx::Rect& initial_pos,
+                      bool user_gesture,
+                      bool* was_blocked) override;
 
   // Gets the parent application id for the passed BackgroundContents. Returns
   // an empty string if no parent application found (e.g. passed
@@ -136,9 +140,20 @@ class BackgroundContentsService : private content::NotificationObserver,
   void StartObserving(Profile* profile);
 
   // content::NotificationObserver implementation.
-  virtual void Observe(int type,
-                       const content::NotificationSource& source,
-                       const content::NotificationDetails& details) OVERRIDE;
+  void Observe(int type,
+               const content::NotificationSource& source,
+               const content::NotificationDetails& details) override;
+
+  // extensions::ExtensionRegistryObserver implementation.
+  void OnExtensionLoaded(content::BrowserContext* browser_context,
+                         const extensions::Extension* extension) override;
+  void OnExtensionUnloaded(
+      content::BrowserContext* browser_context,
+      const extensions::Extension* extension,
+      extensions::UnloadedExtensionInfo::Reason reason) override;
+  void OnExtensionUninstalled(content::BrowserContext* browser_context,
+                              const extensions::Extension* extension,
+                              extensions::UninstallReason reason) override;
 
   // Restarts a force-installed app/extension after a crash.
   void RestartForceInstalledExtensionOnCrash(
@@ -168,7 +183,8 @@ class BackgroundContentsService : private content::NotificationObserver,
                               const base::string16& appid);
 
   // Invoked when a new BackgroundContents is opened.
-  void BackgroundContentsOpened(BackgroundContentsOpenedDetails* details);
+  void BackgroundContentsOpened(BackgroundContentsOpenedDetails* details,
+                                Profile* profile);
 
   // Invoked when a BackgroundContents object is destroyed.
   void BackgroundContentsShutdown(BackgroundContents* contents);
@@ -218,6 +234,10 @@ class BackgroundContentsService : private content::NotificationObserver,
       BackgroundContentsMap;
   BackgroundContentsMap contents_map_;
 
+  ScopedObserver<extensions::ExtensionRegistry,
+                 extensions::ExtensionRegistryObserver>
+      extension_registry_observer_;
+
   DISALLOW_COPY_AND_ASSIGN(BackgroundContentsService);
 };