Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_ |
| 7 | 7 |
| 8 #include "base/observer_list.h" | 8 #include "base/observer_list.h" |
| 9 #include "base/prefs/pref_change_registrar.h" | 9 #include "base/prefs/pref_change_registrar.h" |
| 10 #include "base/scoped_observer.h" | |
| 11 #include "chrome/browser/extensions/install_observer.h" | 10 #include "chrome/browser/extensions/install_observer.h" |
| 12 #include "components/keyed_service/core/keyed_service.h" | 11 #include "components/keyed_service/core/keyed_service.h" |
| 13 #include "content/public/browser/notification_observer.h" | 12 #include "content/public/browser/notification_observer.h" |
| 14 #include "content/public/browser/notification_registrar.h" | 13 #include "content/public/browser/notification_registrar.h" |
| 15 #include "extensions/browser/extension_registry_observer.h" | |
| 16 | 14 |
| 17 class Profile; | 15 class Profile; |
| 18 | 16 |
| 19 namespace content { | 17 namespace content { |
| 20 class BrowserContext; | 18 class BrowserContext; |
| 21 } | 19 } |
| 22 | 20 |
| 23 namespace extensions { | 21 namespace extensions { |
| 24 | 22 |
| 25 class ExtensionPrefs; | 23 class ExtensionPrefs; |
| 26 class ExtensionRegistry; | |
| 27 | 24 |
| 28 class InstallTracker : public KeyedService, | 25 class InstallTracker : public KeyedService, |
| 29 public content::NotificationObserver, | 26 public content::NotificationObserver { |
| 30 public ExtensionRegistryObserver { | |
| 31 public: | 27 public: |
| 32 InstallTracker(Profile* profile, | 28 InstallTracker(Profile* profile, |
| 33 extensions::ExtensionPrefs* prefs); | 29 extensions::ExtensionPrefs* prefs); |
| 34 virtual ~InstallTracker(); | 30 virtual ~InstallTracker(); |
| 35 | 31 |
| 36 static InstallTracker* Get(content::BrowserContext* context); | 32 static InstallTracker* Get(content::BrowserContext* context); |
| 37 | 33 |
| 38 void AddObserver(InstallObserver* observer); | 34 void AddObserver(InstallObserver* observer); |
| 39 void RemoveObserver(InstallObserver* observer); | 35 void RemoveObserver(InstallObserver* observer); |
| 40 | 36 |
| 41 void OnBeginExtensionInstall( | 37 void OnBeginExtensionInstall( |
| 42 const InstallObserver::ExtensionInstallParams& params); | 38 const InstallObserver::ExtensionInstallParams& params); |
| 43 void OnBeginExtensionDownload(const std::string& extension_id); | 39 void OnBeginExtensionDownload(const std::string& extension_id); |
| 44 void OnDownloadProgress(const std::string& extension_id, | 40 void OnDownloadProgress(const std::string& extension_id, |
| 45 int percent_downloaded); | 41 int percent_downloaded); |
| 46 void OnBeginCrxInstall(const std::string& extension_id); | 42 void OnBeginCrxInstall(const std::string& extension_id); |
| 47 void OnFinishCrxInstall(const std::string& extension_id, bool success); | 43 void OnFinishCrxInstall(const std::string& extension_id, bool success); |
| 48 void OnInstallFailure(const std::string& extension_id); | 44 void OnInstallFailure(const std::string& extension_id); |
| 49 | 45 |
| 46 // NOTE(limasdf): For the extension [un]load and [un]installed, | |
| 47 // You might want to use ExtensionRegistryObserver. | |
|
not at google - send to devlin
2014/06/10 18:12:41
s/You might want to //.
I.e. just "For extension
limasdf
2014/06/11 00:26:00
Thank you.
| |
| 48 | |
| 50 // Overriddes for KeyedService. | 49 // Overriddes for KeyedService. |
| 51 virtual void Shutdown() OVERRIDE; | 50 virtual void Shutdown() OVERRIDE; |
| 52 | 51 |
| 53 private: | 52 private: |
| 54 void OnAppsReordered(); | 53 void OnAppsReordered(); |
| 55 | 54 |
| 56 // content::NotificationObserver implementation. | 55 // content::NotificationObserver implementation. |
| 57 virtual void Observe(int type, | 56 virtual void Observe(int type, |
| 58 const content::NotificationSource& source, | 57 const content::NotificationSource& source, |
| 59 const content::NotificationDetails& details) OVERRIDE; | 58 const content::NotificationDetails& details) OVERRIDE; |
| 60 | 59 |
| 61 // ExtensionRegistryObserver implementation. | |
| 62 virtual void OnExtensionWillBeInstalled( | |
| 63 content::BrowserContext* browser_context, | |
| 64 const Extension* extension, | |
| 65 bool is_update, | |
| 66 bool from_ephemeral, | |
| 67 const std::string& old_name) OVERRIDE; | |
| 68 | |
| 69 ObserverList<InstallObserver> observers_; | 60 ObserverList<InstallObserver> observers_; |
| 70 content::NotificationRegistrar registrar_; | 61 content::NotificationRegistrar registrar_; |
| 71 PrefChangeRegistrar pref_change_registrar_; | 62 PrefChangeRegistrar pref_change_registrar_; |
| 72 | 63 |
| 73 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | |
| 74 extension_registry_observer_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(InstallTracker); | 64 DISALLOW_COPY_AND_ASSIGN(InstallTracker); |
| 77 }; | 65 }; |
| 78 | 66 |
| 79 } // namespace extensions | 67 } // namespace extensions |
| 80 | 68 |
| 81 #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_ | 69 #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_ |
| OLD | NEW |