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 |
(...skipping 26 matching lines...) Expand all Loading... |
37 | 37 |
38 struct PostReloadAction { | 38 struct PostReloadAction { |
39 PostReloadAction(); | 39 PostReloadAction(); |
40 | 40 |
41 PostReloadActionType action_type; | 41 PostReloadActionType action_type; |
42 base::CommandLine command_line; | 42 base::CommandLine command_line; |
43 base::FilePath current_dir; | 43 base::FilePath current_dir; |
44 }; | 44 }; |
45 | 45 |
46 explicit AppLoadService(Profile* profile); | 46 explicit AppLoadService(Profile* profile); |
47 virtual ~AppLoadService(); | 47 ~AppLoadService() override; |
48 | 48 |
49 // Reload the application with the given id and then send it the OnRestarted | 49 // Reload the application with the given id and then send it the OnRestarted |
50 // event. | 50 // event. |
51 void RestartApplication(const std::string& extension_id); | 51 void RestartApplication(const std::string& extension_id); |
52 | 52 |
53 // Reload the application with the given id if it is currently running. | 53 // Reload the application with the given id if it is currently running. |
54 void RestartApplicationIfRunning(const std::string& extension_id); | 54 void RestartApplicationIfRunning(const std::string& extension_id); |
55 | 55 |
56 // Loads (or reloads) the app with |extension_path|, then launches it. Any | 56 // Loads (or reloads) the app with |extension_path|, then launches it. Any |
57 // command line parameters from |command_line| will be passed along via | 57 // command line parameters from |command_line| will be passed along via |
58 // launch parameters. Returns true if loading the extension has begun | 58 // launch parameters. Returns true if loading the extension has begun |
59 // successfully. | 59 // successfully. |
60 bool LoadAndLaunch(const base::FilePath& extension_path, | 60 bool LoadAndLaunch(const base::FilePath& extension_path, |
61 const base::CommandLine& command_line, | 61 const base::CommandLine& command_line, |
62 const base::FilePath& current_dir); | 62 const base::FilePath& current_dir); |
63 | 63 |
64 static AppLoadService* Get(Profile* profile); | 64 static AppLoadService* Get(Profile* profile); |
65 | 65 |
66 private: | 66 private: |
67 // content::NotificationObserver. | 67 // content::NotificationObserver. |
68 virtual void Observe(int type, | 68 void Observe(int type, |
69 const content::NotificationSource& source, | 69 const content::NotificationSource& source, |
70 const content::NotificationDetails& details) override; | 70 const content::NotificationDetails& details) override; |
71 | 71 |
72 // extensions::ExtensionRegistryObserver. | 72 // extensions::ExtensionRegistryObserver. |
73 virtual void OnExtensionUnloaded( | 73 void OnExtensionUnloaded( |
74 content::BrowserContext* browser_context, | 74 content::BrowserContext* browser_context, |
75 const extensions::Extension* extension, | 75 const extensions::Extension* extension, |
76 extensions::UnloadedExtensionInfo::Reason reason) override; | 76 extensions::UnloadedExtensionInfo::Reason reason) override; |
77 | 77 |
78 bool WasUnloadedForReload( | 78 bool WasUnloadedForReload( |
79 const extensions::ExtensionId& extension_id, | 79 const extensions::ExtensionId& extension_id, |
80 const extensions::UnloadedExtensionInfo::Reason reason); | 80 const extensions::UnloadedExtensionInfo::Reason reason); |
81 bool HasPostReloadAction(const std::string& extension_id); | 81 bool HasPostReloadAction(const std::string& extension_id); |
82 | 82 |
83 // 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 |
84 // no action. | 84 // no action. |
85 std::map<std::string, PostReloadAction> post_reload_actions_; | 85 std::map<std::string, PostReloadAction> post_reload_actions_; |
86 content::NotificationRegistrar registrar_; | 86 content::NotificationRegistrar registrar_; |
87 Profile* profile_; | 87 Profile* profile_; |
88 | 88 |
89 DISALLOW_COPY_AND_ASSIGN(AppLoadService); | 89 DISALLOW_COPY_AND_ASSIGN(AppLoadService); |
90 }; | 90 }; |
91 | 91 |
92 } // namespace apps | 92 } // namespace apps |
93 | 93 |
94 #endif // APPS_APP_LOAD_SERVICE_H_ | 94 #endif // APPS_APP_LOAD_SERVICE_H_ |
OLD | NEW |