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_UI_APP_LIST_RECOMMENDED_APPS_H_ | 5 #ifndef CHROME_BROWSER_UI_APP_LIST_RECOMMENDED_APPS_H_ |
6 #define CHROME_BROWSER_UI_APP_LIST_RECOMMENDED_APPS_H_ | 6 #define CHROME_BROWSER_UI_APP_LIST_RECOMMENDED_APPS_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/prefs/pref_change_registrar.h" | 13 #include "base/prefs/pref_change_registrar.h" |
| 14 #include "base/scoped_observer.h" |
14 #include "chrome/browser/extensions/install_observer.h" | 15 #include "chrome/browser/extensions/install_observer.h" |
| 16 #include "extensions/browser/extension_registry_observer.h" |
15 | 17 |
16 class Profile; | 18 class Profile; |
17 | 19 |
| 20 namespace extensions { |
| 21 class ExtensionRegistry; |
| 22 } |
| 23 |
18 namespace app_list { | 24 namespace app_list { |
19 | 25 |
20 class RecommendedAppsObserver; | 26 class RecommendedAppsObserver; |
21 | 27 |
22 // A class that maintains a list of recommended apps by watching changes | 28 // A class that maintains a list of recommended apps by watching changes |
23 // to app state. | 29 // to app state. |
24 class RecommendedApps : public extensions::InstallObserver { | 30 class RecommendedApps : public extensions::ExtensionRegistryObserver { |
25 public: | 31 public: |
26 typedef std::vector<scoped_refptr<const extensions::Extension> > Apps; | 32 typedef std::vector<scoped_refptr<const extensions::Extension> > Apps; |
27 | 33 |
28 explicit RecommendedApps(Profile* profile); | 34 explicit RecommendedApps(Profile* profile); |
29 virtual ~RecommendedApps(); | 35 virtual ~RecommendedApps(); |
30 | 36 |
31 void AddObserver(RecommendedAppsObserver* observer); | 37 void AddObserver(RecommendedAppsObserver* observer); |
32 void RemoveObserver(RecommendedAppsObserver* observer); | 38 void RemoveObserver(RecommendedAppsObserver* observer); |
33 | 39 |
34 const Apps& apps() const { return apps_; } | 40 const Apps& apps() const { return apps_; } |
35 | 41 |
36 private: | 42 private: |
37 void Update(); | 43 void Update(); |
38 | 44 |
39 // extensions::InstallObserver overrides: | 45 // extensions::InstallObserver overrides: |
40 virtual void OnExtensionInstalled( | 46 virtual void OnExtensionLoaded( |
| 47 content::BrowserContext* browser_context, |
41 const extensions::Extension* extension) OVERRIDE; | 48 const extensions::Extension* extension) OVERRIDE; |
42 virtual void OnExtensionLoaded( | 49 virtual void OnExtensionWillBeInstalled( |
43 const extensions::Extension* extension) OVERRIDE; | 50 content::BrowserContext* browser_context, |
44 virtual void OnExtensionUnloaded( | 51 const extensions::Extension* extension, |
45 const extensions::Extension* extension) OVERRIDE; | 52 bool is_update, |
| 53 bool from_ephemeral, |
| 54 const std::string& old_name) OVERRIDE; |
46 virtual void OnExtensionUninstalled( | 55 virtual void OnExtensionUninstalled( |
| 56 content::BrowserContext* browser_context, |
47 const extensions::Extension* extension) OVERRIDE; | 57 const extensions::Extension* extension) OVERRIDE; |
48 | 58 |
49 Profile* profile_; | 59 Profile* profile_; |
50 PrefChangeRegistrar pref_change_registrar_; | 60 PrefChangeRegistrar pref_change_registrar_; |
51 | 61 |
52 Apps apps_; | 62 Apps apps_; |
53 ObserverList<RecommendedAppsObserver, true> observers_; | 63 ObserverList<RecommendedAppsObserver, true> observers_; |
54 | 64 |
| 65 ScopedObserver<extensions::ExtensionRegistry, |
| 66 extensions::ExtensionRegistryObserver> |
| 67 extension_registry_observer_; |
| 68 |
55 DISALLOW_COPY_AND_ASSIGN(RecommendedApps); | 69 DISALLOW_COPY_AND_ASSIGN(RecommendedApps); |
56 }; | 70 }; |
57 | 71 |
58 } // namespace app_list | 72 } // namespace app_list |
59 | 73 |
60 #endif // CHROME_BROWSER_UI_APP_LIST_RECOMMENDED_APPS_H_ | 74 #endif // CHROME_BROWSER_UI_APP_LIST_RECOMMENDED_APPS_H_ |
OLD | NEW |