OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chromedriver/server/http_handler.h" | 5 #include "chrome/test/chromedriver/server/http_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
715 new net::HttpServerResponseInfo(net::HTTP_OK)); | 715 new net::HttpServerResponseInfo(net::HTTP_OK)); |
716 response->SetBody(body, "application/json; charset=utf-8"); | 716 response->SetBody(body, "application/json; charset=utf-8"); |
717 return response.Pass(); | 717 return response.Pass(); |
718 } | 718 } |
719 | 719 |
720 namespace internal { | 720 namespace internal { |
721 | 721 |
722 const char kNewSessionPathPattern[] = "session"; | 722 const char kNewSessionPathPattern[] = "session"; |
723 | 723 |
724 bool MatchesMethod(HttpMethod command_method, const std::string& method) { | 724 bool MatchesMethod(HttpMethod command_method, const std::string& method) { |
725 std::string lower_method = base::StringToLowerASCII(method); | 725 std::string lower_method = base::ToLowerASCII(method); |
726 switch (command_method) { | 726 switch (command_method) { |
727 case kGet: | 727 case kGet: |
728 return lower_method == "get"; | 728 return lower_method == "get"; |
729 case kPost: | 729 case kPost: |
730 return lower_method == "post" || lower_method == "put"; | 730 return lower_method == "post" || lower_method == "put"; |
731 case kDelete: | 731 case kDelete: |
732 return lower_method == "delete"; | 732 return lower_method == "delete"; |
733 } | 733 } |
734 return false; | 734 return false; |
735 } | 735 } |
736 | 736 |
737 bool MatchesCommand(const std::string& method, | 737 bool MatchesCommand(const std::string& method, |
738 const std::string& path, | 738 const std::string& path, |
739 const CommandMapping& command, | 739 const CommandMapping& command, |
740 std::string* session_id, | 740 std::string* session_id, |
741 base::DictionaryValue* out_params) { | 741 base::DictionaryValue* out_params) { |
742 if (!MatchesMethod(command.method, method)) | 742 if (!MatchesMethod(command.method, method)) |
(...skipping 19 matching lines...) Expand all Loading... |
762 params.SetString(name, path_parts[i]); | 762 params.SetString(name, path_parts[i]); |
763 } else if (command_path_parts[i] != path_parts[i]) { | 763 } else if (command_path_parts[i] != path_parts[i]) { |
764 return false; | 764 return false; |
765 } | 765 } |
766 } | 766 } |
767 out_params->MergeDictionary(¶ms); | 767 out_params->MergeDictionary(¶ms); |
768 return true; | 768 return true; |
769 } | 769 } |
770 | 770 |
771 } // namespace internal | 771 } // namespace internal |
OLD | NEW |