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 <map> | 8 #include <map> |
9 | 9 |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 | 25 |
26 class ExtensionPrefs; | 26 class ExtensionPrefs; |
27 class ExtensionRegistry; | 27 class ExtensionRegistry; |
28 | 28 |
29 class InstallTracker : public KeyedService, | 29 class InstallTracker : public KeyedService, |
30 public content::NotificationObserver, | 30 public content::NotificationObserver, |
31 public ExtensionRegistryObserver { | 31 public ExtensionRegistryObserver { |
32 public: | 32 public: |
33 InstallTracker(content::BrowserContext* browser_context, | 33 InstallTracker(content::BrowserContext* browser_context, |
34 extensions::ExtensionPrefs* prefs); | 34 extensions::ExtensionPrefs* prefs); |
35 virtual ~InstallTracker(); | 35 ~InstallTracker() override; |
36 | 36 |
37 static InstallTracker* Get(content::BrowserContext* context); | 37 static InstallTracker* Get(content::BrowserContext* context); |
38 | 38 |
39 void AddObserver(InstallObserver* observer); | 39 void AddObserver(InstallObserver* observer); |
40 void RemoveObserver(InstallObserver* observer); | 40 void RemoveObserver(InstallObserver* observer); |
41 | 41 |
42 // If an install is currently in progress for |extension_id|, returns details | 42 // If an install is currently in progress for |extension_id|, returns details |
43 // of the installation. This instance retains ownership of the returned | 43 // of the installation. This instance retains ownership of the returned |
44 // pointer. Returns NULL if the extension is not currently being installed. | 44 // pointer. Returns NULL if the extension is not currently being installed. |
45 const ActiveInstallData* GetActiveInstall( | 45 const ActiveInstallData* GetActiveInstall( |
(...skipping 15 matching lines...) Expand all Loading... |
61 void OnDownloadProgress(const std::string& extension_id, | 61 void OnDownloadProgress(const std::string& extension_id, |
62 int percent_downloaded); | 62 int percent_downloaded); |
63 void OnBeginCrxInstall(const std::string& extension_id); | 63 void OnBeginCrxInstall(const std::string& extension_id); |
64 void OnFinishCrxInstall(const std::string& extension_id, bool success); | 64 void OnFinishCrxInstall(const std::string& extension_id, bool success); |
65 void OnInstallFailure(const std::string& extension_id); | 65 void OnInstallFailure(const std::string& extension_id); |
66 | 66 |
67 // NOTE(limasdf): For extension [un]load and [un]installed, use | 67 // NOTE(limasdf): For extension [un]load and [un]installed, use |
68 // ExtensionRegistryObserver. | 68 // ExtensionRegistryObserver. |
69 | 69 |
70 // Overriddes for KeyedService. | 70 // Overriddes for KeyedService. |
71 virtual void Shutdown() override; | 71 void Shutdown() override; |
72 | 72 |
73 private: | 73 private: |
74 void OnAppsReordered(); | 74 void OnAppsReordered(); |
75 | 75 |
76 // content::NotificationObserver implementation. | 76 // content::NotificationObserver implementation. |
77 virtual void Observe(int type, | 77 void Observe(int type, |
78 const content::NotificationSource& source, | 78 const content::NotificationSource& source, |
79 const content::NotificationDetails& details) override; | 79 const content::NotificationDetails& details) override; |
80 | 80 |
81 // ExtensionRegistryObserver implementation. | 81 // ExtensionRegistryObserver implementation. |
82 virtual void OnExtensionInstalled(content::BrowserContext* browser_context, | 82 void OnExtensionInstalled(content::BrowserContext* browser_context, |
83 const Extension* extension, | 83 const Extension* extension, |
84 bool is_update) override; | 84 bool is_update) override; |
85 | 85 |
86 // Maps extension id to the details of an active install. | 86 // Maps extension id to the details of an active install. |
87 typedef std::map<std::string, ActiveInstallData> ActiveInstallsMap; | 87 typedef std::map<std::string, ActiveInstallData> ActiveInstallsMap; |
88 ActiveInstallsMap active_installs_; | 88 ActiveInstallsMap active_installs_; |
89 | 89 |
90 ObserverList<InstallObserver> observers_; | 90 ObserverList<InstallObserver> observers_; |
91 content::NotificationRegistrar registrar_; | 91 content::NotificationRegistrar registrar_; |
92 PrefChangeRegistrar pref_change_registrar_; | 92 PrefChangeRegistrar pref_change_registrar_; |
93 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> | 93 ScopedObserver<ExtensionRegistry, ExtensionRegistryObserver> |
94 extension_registry_observer_; | 94 extension_registry_observer_; |
95 | 95 |
96 DISALLOW_COPY_AND_ASSIGN(InstallTracker); | 96 DISALLOW_COPY_AND_ASSIGN(InstallTracker); |
97 }; | 97 }; |
98 | 98 |
99 } // namespace extensions | 99 } // namespace extensions |
100 | 100 |
101 #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_ | 101 #endif // CHROME_BROWSER_EXTENSIONS_INSTALL_TRACKER_H_ |
OLD | NEW |