| Index: chrome/test/chromedriver/commands.cc
|
| diff --git a/chrome/test/chromedriver/commands.cc b/chrome/test/chromedriver/commands.cc
|
| index 43a2e9819feea31901e68bd7aab5dcbab8807b30..60bdb7feeb6d7c1094da3f45be34c9abc3cbbc1a 100644
|
| --- a/chrome/test/chromedriver/commands.cc
|
| +++ b/chrome/test/chromedriver/commands.cc
|
| @@ -4,11 +4,12 @@
|
|
|
| #include "chrome/test/chromedriver/commands.h"
|
|
|
| -#include "base/callback.h"
|
| +#include "base/bind.h"
|
| #include "base/file_util.h"
|
| #include "base/stringprintf.h"
|
| #include "base/sys_info.h"
|
| #include "base/values.h"
|
| +#include "chrome/test/chromedriver/capabilities_parser.h"
|
| #include "chrome/test/chromedriver/chrome/chrome.h"
|
| #include "chrome/test/chromedriver/chrome/chrome_android_impl.h"
|
| #include "chrome/test/chromedriver/chrome/chrome_desktop_impl.h"
|
| @@ -58,75 +59,26 @@ Status ExecuteNewSession(
|
| if (!params.GetDictionary("desiredCapabilities", &desired_caps))
|
| return Status(kUnknownError, "cannot find dict 'desiredCapabilities'");
|
|
|
| - scoped_ptr<Chrome> chrome;
|
| - std::string android_package;
|
| - if (desired_caps->GetString("chromeOptions.android_package",
|
| - &android_package)) {
|
| - Status status = LaunchAndroidChrome(
|
| - context_getter, port, socket_factory, android_package, &chrome);
|
| - if (status.IsError())
|
| - return status;
|
| - } else {
|
| - base::FilePath::StringType path_str;
|
| - base::FilePath chrome_exe;
|
| - if (desired_caps->GetString("chromeOptions.binary", &path_str)) {
|
| - chrome_exe = base::FilePath(path_str);
|
| - if (!file_util::PathExists(chrome_exe)) {
|
| - std::string message = base::StringPrintf(
|
| - "no chrome binary at %" PRFilePath,
|
| - path_str.c_str());
|
| - return Status(kUnknownError, message);
|
| - }
|
| - }
|
| -
|
| - const base::Value* args = NULL;
|
| - const base::ListValue* args_list = NULL;
|
| - if (desired_caps->Get("chromeOptions.args", &args) &&
|
| - !args->GetAsList(&args_list)) {
|
| - return Status(kUnknownError,
|
| - "command line arguments for chrome must be a list");
|
| - }
|
| -
|
| - const base::Value* prefs = NULL;
|
| - const base::DictionaryValue* prefs_dict = NULL;
|
| - if (desired_caps->Get("chromeOptions.prefs", &prefs) &&
|
| - !prefs->GetAsDictionary(&prefs_dict)) {
|
| - return Status(kUnknownError, "'prefs' must be a dictionary");
|
| - }
|
| -
|
| - const base::Value* local_state = NULL;
|
| - const base::DictionaryValue* local_state_dict = NULL;
|
| - if (desired_caps->Get("chromeOptions.localState", &local_state) &&
|
| - !prefs->GetAsDictionary(&prefs_dict)) {
|
| - return Status(kUnknownError, "'localState' must be a dictionary");
|
| - }
|
| -
|
| - const base::Value* extensions = NULL;
|
| - const base::ListValue* extensions_list = NULL;
|
| - if (desired_caps->Get("chromeOptions.extensions", &extensions)
|
| - && !extensions->GetAsList(&extensions_list)) {
|
| - return Status(kUnknownError,
|
| - "chrome extensions must be a list");
|
| - }
|
| -
|
| - const base::Value* log_path = NULL;
|
| - std::string chrome_log_path;
|
| - if (desired_caps->Get("chromeOptions.logPath", &log_path) &&
|
| - !log_path->GetAsString(&chrome_log_path)) {
|
| - return Status(kUnknownError,
|
| - "chrome log path must be a string");
|
| - }
|
| -
|
| - Status status = LaunchDesktopChrome(
|
| - context_getter, port, socket_factory,
|
| - chrome_exe, args_list, extensions_list,
|
| - prefs_dict, local_state_dict, chrome_log_path, &chrome);
|
| + Capabilities capabilities;
|
| + const base::Value* chrome_options = NULL;
|
| + if (desired_caps->Get("chromeOptions", &chrome_options)) {
|
| + const base::DictionaryValue* chrome_options_dict = NULL;
|
| + if (!chrome_options->GetAsDictionary(&chrome_options_dict))
|
| + return Status(kUnknownError, "'chromeOptions' must be a dictionary");
|
| + Status status = capabilities.Parse(*chrome_options_dict,
|
| + base::Bind(&file_util::PathExists));
|
| if (status.IsError())
|
| return status;
|
| }
|
|
|
| + scoped_ptr<Chrome> chrome;
|
| + Status status = LaunchChrome(context_getter, port, socket_factory,
|
| + capabilities, &chrome);
|
| + if (status.IsError())
|
| + return status;
|
| +
|
| std::list<std::string> web_view_ids;
|
| - Status status = chrome->GetWebViewIds(&web_view_ids);
|
| + status = chrome->GetWebViewIds(&web_view_ids);
|
| if (status.IsError() || web_view_ids.empty()) {
|
| chrome->Quit();
|
| return status.IsError() ? status :
|
|
|