Chromium Code Reviews| Index: chrome/test/webdriver/commands/create_session.cc |
| diff --git a/chrome/test/webdriver/commands/create_session.cc b/chrome/test/webdriver/commands/create_session.cc |
| index a81986881bd3e31fc3faf415b6a427a0768f016d..81da75f1bcdc3a704dfb1da7059d9bd9fa29bd6e 100644 |
| --- a/chrome/test/webdriver/commands/create_session.cc |
| +++ b/chrome/test/webdriver/commands/create_session.cc |
| @@ -25,6 +25,8 @@ |
| #include "chrome/test/webdriver/session_manager.h" |
| #include "chrome/test/webdriver/webdriver_error.h" |
| +namespace webdriver { |
| + |
| namespace { |
| bool WriteBase64DataToFile(const FilePath& filename, |
| @@ -42,9 +44,18 @@ bool WriteBase64DataToFile(const FilePath& filename, |
| return true; |
| } |
| -} // namespace |
| +Error* SetBooleanOption( |
| + const base::DictionaryValue* dict, const std::string& key, bool* option) { |
| + Value* value = NULL; |
| + if (dict->GetWithoutPathExpansion(key, &value)) { |
|
Huyen
2011/08/08 20:51:18
Did you mean to do a Set here?
kkania
2011/08/09 17:10:24
No
Huyen
2011/08/09 18:10:02
Per offline conversation, please change name of th
|
| + if (!value->GetAsBoolean(option)) { |
| + return new Error(kUnknownError, key + " must be a boolean"); |
| + } |
| + } |
| + return NULL; |
| +} |
| -namespace webdriver { |
| +} // namespace |
| CreateSession::CreateSession(const std::vector<std::string>& path_segments, |
| const DictionaryValue* const parameters) |
| @@ -175,11 +186,24 @@ void CreateSession::ExecutePost(Response* const response) { |
| return; |
| } |
| + Session::Options options; |
| + Error* error = NULL; |
| + error = SetBooleanOption(capabilities, "chrome.nativeEvents", |
| + &options.use_native_events); |
| + if (!error) { |
| + error = SetBooleanOption(capabilities, "chrome.loadAsync", |
| + &options.load_async); |
| + } |
| + if (error) { |
| + response->SetError(error); |
| + return; |
| + } |
| + |
| // Session manages its own liftime, so do not call delete. |
| - Session* session = new Session(); |
| - Error* error = session->Init(browser_exe, |
| - temp_user_data_dir, |
| - command_line_options); |
| + Session* session = new Session(options); |
| + error = session->Init(browser_exe, |
| + temp_user_data_dir, |
| + command_line_options); |
| if (error) { |
| response->SetError(error); |
| return; |
| @@ -194,20 +218,6 @@ void CreateSession::ExecutePost(Response* const response) { |
| } |
| } |
| - bool native_events_required = false; |
| - Value* native_events_value = NULL; |
| - if (capabilities->GetWithoutPathExpansion( |
| - "chrome.nativeEvents", &native_events_value)) { |
| - if (native_events_value->GetAsBoolean(&native_events_required)) { |
| - session->set_use_native_events(native_events_required); |
| - } |
| - } |
| - bool screenshot_on_error = false; |
| - if (capabilities->GetBoolean( |
| - "takeScreenshotOnError", &screenshot_on_error)) { |
| - session->set_screenshot_on_error(screenshot_on_error); |
| - } |
| - |
| LOG(INFO) << "Created session " << session->id(); |
| // Redirect to a relative URI. Although prohibited by the HTTP standard, |
| // this is what the IEDriver does. Finding the actual IP address is |