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 APPS_APP_LOAD_SERVICE_H_ | 5 #ifndef APPS_APP_LOAD_SERVICE_H_ |
6 #define APPS_APP_LOAD_SERVICE_H_ | 6 #define APPS_APP_LOAD_SERVICE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
| 11 #include "base/scoped_observer.h" |
11 #include "base/command_line.h" | 12 #include "base/command_line.h" |
12 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
13 #include "components/keyed_service/core/keyed_service.h" | 14 #include "components/keyed_service/core/keyed_service.h" |
14 #include "content/public/browser/notification_observer.h" | 15 #include "content/public/browser/notification_observer.h" |
15 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
| 17 #include "extensions/browser/extension_registry_observer.h" |
16 | 18 |
17 class Profile; | 19 class Profile; |
18 | 20 |
19 namespace extensions { | 21 namespace extensions { |
| 22 class ExtensionRegistry; |
20 struct UnloadedExtensionInfo; | 23 struct UnloadedExtensionInfo; |
21 } | 24 } |
22 | 25 |
23 namespace apps { | 26 namespace apps { |
24 | 27 |
25 // Monitors apps being reloaded and performs app specific actions (like launch | 28 // Monitors apps being reloaded and performs app specific actions (like launch |
26 // or restart) on them. Also provides an interface to schedule these actions. | 29 // or restart) on them. Also provides an interface to schedule these actions. |
27 class AppLoadService : public KeyedService, | 30 class AppLoadService : public KeyedService, |
28 public content::NotificationObserver { | 31 public content::NotificationObserver, |
| 32 public extensions::ExtensionRegistryObserver { |
29 public: | 33 public: |
30 enum PostReloadActionType { | 34 enum PostReloadActionType { |
31 LAUNCH, | 35 LAUNCH, |
32 RESTART, | 36 RESTART, |
33 LAUNCH_WITH_COMMAND_LINE, | 37 LAUNCH_WITH_COMMAND_LINE, |
34 }; | 38 }; |
35 | 39 |
36 struct PostReloadAction { | 40 struct PostReloadAction { |
37 PostReloadAction(); | 41 PostReloadAction(); |
38 | 42 |
(...skipping 21 matching lines...) Expand all Loading... |
60 const base::FilePath& current_dir); | 64 const base::FilePath& current_dir); |
61 | 65 |
62 static AppLoadService* Get(Profile* profile); | 66 static AppLoadService* Get(Profile* profile); |
63 | 67 |
64 private: | 68 private: |
65 // content::NotificationObserver. | 69 // content::NotificationObserver. |
66 virtual void Observe(int type, | 70 virtual void Observe(int type, |
67 const content::NotificationSource& source, | 71 const content::NotificationSource& source, |
68 const content::NotificationDetails& details) OVERRIDE; | 72 const content::NotificationDetails& details) OVERRIDE; |
69 | 73 |
| 74 // extensions::ExtensionRegistryObserver. |
| 75 virtual void OnExtensionUnloaded( |
| 76 content::BrowserContext* browser_context, |
| 77 const extensions::Extension* extension, |
| 78 extensions::UnloadedExtensionInfo::Reason reason) OVERRIDE; |
| 79 |
70 bool WasUnloadedForReload( | 80 bool WasUnloadedForReload( |
71 const extensions::UnloadedExtensionInfo& unload_info); | 81 const extensions::ExtensionId& extension_id, |
| 82 const extensions::UnloadedExtensionInfo::Reason unload_info); |
72 bool HasPostReloadAction(const std::string& extension_id); | 83 bool HasPostReloadAction(const std::string& extension_id); |
73 | 84 |
74 // Map of extension id to reload action. Absence from the map implies | 85 // Map of extension id to reload action. Absence from the map implies |
75 // no action. | 86 // no action. |
76 std::map<std::string, PostReloadAction> post_reload_actions_; | 87 std::map<std::string, PostReloadAction> post_reload_actions_; |
77 content::NotificationRegistrar registrar_; | 88 content::NotificationRegistrar registrar_; |
78 Profile* profile_; | 89 Profile* profile_; |
79 | 90 |
| 91 ScopedObserver<extensions::ExtensionRegistry, |
| 92 extensions::ExtensionRegistryObserver> |
| 93 extension_registry_observer_; |
| 94 |
80 DISALLOW_COPY_AND_ASSIGN(AppLoadService); | 95 DISALLOW_COPY_AND_ASSIGN(AppLoadService); |
81 }; | 96 }; |
82 | 97 |
83 } // namespace apps | 98 } // namespace apps |
84 | 99 |
85 #endif // APPS_APP_LOAD_SERVICE_H_ | 100 #endif // APPS_APP_LOAD_SERVICE_H_ |
OLD | NEW |