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 #include "apps/app_load_service.h" | 5 #include "apps/app_load_service.h" |
6 | 6 |
7 #include "apps/app_load_service_factory.h" | 7 #include "apps/app_load_service_factory.h" |
8 #include "apps/app_restore_service.h" | 8 #include "apps/app_restore_service.h" |
9 #include "apps/launcher.h" | 9 #include "apps/launcher.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 11 matching lines...) Expand all Loading... |
22 #include "extensions/common/extension.h" | 22 #include "extensions/common/extension.h" |
23 | 23 |
24 using extensions::Extension; | 24 using extensions::Extension; |
25 using extensions::ExtensionPrefs; | 25 using extensions::ExtensionPrefs; |
26 using extensions::ExtensionSystem; | 26 using extensions::ExtensionSystem; |
27 | 27 |
28 namespace apps { | 28 namespace apps { |
29 | 29 |
30 AppLoadService::PostReloadAction::PostReloadAction() | 30 AppLoadService::PostReloadAction::PostReloadAction() |
31 : action_type(LAUNCH), | 31 : action_type(LAUNCH), |
32 command_line(CommandLine::NO_PROGRAM) { | 32 command_line(base::CommandLine::NO_PROGRAM) { |
33 } | 33 } |
34 | 34 |
35 AppLoadService::AppLoadService(Profile* profile) | 35 AppLoadService::AppLoadService(Profile* profile) |
36 : profile_(profile) { | 36 : profile_(profile) { |
37 registrar_.Add(this, | 37 registrar_.Add(this, |
38 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, | 38 extensions::NOTIFICATION_EXTENSION_HOST_DID_STOP_LOADING, |
39 content::NotificationService::AllSources()); | 39 content::NotificationService::AllSources()); |
40 extensions::ExtensionRegistry::Get(profile_)->AddObserver(this); | 40 extensions::ExtensionRegistry::Get(profile_)->AddObserver(this); |
41 } | 41 } |
42 | 42 |
43 AppLoadService::~AppLoadService() { | 43 AppLoadService::~AppLoadService() { |
44 extensions::ExtensionRegistry::Get(profile_)->RemoveObserver(this); | 44 extensions::ExtensionRegistry::Get(profile_)->RemoveObserver(this); |
45 } | 45 } |
46 | 46 |
47 void AppLoadService::RestartApplication(const std::string& extension_id) { | 47 void AppLoadService::RestartApplication(const std::string& extension_id) { |
48 post_reload_actions_[extension_id].action_type = RESTART; | 48 post_reload_actions_[extension_id].action_type = RESTART; |
49 ExtensionService* service = extensions::ExtensionSystem::Get(profile_)-> | 49 ExtensionService* service = extensions::ExtensionSystem::Get(profile_)-> |
50 extension_service(); | 50 extension_service(); |
51 DCHECK(service); | 51 DCHECK(service); |
52 service->ReloadExtension(extension_id); | 52 service->ReloadExtension(extension_id); |
53 } | 53 } |
54 | 54 |
55 void AppLoadService::RestartApplicationIfRunning( | 55 void AppLoadService::RestartApplicationIfRunning( |
56 const std::string& extension_id) { | 56 const std::string& extension_id) { |
57 if (apps::AppRestoreService::Get(profile_)->IsAppRestorable(extension_id)) | 57 if (apps::AppRestoreService::Get(profile_)->IsAppRestorable(extension_id)) |
58 RestartApplication(extension_id); | 58 RestartApplication(extension_id); |
59 } | 59 } |
60 | 60 |
61 bool AppLoadService::LoadAndLaunch(const base::FilePath& extension_path, | 61 bool AppLoadService::LoadAndLaunch(const base::FilePath& extension_path, |
62 const CommandLine& command_line, | 62 const base::CommandLine& command_line, |
63 const base::FilePath& current_dir) { | 63 const base::FilePath& current_dir) { |
64 ExtensionService* extension_service = | 64 ExtensionService* extension_service = |
65 ExtensionSystem::Get(profile_)->extension_service(); | 65 ExtensionSystem::Get(profile_)->extension_service(); |
66 std::string extension_id; | 66 std::string extension_id; |
67 if (!extensions::UnpackedInstaller::Create(extension_service)-> | 67 if (!extensions::UnpackedInstaller::Create(extension_service)-> |
68 LoadFromCommandLine(base::FilePath(extension_path), &extension_id)) { | 68 LoadFromCommandLine(base::FilePath(extension_path), &extension_id)) { |
69 return false; | 69 return false; |
70 } | 70 } |
71 | 71 |
72 // Schedule the app to be launched once loaded. | 72 // Schedule the app to be launched once loaded. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 Extension::DISABLE_RELOAD) != 0; | 140 Extension::DISABLE_RELOAD) != 0; |
141 } | 141 } |
142 return false; | 142 return false; |
143 } | 143 } |
144 | 144 |
145 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { | 145 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { |
146 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); | 146 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); |
147 } | 147 } |
148 | 148 |
149 } // namespace apps | 149 } // namespace apps |
OLD | NEW |