| Index: chrome/test/chromedriver/chrome_launcher.cc
|
| diff --git a/chrome/test/chromedriver/chrome_launcher.cc b/chrome/test/chromedriver/chrome_launcher.cc
|
| index 161377b16add638b735486e623e9d66d8719d512..77422957ff8a24541c2a7295e85e8a15a5db799a 100644
|
| --- a/chrome/test/chromedriver/chrome_launcher.cc
|
| +++ b/chrome/test/chromedriver/chrome_launcher.cc
|
| @@ -34,15 +34,11 @@
|
| namespace {
|
|
|
| Status PrepareCommandLine(int port,
|
| - const base::FilePath& exe,
|
| - const base::ListValue* args,
|
| - const base::ListValue* extensions,
|
| - const base::DictionaryValue* prefs,
|
| - const base::DictionaryValue* local_state,
|
| + const Capabilities& capabilities,
|
| CommandLine* prepared_command,
|
| base::ScopedTempDir* user_data_dir,
|
| base::ScopedTempDir* extension_dir) {
|
| - base::FilePath program = exe;
|
| + base::FilePath program = capabilities.chrome_exe;
|
| if (program.empty()) {
|
| if (!FindChrome(&program))
|
| return Status(kUnknownError, "cannot find Chrome binary");
|
| @@ -56,8 +52,9 @@ Status PrepareCommandLine(int port,
|
| command.AppendSwitchASCII("logging-level", "1");
|
| command.AppendArg("data:text/html;charset=utf-8,");
|
|
|
| - if (args) {
|
| - Status status = internal::ProcessCommandLineArgs(args, &command);
|
| + if (!capabilities.args.empty()) {
|
| + Status status = internal::ProcessCommandLineArgs(
|
| + &capabilities.args, &command);
|
| if (status.IsError())
|
| return status;
|
| }
|
| @@ -67,17 +64,17 @@ Status PrepareCommandLine(int port,
|
| return Status(kUnknownError, "cannot create temp dir for user data dir");
|
| command.AppendSwitchPath("user-data-dir", user_data_dir->path());
|
| Status status = internal::PrepareUserDataDir(
|
| - user_data_dir->path(), prefs, local_state);
|
| + user_data_dir->path(), capabilities.prefs, capabilities.local_state);
|
| if (status.IsError())
|
| return status;
|
| }
|
|
|
| - if (extensions) {
|
| + if (capabilities.extensions) {
|
| if (!extension_dir->CreateUniqueTempDir())
|
| return Status(kUnknownError,
|
| "cannot create temp dir for unpacking extensions");
|
| Status status = internal::ProcessExtensions(
|
| - extensions, extension_dir->path(), &command);
|
| + capabilities.extensions, extension_dir->path(), &command);
|
| if (status.IsError())
|
| return status;
|
| }
|
| @@ -159,30 +156,24 @@ Status WaitForDevToolsAndCheckVersion(
|
| return Status(kUnknownError, "unable to discover open pages");
|
| }
|
|
|
| -} // namespace
|
| -
|
| Status LaunchDesktopChrome(URLRequestContextGetter* context_getter,
|
| int port,
|
| const SyncWebSocketFactory& socket_factory,
|
| - const base::FilePath& exe,
|
| - const base::ListValue* args,
|
| - const base::ListValue* extensions,
|
| - const base::DictionaryValue* prefs,
|
| - const base::DictionaryValue* local_state,
|
| - const std::string& log_path,
|
| + const Capabilities& capabilities,
|
| scoped_ptr<Chrome>* chrome) {
|
| CommandLine command(CommandLine::NO_PROGRAM);
|
| base::ScopedTempDir user_data_dir;
|
| base::ScopedTempDir extension_dir;
|
| - PrepareCommandLine(port, exe, args, extensions, prefs, local_state,
|
| + PrepareCommandLine(port, capabilities,
|
| &command, &user_data_dir, &extension_dir);
|
| base::LaunchOptions options;
|
|
|
| #if !defined(OS_WIN)
|
| base::EnvironmentVector environ;
|
| - if (!log_path.empty()) {
|
| - environ.push_back(base::EnvironmentVector::value_type("CHROME_LOG_FILE",
|
| - log_path));
|
| + if (!capabilities.log_path.empty()) {
|
| + environ.push_back(
|
| + base::EnvironmentVector::value_type("CHROME_LOG_FILE",
|
| + capabilities.log_path));
|
| options.environ = &environ;
|
| }
|
| #endif
|
| @@ -241,13 +232,13 @@ Status LaunchDesktopChrome(URLRequestContextGetter* context_getter,
|
| Status LaunchAndroidChrome(URLRequestContextGetter* context_getter,
|
| int port,
|
| const SyncWebSocketFactory& socket_factory,
|
| - const std::string& package_name,
|
| + const Capabilities& capabilities,
|
| scoped_ptr<Chrome>* chrome) {
|
| // TODO(frankf): Figure out how this should be installed to
|
| // make this work for all platforms.
|
| base::FilePath adb_commands(FILE_PATH_LITERAL("adb_commands.py"));
|
| CommandLine command(adb_commands);
|
| - command.AppendSwitchASCII("package", package_name);
|
| + command.AppendSwitchASCII("package", capabilities.android_package);
|
| command.AppendSwitch("launch");
|
| command.AppendSwitchASCII("port", base::IntToString(port));
|
|
|
| @@ -275,6 +266,22 @@ Status LaunchAndroidChrome(URLRequestContextGetter* context_getter,
|
| return Status(kOk);
|
| }
|
|
|
| +} // namespace
|
| +
|
| +Status LaunchChrome(URLRequestContextGetter* context_getter,
|
| + int port,
|
| + const SyncWebSocketFactory& socket_factory,
|
| + const Capabilities& capabilities,
|
| + scoped_ptr<Chrome>* chrome) {
|
| + if (capabilities.HasAndroidPackage()) {
|
| + return LaunchAndroidChrome(
|
| + context_getter, port, socket_factory, capabilities, chrome);
|
| + } else {
|
| + return LaunchDesktopChrome(
|
| + context_getter, port, socket_factory, capabilities, chrome);
|
| + }
|
| +}
|
| +
|
| namespace internal {
|
|
|
| Status ProcessCommandLineArgs(const base::ListValue* args,
|
|
|