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