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