OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 uri = uri.substr(manager->url_base().length()); | 313 uri = uri.substr(manager->url_base().length()); |
314 | 314 |
315 base::SplitString(uri, '/', path_segments); | 315 base::SplitString(uri, '/', path_segments); |
316 | 316 |
317 if (*method == "POST") { | 317 if (*method == "POST") { |
318 std::string json; | 318 std::string json; |
319 ReadRequestBody(request_info, connection, &json); | 319 ReadRequestBody(request_info, connection, &json); |
320 if (json.length() > 0) { | 320 if (json.length() > 0) { |
321 std::string error_msg; | 321 std::string error_msg; |
322 scoped_ptr<Value> params(base::JSONReader::ReadAndReturnError( | 322 scoped_ptr<Value> params(base::JSONReader::ReadAndReturnError( |
323 json, true, NULL, &error_msg)); | 323 json, base::JSON_ALLOW_TRAILING_COMMAS, NULL, &error_msg)); |
324 if (!params.get()) { | 324 if (!params.get()) { |
325 response->SetError(new Error( | 325 response->SetError(new Error( |
326 kBadRequest, | 326 kBadRequest, |
327 "Failed to parse command data: " + error_msg + | 327 "Failed to parse command data: " + error_msg + |
328 "\n Data: " + json)); | 328 "\n Data: " + json)); |
329 return false; | 329 return false; |
330 } | 330 } |
331 if (!params->IsType(Value::TYPE_DICTIONARY)) { | 331 if (!params->IsType(Value::TYPE_DICTIONARY)) { |
332 response->SetError(new Error( | 332 response->SetError(new Error( |
333 kBadRequest, | 333 kBadRequest, |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 ++callback) { | 418 ++callback) { |
419 if (MatchPattern(request_info->uri, callback->uri_regex_)) { | 419 if (MatchPattern(request_info->uri, callback->uri_regex_)) { |
420 callback->func_(connection, request_info, callback->user_data_); | 420 callback->func_(connection, request_info, callback->user_data_); |
421 return true; | 421 return true; |
422 } | 422 } |
423 } | 423 } |
424 return false; | 424 return false; |
425 } | 425 } |
426 | 426 |
427 } // namespace webdriver | 427 } // namespace webdriver |
OLD | NEW |