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_APPS_SHORTCUT_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_ |
6 #define CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_ | 6 #define CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_ |
7 | 7 |
| 8 #include "base/scoped_observer.h" |
8 #include "chrome/browser/profiles/profile_info_cache_observer.h" | 9 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
9 #include "components/keyed_service/core/keyed_service.h" | 10 #include "components/keyed_service/core/keyed_service.h" |
10 #include "content/public/browser/notification_observer.h" | 11 #include "content/public/browser/notification_observer.h" |
11 #include "content/public/browser/notification_registrar.h" | 12 #include "content/public/browser/notification_registrar.h" |
| 13 #include "extensions/browser/extension_registry_observer.h" |
12 #include "extensions/common/extension.h" | 14 #include "extensions/common/extension.h" |
13 | 15 |
14 class PrefService; | 16 class PrefService; |
15 class Profile; | 17 class Profile; |
16 | 18 |
| 19 namespace extensions { |
| 20 class ExtensionRegistry; |
| 21 } |
| 22 |
17 namespace user_prefs { | 23 namespace user_prefs { |
18 class PrefRegistrySyncable; | 24 class PrefRegistrySyncable; |
19 } | 25 } |
20 | 26 |
21 // This class manages the installation of shortcuts for platform apps. | 27 // This class manages the installation of shortcuts for platform apps. |
22 class AppShortcutManager : public KeyedService, | 28 class AppShortcutManager : public KeyedService, |
23 public content::NotificationObserver, | 29 public content::NotificationObserver, |
| 30 public extensions::ExtensionRegistryObserver, |
24 public ProfileInfoCacheObserver { | 31 public ProfileInfoCacheObserver { |
25 public: | 32 public: |
26 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 33 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
27 | 34 |
28 explicit AppShortcutManager(Profile* profile); | 35 explicit AppShortcutManager(Profile* profile); |
29 | 36 |
30 virtual ~AppShortcutManager(); | 37 virtual ~AppShortcutManager(); |
31 | 38 |
32 // Checks if kShortcutsEnabled is set in prefs. If not, this sets it and | 39 // Checks if kShortcutsEnabled is set in prefs. If not, this sets it and |
33 // creates shortcuts for all apps. | 40 // creates shortcuts for all apps. |
34 void OnceOffCreateShortcuts(); | 41 void OnceOffCreateShortcuts(); |
35 | 42 |
36 // content::NotificationObserver | 43 // content::NotificationObserver. |
37 virtual void Observe(int type, | 44 virtual void Observe(int type, |
38 const content::NotificationSource& source, | 45 const content::NotificationSource& source, |
39 const content::NotificationDetails& details) OVERRIDE; | 46 const content::NotificationDetails& details) OVERRIDE; |
40 | 47 |
41 // ProfileInfoCacheObserver | 48 // extensions::ExtensionRegistryObserver. |
| 49 virtual void OnExtensionWillBeInstalled( |
| 50 content::BrowserContext* browser_context, |
| 51 const extensions::Extension* extension, |
| 52 bool is_update, |
| 53 const std::string& old_name) OVERRIDE; |
| 54 virtual void OnExtensionUninstalled( |
| 55 content::BrowserContext* browser_context, |
| 56 const extensions::Extension* extension) OVERRIDE; |
| 57 |
| 58 // ProfileInfoCacheObserver. |
42 virtual void OnProfileWillBeRemoved( | 59 virtual void OnProfileWillBeRemoved( |
43 const base::FilePath& profile_path) OVERRIDE; | 60 const base::FilePath& profile_path) OVERRIDE; |
44 | 61 |
45 private: | 62 private: |
46 void DeleteApplicationShortcuts(const extensions::Extension* extension); | 63 void DeleteApplicationShortcuts(const extensions::Extension* extension); |
47 | 64 |
48 content::NotificationRegistrar registrar_; | 65 content::NotificationRegistrar registrar_; |
49 Profile* profile_; | 66 Profile* profile_; |
50 bool is_profile_info_cache_observer_; | 67 bool is_profile_info_cache_observer_; |
51 PrefService* prefs_; | 68 PrefService* prefs_; |
52 | 69 |
| 70 ScopedObserver<extensions::ExtensionRegistry, |
| 71 extensions::ExtensionRegistryObserver> |
| 72 extension_registry_observer_; |
| 73 |
53 DISALLOW_COPY_AND_ASSIGN(AppShortcutManager); | 74 DISALLOW_COPY_AND_ASSIGN(AppShortcutManager); |
54 }; | 75 }; |
55 | 76 |
56 #endif // CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_ | 77 #endif // CHROME_BROWSER_APPS_SHORTCUT_MANAGER_H_ |
OLD | NEW |