OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/test/webdriver/commands/keys_command.h" | 5 #include "chrome/test/webdriver/commands/keys_command.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "chrome/test/webdriver/commands/response.h" | 8 #include "chrome/test/webdriver/commands/response.h" |
9 #include "chrome/test/webdriver/webdriver_error.h" | 9 #include "chrome/test/webdriver/webdriver_error.h" |
10 #include "chrome/test/webdriver/webdriver_session.h" | 10 #include "chrome/test/webdriver/webdriver_session.h" |
11 #include "chrome/test/webdriver/webdriver_util.h" | 11 #include "chrome/test/webdriver/webdriver_util.h" |
12 | 12 |
13 namespace webdriver { | 13 namespace webdriver { |
14 | 14 |
15 KeysCommand::KeysCommand(const std::vector<std::string>& path_segments, | 15 KeysCommand::KeysCommand(const std::vector<std::string>& path_segments, |
16 const DictionaryValue* const parameters) | 16 const DictionaryValue* const parameters) |
17 : WebDriverCommand(path_segments, parameters) {} | 17 : WebDriverCommand(path_segments, parameters) {} |
18 | 18 |
19 KeysCommand::~KeysCommand() {} | 19 KeysCommand::~KeysCommand() {} |
20 | 20 |
21 bool KeysCommand::DoesPost() { | 21 bool KeysCommand::DoesPost() { |
22 return true; | 22 return true; |
23 } | 23 } |
24 | 24 |
25 void KeysCommand::ExecutePost(Response* const response) { | 25 void KeysCommand::ExecutePost(Response* const response) { |
26 ListValue* key_list; | 26 const ListValue* key_list; |
27 if (!GetListParameter("value", &key_list)) { | 27 if (!GetListParameter("value", &key_list)) { |
28 response->SetError(new Error( | 28 response->SetError(new Error( |
29 kBadRequest, "Missing or invalid 'value' parameter")); | 29 kBadRequest, "Missing or invalid 'value' parameter")); |
30 return; | 30 return; |
31 } | 31 } |
32 | 32 |
33 // Flatten the given array of strings into one. | 33 // Flatten the given array of strings into one. |
34 string16 keys; | 34 string16 keys; |
35 Error* error = FlattenStringArray(key_list, &keys); | 35 Error* error = FlattenStringArray(key_list, &keys); |
36 if (error) { | 36 if (error) { |
37 response->SetError(error); | 37 response->SetError(error); |
38 return; | 38 return; |
39 } | 39 } |
40 | 40 |
41 error = session_->SendKeys(keys); | 41 error = session_->SendKeys(keys); |
42 if (error) { | 42 if (error) { |
43 response->SetError(error); | 43 response->SetError(error); |
44 return; | 44 return; |
45 } | 45 } |
46 } | 46 } |
47 | 47 |
48 } // namespace webdriver | 48 } // namespace webdriver |
OLD | NEW |