OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/test/webdriver/commands/url_command.h" | |
6 | |
7 #include <string> | |
8 | |
9 #include "chrome/test/webdriver/commands/response.h" | |
10 #include "chrome/test/webdriver/webdriver_error.h" | |
11 #include "chrome/test/webdriver/webdriver_session.h" | |
12 | |
13 namespace webdriver { | |
14 | |
15 URLCommand::URLCommand(const std::vector<std::string>& path_segments, | |
16 const DictionaryValue* const parameters) | |
17 : WebDriverCommand(path_segments, parameters) {} | |
18 | |
19 URLCommand::~URLCommand() {} | |
20 | |
21 bool URLCommand::DoesGet() { | |
22 return true; | |
23 } | |
24 | |
25 bool URLCommand::DoesPost() { | |
26 return true; | |
27 } | |
28 | |
29 void URLCommand::ExecuteGet(Response* const response) { | |
30 std::string url; | |
31 Error* error = session_->GetURL(&url); | |
32 if (error) { | |
33 response->SetError(error); | |
34 return; | |
35 } | |
36 response->SetValue(new StringValue(url)); | |
37 } | |
38 | |
39 void URLCommand::ExecutePost(Response* const response) { | |
40 std::string url; | |
41 | |
42 if (!GetStringASCIIParameter("url", &url)) { | |
43 response->SetError(new Error(kBadRequest, "Missing 'url' parameter")); | |
44 return; | |
45 } | |
46 | |
47 Error* error = session_->NavigateToURL(url); | |
48 if (error) { | |
49 response->SetError(error); | |
50 return; | |
51 } | |
52 } | |
53 | |
54 | |
55 } // namespace webdriver | |
OLD | NEW |