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/webdriver_dispatch.h" | 5 #include "chrome/test/webdriver/webdriver_dispatch.h" |
6 | 6 |
7 #include <sstream> | 7 #include <sstream> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 break; | 166 break; |
167 } | 167 } |
168 | 168 |
169 case kBadRequest: | 169 case kBadRequest: |
170 case kSessionNotFound: | 170 case kSessionNotFound: |
171 http_response->set_status(status); | 171 http_response->set_status(status); |
172 break; | 172 break; |
173 | 173 |
174 case kMethodNotAllowed: { | 174 case kMethodNotAllowed: { |
175 const Value* const value = command_response.GetValue(); | 175 const Value* const value = command_response.GetValue(); |
176 if (!value->IsType(Value::TYPE_LIST)) { | 176 if (!value->IsList()) { |
177 // This should never happen. | 177 // This should never happen. |
178 http_response->set_status(HttpResponse::kInternalServerError); | 178 http_response->set_status(HttpResponse::kInternalServerError); |
179 http_response->SetBody( | 179 http_response->SetBody( |
180 "Unable to set 'Allow' header: response value was " | 180 "Unable to set 'Allow' header: response value was " |
181 "not a list of strings: " + command_response.ToJSON()); | 181 "not a list of strings: " + command_response.ToJSON()); |
182 return; | 182 return; |
183 } | 183 } |
184 | 184 |
185 const ListValue* const list_value = | 185 const ListValue* const list_value = |
186 static_cast<const ListValue* const>(value); | 186 static_cast<const ListValue* const>(value); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 std::string json(request_info->post_data, request_info->post_data_len); | 259 std::string json(request_info->post_data, request_info->post_data_len); |
260 std::string error_msg; | 260 std::string error_msg; |
261 scoped_ptr<Value> params(base::JSONReader::ReadAndReturnError( | 261 scoped_ptr<Value> params(base::JSONReader::ReadAndReturnError( |
262 json, true, NULL, &error_msg)); | 262 json, true, NULL, &error_msg)); |
263 if (!params.get()) { | 263 if (!params.get()) { |
264 response->SetError(new Error( | 264 response->SetError(new Error( |
265 kBadRequest, | 265 kBadRequest, |
266 "Failed to parse command data: " + error_msg + "\n Data: " + json)); | 266 "Failed to parse command data: " + error_msg + "\n Data: " + json)); |
267 return false; | 267 return false; |
268 } | 268 } |
269 if (!params->IsType(Value::TYPE_DICTIONARY)) { | 269 if (!params->IsDictionary()) { |
270 response->SetError(new Error( | 270 response->SetError(new Error( |
271 kBadRequest, | 271 kBadRequest, |
272 "Data passed in URL must be a dictionary. Data: " + json)); | 272 "Data passed in URL must be a dictionary. Data: " + json)); |
273 return false; | 273 return false; |
274 } | 274 } |
275 *parameters = static_cast<DictionaryValue*>(params.release()); | 275 *parameters = static_cast<DictionaryValue*>(params.release()); |
276 } | 276 } |
277 return true; | 277 return true; |
278 } | 278 } |
279 | 279 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 void Dispatcher::SetNotImplemented(const std::string& pattern) { | 331 void Dispatcher::SetNotImplemented(const std::string& pattern) { |
332 mg_set_uri_callback(context_, (root_ + pattern).c_str(), | 332 mg_set_uri_callback(context_, (root_ + pattern).c_str(), |
333 &SendNotImplementedError, NULL); | 333 &SendNotImplementedError, NULL); |
334 } | 334 } |
335 | 335 |
336 void Dispatcher::ForbidAllOtherRequests() { | 336 void Dispatcher::ForbidAllOtherRequests() { |
337 mg_set_uri_callback(context_, "*", &SendForbidden, NULL); | 337 mg_set_uri_callback(context_, "*", &SendForbidden, NULL); |
338 } | 338 } |
339 | 339 |
340 } // namespace webdriver | 340 } // namespace webdriver |
OLD | NEW |