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/log_command.h" | |
6 | |
7 #include "base/strings/string_util.h" | |
8 #include "base/values.h" | |
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 LogCommand::LogCommand( | |
16 const std::vector<std::string>& path_segments, | |
17 DictionaryValue* parameters) | |
18 : WebDriverCommand(path_segments, parameters) { | |
19 } | |
20 | |
21 LogCommand::~LogCommand() { | |
22 } | |
23 | |
24 bool LogCommand::DoesPost() { | |
25 return true; | |
26 } | |
27 | |
28 void LogCommand::ExecutePost(Response* const response) { | |
29 std::string type; | |
30 if (!GetStringParameter("type", &type)) { | |
31 response->SetError(new Error(kUnknownError, "Missing or invalid 'type'")); | |
32 return; | |
33 } | |
34 | |
35 LogType log_type; | |
36 if (!LogType::FromString(type, &log_type)) { | |
37 response->SetError(new Error(kUnknownError, "Unknown log type: " + type)); | |
38 return; | |
39 } | |
40 | |
41 if (log_type.type() == LogType::kDriver) { | |
42 response->SetValue(session_->GetLog()); | |
43 } else { | |
44 response->SetError(new Error(kUnknownError, "Unrecognized type: " + type)); | |
45 return; | |
46 } | |
47 } | |
48 | |
49 } // namespace webdriver | |
OLD | NEW |