Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2250)

Unified Diff: apps/app_load_service.cc

Issue 16357005: Pass command line arguments through with --load-and-launch-app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Feedback Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « apps/app_load_service.h ('k') | apps/load_and_launch_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: apps/app_load_service.cc
diff --git a/apps/app_load_service.cc b/apps/app_load_service.cc
index 1d78554120b7c486beb4747b7c8b0d824fb3eeea..f3d45e155f45dd90f0ab78e0deb91bcd1cd03093 100644
--- a/apps/app_load_service.cc
+++ b/apps/app_load_service.cc
@@ -10,6 +10,8 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/platform_app_launcher.h"
#include "chrome/browser/extensions/shell_window_registry.h"
+#include "chrome/browser/extensions/unpacked_installer.h"
+#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_notification_types.h"
#include "chrome/common/extensions/extension.h"
#include "chrome/common/extensions/extension_constants.h"
@@ -20,17 +22,12 @@
using extensions::Extension;
using extensions::ExtensionPrefs;
-namespace {
-
-enum PostReloadAction {
- RELOAD_ACTION_LAUNCH,
- RELOAD_ACTION_RESTART,
-};
-
-} // namespace
-
namespace apps {
+AppLoadService::PostReloadAction::PostReloadAction()
+ : command_line(CommandLine::NO_PROGRAM) {
+}
+
AppLoadService::AppLoadService(Profile* profile)
: profile_(profile) {
registrar_.Add(
@@ -44,15 +41,28 @@ AppLoadService::AppLoadService(Profile* profile)
AppLoadService::~AppLoadService() {}
void AppLoadService::RestartApplication(const std::string& extension_id) {
- reload_actions_[extension_id] = RELOAD_ACTION_RESTART;
+ post_reload_actions_[extension_id].action_type = RESTART;
ExtensionService* service = extensions::ExtensionSystem::Get(profile_)->
extension_service();
DCHECK(service);
service->ReloadExtension(extension_id);
}
-void AppLoadService::ScheduleLaunchOnLoad(const std::string& extension_id) {
- reload_actions_[extension_id] = RELOAD_ACTION_LAUNCH;
+bool AppLoadService::LoadAndLaunch(const base::FilePath& extension_path,
+ const CommandLine& command_line,
+ const base::FilePath& current_dir) {
+ std::string extension_id;
+ if (!extensions::UnpackedInstaller::Create(profile_->GetExtensionService())->
+ LoadFromCommandLine(base::FilePath(extension_path), &extension_id)) {
+ return false;
+ }
+
+ // Schedule the app to be launched once loaded.
+ PostReloadAction& action = post_reload_actions_[extension_id];
+ action.action_type = LAUNCH_WITH_COMMAND_LINE;
+ action.command_line = command_line;
+ action.current_dir = current_dir;
+ return true;
}
// static
@@ -66,23 +76,28 @@ void AppLoadService::Observe(int type,
switch (type) {
case chrome::NOTIFICATION_EXTENSION_LOADED: {
const Extension* extension = content::Details<Extension>(details).ptr();
- std::map<std::string, int>::iterator it = reload_actions_.find(
- extension->id());
- if (it == reload_actions_.end())
+ std::map<std::string, PostReloadAction>::iterator it =
+ post_reload_actions_.find(extension->id());
+ if (it == post_reload_actions_.end())
break;
- switch (it->second) {
- case RELOAD_ACTION_LAUNCH:
+ switch (it->second.action_type) {
+ case LAUNCH:
extensions::LaunchPlatformApp(profile_, extension);
break;
- case RELOAD_ACTION_RESTART:
+ case RESTART:
extensions::RestartPlatformApp(profile_, extension);
break;
+ case LAUNCH_WITH_COMMAND_LINE:
+ extensions::LaunchPlatformAppWithCommandLine(
+ profile_, extension, &it->second.command_line,
+ it->second.current_dir);
+ break;
default:
NOTREACHED();
}
- reload_actions_.erase(it);
+ post_reload_actions_.erase(it);
break;
}
case chrome::NOTIFICATION_EXTENSION_UNLOADED: {
@@ -97,7 +112,8 @@ void AppLoadService::Observe(int type,
Extension::DISABLE_RELOAD) &&
!extensions::ShellWindowRegistry::Get(profile_)->
GetShellWindowsForApp(unload_info->extension->id()).empty()) {
- reload_actions_[unload_info->extension->id()] = RELOAD_ACTION_LAUNCH;
+ post_reload_actions_[unload_info->extension->id()].action_type =
+ LAUNCH;
}
}
break;
« no previous file with comments | « apps/app_load_service.h ('k') | apps/load_and_launch_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698