Chromium Code Reviews| 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" | |
| 12 #include "base/files/file_path.h" | |
| 11 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" | 13 #include "components/browser_context_keyed_service/browser_context_keyed_service .h" |
| 12 #include "content/public/browser/notification_observer.h" | 14 #include "content/public/browser/notification_observer.h" |
| 13 #include "content/public/browser/notification_registrar.h" | 15 #include "content/public/browser/notification_registrar.h" |
| 14 | 16 |
| 15 class Profile; | 17 class Profile; |
| 16 | 18 |
| 17 namespace apps { | 19 namespace apps { |
| 18 | 20 |
| 19 // Monitors apps being reloaded and performs app specific actions (like launch | 21 // Monitors apps being reloaded and performs app specific actions (like launch |
| 20 // or restart) on them. Also provides an interface to schedule these actions. | 22 // or restart) on them. Also provides an interface to schedule these actions. |
| 21 class AppLoadService : public BrowserContextKeyedService, | 23 class AppLoadService : public BrowserContextKeyedService, |
| 22 public content::NotificationObserver { | 24 public content::NotificationObserver { |
| 23 public: | 25 public: |
| 26 enum PostReloadActionType { | |
| 27 RELOAD_LAUNCH, | |
|
koz (OOO until 15th September)
2013/06/05 08:34:11
nit: I think it's fine to remove the RELOAD_ prefi
benwells
2013/06/06 00:22:42
Done.
| |
| 28 RELOAD_RESTART, | |
| 29 RELOAD_LAUNCH_WITH_COMMAND_LINE, | |
| 30 }; | |
| 31 | |
| 32 struct PostReloadAction { | |
| 33 PostReloadAction(); | |
| 34 | |
| 35 PostReloadActionType action_type; | |
| 36 CommandLine command_line; | |
| 37 base::FilePath current_dir; | |
| 38 }; | |
| 39 | |
| 24 explicit AppLoadService(Profile* profile); | 40 explicit AppLoadService(Profile* profile); |
| 25 virtual ~AppLoadService(); | 41 virtual ~AppLoadService(); |
| 26 | 42 |
| 27 // Reload the application with the given id and then send it the OnRestarted | 43 // Reload the application with the given id and then send it the OnRestarted |
| 28 // event. | 44 // event. |
| 29 void RestartApplication(const std::string& extension_id); | 45 void RestartApplication(const std::string& extension_id); |
| 30 | 46 |
| 31 // Schedule a launch to happen for the extension with id |extension_id| | 47 // Loads (or reloads) the app with |extension_path|, then launches it. Any |
| 32 // when it loads next. This does not cause the extension to be reloaded. | 48 // command line parameters from |command_line| will be passed along via |
| 33 void ScheduleLaunchOnLoad(const std::string& extension_id); | 49 // launch parameters. Returns true if loading the extension has begun |
| 50 // successfully. | |
| 51 bool LoadAndLaunch(const base::FilePath& extension_path, | |
| 52 const CommandLine& command_line, | |
| 53 const base::FilePath& current_dir); | |
| 34 | 54 |
| 35 static AppLoadService* Get(Profile* profile); | 55 static AppLoadService* Get(Profile* profile); |
| 36 | 56 |
| 37 private: | 57 private: |
| 38 // content::NotificationObserver. | 58 // content::NotificationObserver. |
| 39 virtual void Observe(int type, | 59 virtual void Observe(int type, |
| 40 const content::NotificationSource& source, | 60 const content::NotificationSource& source, |
| 41 const content::NotificationDetails& details) OVERRIDE; | 61 const content::NotificationDetails& details) OVERRIDE; |
| 42 | 62 |
| 43 // Map of extension id to reload action. Absence from the map implies | 63 // Map of extension id to reload action. Absence from the map implies |
| 44 // no action. | 64 // no action. |
| 45 std::map<std::string, int> reload_actions_; | 65 std::map<std::string, PostReloadAction> reload_actions_; |
|
koz (OOO until 15th September)
2013/06/05 08:34:11
s/reload_actions_/post_reload_actions_/ ?
benwells
2013/06/06 00:22:42
Done.
| |
| 46 content::NotificationRegistrar registrar_; | 66 content::NotificationRegistrar registrar_; |
| 47 Profile* profile_; | 67 Profile* profile_; |
| 48 | 68 |
| 49 DISALLOW_COPY_AND_ASSIGN(AppLoadService); | 69 DISALLOW_COPY_AND_ASSIGN(AppLoadService); |
| 50 }; | 70 }; |
| 51 | 71 |
| 52 } // namespace apps | 72 } // namespace apps |
| 53 | 73 |
| 54 #endif // APPS_APP_LOAD_SERVICE_H_ | 74 #endif // APPS_APP_LOAD_SERVICE_H_ |
| OLD | NEW |