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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 base::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 true /* only_allow_apps */)) { | |
70 return false; | 69 return false; |
71 } | 70 } |
72 | 71 |
73 // Schedule the app to be launched once loaded. | 72 // Schedule the app to be launched once loaded. |
74 PostReloadAction& action = post_reload_actions_[extension_id]; | 73 PostReloadAction& action = post_reload_actions_[extension_id]; |
75 action.action_type = LAUNCH_FOR_LOAD_AND_LAUNCH; | 74 action.action_type = LAUNCH_FOR_LOAD_AND_LAUNCH; |
76 action.command_line = command_line; | 75 action.command_line = command_line; |
77 action.current_dir = current_dir; | 76 action.current_dir = current_dir; |
78 return true; | 77 return true; |
79 } | 78 } |
80 | 79 |
81 bool AppLoadService::Load(const base::FilePath& extension_path) { | 80 bool AppLoadService::Load(const base::FilePath& extension_path) { |
82 ExtensionService* extension_service = | 81 ExtensionService* extension_service = |
83 ExtensionSystem::Get(profile_)->extension_service(); | 82 ExtensionSystem::Get(profile_)->extension_service(); |
84 std::string extension_id; | 83 std::string extension_id; |
85 return extensions::UnpackedInstaller::Create(extension_service) | 84 return extensions::UnpackedInstaller::Create(extension_service)-> |
86 ->LoadFromCommandLine(base::FilePath(extension_path), &extension_id, | 85 LoadFromCommandLine(base::FilePath(extension_path), &extension_id); |
87 true /* only_allow_apps */); | |
88 } | 86 } |
89 | 87 |
90 // static | 88 // static |
91 AppLoadService* AppLoadService::Get(Profile* profile) { | 89 AppLoadService* AppLoadService::Get(Profile* profile) { |
92 return apps::AppLoadServiceFactory::GetForProfile(profile); | 90 return apps::AppLoadServiceFactory::GetForProfile(profile); |
93 } | 91 } |
94 | 92 |
95 void AppLoadService::Observe(int type, | 93 void AppLoadService::Observe(int type, |
96 const content::NotificationSource& source, | 94 const content::NotificationSource& source, |
97 const content::NotificationDetails& details) { | 95 const content::NotificationDetails& details) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 Extension::DISABLE_RELOAD) != 0; | 151 Extension::DISABLE_RELOAD) != 0; |
154 } | 152 } |
155 return false; | 153 return false; |
156 } | 154 } |
157 | 155 |
158 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { | 156 bool AppLoadService::HasPostReloadAction(const std::string& extension_id) { |
159 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); | 157 return post_reload_actions_.find(extension_id) != post_reload_actions_.end(); |
160 } | 158 } |
161 | 159 |
162 } // namespace apps | 160 } // namespace apps |
OLD | NEW |