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