| 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 "google_apis/gaia/fake_gaia.h" | 5 #include "google_apis/gaia/fake_gaia.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 return result; | 95 return result; |
| 96 } | 96 } |
| 97 | 97 |
| 98 // Extracts the |access_token| from authorization header of |request|. | 98 // Extracts the |access_token| from authorization header of |request|. |
| 99 bool GetAccessToken(const HttpRequest& request, | 99 bool GetAccessToken(const HttpRequest& request, |
| 100 const char* auth_token_prefix, | 100 const char* auth_token_prefix, |
| 101 std::string* access_token) { | 101 std::string* access_token) { |
| 102 std::map<std::string, std::string>::const_iterator auth_header_entry = | 102 std::map<std::string, std::string>::const_iterator auth_header_entry = |
| 103 request.headers.find("Authorization"); | 103 request.headers.find("Authorization"); |
| 104 if (auth_header_entry != request.headers.end()) { | 104 if (auth_header_entry != request.headers.end()) { |
| 105 if (base::StartsWithASCII(auth_header_entry->second, auth_token_prefix, | 105 if (base::StartsWith(auth_header_entry->second, auth_token_prefix, |
| 106 true)) { | 106 base::CompareCase::SENSITIVE)) { |
| 107 *access_token = auth_header_entry->second.substr( | 107 *access_token = auth_header_entry->second.substr( |
| 108 strlen(auth_token_prefix)); | 108 strlen(auth_token_prefix)); |
| 109 return true; | 109 return true; |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 return false; | 113 return false; |
| 114 } | 114 } |
| 115 | 115 |
| 116 void SetCookies(BasicHttpResponse* http_response, | 116 void SetCookies(BasicHttpResponse* http_response, |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 769 if (token_info) { | 769 if (token_info) { |
| 770 base::DictionaryValue response_dict; | 770 base::DictionaryValue response_dict; |
| 771 response_dict.SetString("id", GetGaiaIdOfEmail(token_info->email)); | 771 response_dict.SetString("id", GetGaiaIdOfEmail(token_info->email)); |
| 772 response_dict.SetString("email", token_info->email); | 772 response_dict.SetString("email", token_info->email); |
| 773 response_dict.SetString("verified_email", token_info->email); | 773 response_dict.SetString("verified_email", token_info->email); |
| 774 FormatJSONResponse(response_dict, http_response); | 774 FormatJSONResponse(response_dict, http_response); |
| 775 } else { | 775 } else { |
| 776 http_response->set_code(net::HTTP_BAD_REQUEST); | 776 http_response->set_code(net::HTTP_BAD_REQUEST); |
| 777 } | 777 } |
| 778 } | 778 } |
| OLD | NEW |