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/target_locator_commands.h" | 5 #include "chrome/test/webdriver/commands/target_locator_commands.h" |
6 | 6 |
7 #include "base/string_number_conversions.h" | 7 #include "base/string_number_conversions.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/test/webdriver/commands/response.h" | 9 #include "chrome/test/webdriver/commands/response.h" |
10 #include "chrome/test/webdriver/session.h" | 10 #include "chrome/test/webdriver/session.h" |
11 #include "chrome/test/webdriver/web_element_id.h" | 11 #include "chrome/test/webdriver/web_element_id.h" |
12 #include "chrome/test/webdriver/webdriver_error.h" | 12 #include "chrome/test/webdriver/webdriver_error.h" |
13 | 13 |
14 namespace webdriver { | 14 namespace webdriver { |
15 | 15 |
16 WindowHandleCommand::WindowHandleCommand( | 16 WindowHandleCommand::WindowHandleCommand( |
17 const std::vector<std::string>& path_segments, | 17 const std::vector<std::string>& path_segments, |
18 DictionaryValue* parameters) | 18 DictionaryValue* parameters) |
19 : WebDriverCommand(path_segments, parameters) {} | 19 : WebDriverCommand(path_segments, parameters) {} |
20 | 20 |
21 WindowHandleCommand::~WindowHandleCommand() {} | 21 WindowHandleCommand::~WindowHandleCommand() {} |
22 | 22 |
23 bool WindowHandleCommand::DoesGet() { | 23 bool WindowHandleCommand::DoesGet() { |
24 return true; | 24 return true; |
25 } | 25 } |
26 | 26 |
27 void WindowHandleCommand::ExecuteGet(Response* const response) { | 27 void WindowHandleCommand::ExecuteGet(Response* const response) { |
28 response->SetValue(new StringValue( | 28 response->SetValue(base::StringValue::New( |
29 base::IntToString(session_->current_target().window_id))); | 29 base::IntToString(session_->current_target().window_id))); |
30 } | 30 } |
31 | 31 |
32 WindowHandlesCommand::WindowHandlesCommand( | 32 WindowHandlesCommand::WindowHandlesCommand( |
33 const std::vector<std::string>& path_segments, | 33 const std::vector<std::string>& path_segments, |
34 DictionaryValue* parameters) | 34 DictionaryValue* parameters) |
35 : WebDriverCommand(path_segments, parameters) {} | 35 : WebDriverCommand(path_segments, parameters) {} |
36 | 36 |
37 WindowHandlesCommand::~WindowHandlesCommand() {} | 37 WindowHandlesCommand::~WindowHandlesCommand() {} |
38 | 38 |
39 bool WindowHandlesCommand::DoesGet() { | 39 bool WindowHandlesCommand::DoesGet() { |
40 return true; | 40 return true; |
41 } | 41 } |
42 | 42 |
43 void WindowHandlesCommand::ExecuteGet(Response* const response) { | 43 void WindowHandlesCommand::ExecuteGet(Response* const response) { |
44 std::vector<int> window_ids; | 44 std::vector<int> window_ids; |
45 Error* error = session_->GetWindowIds(&window_ids); | 45 Error* error = session_->GetWindowIds(&window_ids); |
46 if (error) { | 46 if (error) { |
47 response->SetError(error); | 47 response->SetError(error); |
48 return; | 48 return; |
49 } | 49 } |
50 ListValue* id_list = new ListValue(); | 50 ListValue* id_list = new ListValue(); |
51 for (size_t i = 0; i < window_ids.size(); ++i) | 51 for (size_t i = 0; i < window_ids.size(); ++i) |
52 id_list->Append(new StringValue(base::IntToString(window_ids[i]))); | 52 id_list->Append(base::StringValue::New(base::IntToString(window_ids[i]))); |
53 response->SetValue(id_list); | 53 response->SetValue(id_list); |
54 } | 54 } |
55 | 55 |
56 WindowCommand::WindowCommand( | 56 WindowCommand::WindowCommand( |
57 const std::vector<std::string>& path_segments, | 57 const std::vector<std::string>& path_segments, |
58 DictionaryValue* parameters) | 58 DictionaryValue* parameters) |
59 : WebDriverCommand(path_segments, parameters) {} | 59 : WebDriverCommand(path_segments, parameters) {} |
60 | 60 |
61 WindowCommand::~WindowCommand() {} | 61 WindowCommand::~WindowCommand() {} |
62 | 62 |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 Error* error = session_->ExecuteScript( | 151 Error* error = session_->ExecuteScript( |
152 "return document.activeElement || document.body", &args, &result); | 152 "return document.activeElement || document.body", &args, &result); |
153 if (error) { | 153 if (error) { |
154 response->SetError(error); | 154 response->SetError(error); |
155 return; | 155 return; |
156 } | 156 } |
157 response->SetValue(result); | 157 response->SetValue(result); |
158 } | 158 } |
159 | 159 |
160 } // namespace webdriver | 160 } // namespace webdriver |
OLD | NEW |