Index: chrome/test/chromedriver/commands.cc |
diff --git a/chrome/test/chromedriver/commands.cc b/chrome/test/chromedriver/commands.cc |
index adc63479a81b776d7dadd8569355f934943797cb..260b8f335a3130423dbc10ea77527205114efa1a 100644 |
--- a/chrome/test/chromedriver/commands.cc |
+++ b/chrome/test/chromedriver/commands.cc |
@@ -4,11 +4,13 @@ |
#include "chrome/test/chromedriver/commands.h" |
+#include "base/bind.h" |
#include "base/callback.h" |
chrisgao (Use stgao instead)
2013/04/02 15:37:17
unused
chrisgao (Use stgao instead)
2013/04/03 18:51:43
Done.
|
#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" |
@@ -57,71 +59,25 @@ Status ExecuteNewSession( |
if (!params.GetDictionary("desiredCapabilities", &desired_caps)) |
return Status(kUnknownError, "cannot find dict 'desiredCapabilities'"); |
+ Capabilities capabilities; |
+ Status status = ParseCapabilities( |
+ *desired_caps, & capabilities, base::Bind(&file_util::PathExists)); |
+ if (status.IsError()) |
+ return status; |
+ |
scoped_ptr<Chrome> chrome; |
- Status status(kOk); |
- std::string android_package; |
- if (desired_caps->GetString("chromeOptions.android_package", |
- &android_package)) { |
+ if (capabilities.HasAndroidPackage()) { |
scoped_ptr<ChromeAndroidImpl> chrome_android(new ChromeAndroidImpl( |
context_getter, port, socket_factory)); |
- status = chrome_android->Launch(android_package); |
+ status = chrome_android->Launch(capabilities.android_package); |
chrome.reset(chrome_android.release()); |
} 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"); |
- } |
- |
scoped_ptr<ChromeDesktopImpl> chrome_desktop(new ChromeDesktopImpl( |
context_getter, port, socket_factory)); |
- status = chrome_desktop->Launch(chrome_exe, args_list, extensions_list, |
- prefs_dict, local_state_dict, |
- chrome_log_path); |
+ status = chrome_desktop->Launch( |
+ capabilities.chrome_exe, &capabilities.args_list, |
+ capabilities.extensions_list, capabilities.prefs_dict, |
+ capabilities.local_state_dict, capabilities.log_path); |
chrome.reset(chrome_desktop.release()); |
} |
if (status.IsError()) |