| Index: chrome/browser/extensions/install_tracker.h
|
| diff --git a/chrome/browser/extensions/install_tracker.h b/chrome/browser/extensions/install_tracker.h
|
| index 9624000f2fe7523fbb402fcfaf7b7db257e1c57d..e4bc90e518c3d29a339d3de20f3dd770a2de86ad 100644
|
| --- a/chrome/browser/extensions/install_tracker.h
|
| +++ b/chrome/browser/extensions/install_tracker.h
|
| @@ -5,12 +5,16 @@
|
| #ifndef CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_
|
| #define CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_
|
|
|
| +#include <map>
|
| +
|
| #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;
|
|
|
| @@ -21,10 +25,23 @@ class BrowserContext;
|
| namespace extensions {
|
|
|
| class ExtensionPrefs;
|
| +class ExtensionRegistry;
|
|
|
| class InstallTracker : public KeyedService,
|
| - public content::NotificationObserver {
|
| + public content::NotificationObserver,
|
| + public ExtensionRegistryObserver {
|
| public:
|
| + // Details of an active installation.
|
| + struct InstallProgressData {
|
| + public:
|
| + InstallProgressData();
|
| + explicit InstallProgressData(const std::string& extension_id);
|
| +
|
| + std::string extension_id;
|
| + int percent_downloaded;
|
| + bool is_ephemeral;
|
| + };
|
| +
|
| InstallTracker(Profile* profile,
|
| extensions::ExtensionPrefs* prefs);
|
| virtual ~InstallTracker();
|
| @@ -34,6 +51,21 @@ class InstallTracker : public KeyedService,
|
| void AddObserver(InstallObserver* observer);
|
| void RemoveObserver(InstallObserver* observer);
|
|
|
| + // If an install is currently in progress for |extension_id|, returns details
|
| + // of the installation. This instance retains ownership of the returned
|
| + // pointer. Returns NULL if the extension is not currently being installed.
|
| + const InstallProgressData* GetActiveInstall(
|
| + const std::string& extension_id) const;
|
| +
|
| + // Registers an install initiated by the user to allow checking of duplicate
|
| + // installs. Download of the extension has not necessarily started.
|
| + // RemoveActiveInstall() must be called when install is complete regardless of
|
| + // success or failure.
|
| + void AddActiveInstall(const InstallProgressData& install_data);
|
| +
|
| + // Deregisters an active install.
|
| + void RemoveActiveInstall(const std::string& extension_id);
|
| +
|
| void OnBeginExtensionInstall(
|
| const InstallObserver::ExtensionInstallParams& params);
|
| void OnBeginExtensionDownload(const std::string& extension_id);
|
| @@ -57,9 +89,19 @@ class InstallTracker : public KeyedService,
|
| const content::NotificationSource& source,
|
| const content::NotificationDetails& details) OVERRIDE;
|
|
|
| + // ExtensionRegistryObserver implementation.
|
| + virtual void OnExtensionInstalled(content::BrowserContext* browser_context,
|
| + const Extension* extension) OVERRIDE;
|
| +
|
| + // Maps extension id to the details of an active install.
|
| + typedef std::map<std::string, InstallProgressData> ActiveInstallsMap;
|
| + ActiveInstallsMap active_installs_;
|
| +
|
| ObserverList<InstallObserver> observers_;
|
| content::NotificationRegistrar registrar_;
|
| PrefChangeRegistrar pref_change_registrar_;
|
| + ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver>
|
| + extension_registry_observer_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(InstallTracker);
|
| };
|
|
|