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 <utility> | 7 #include <utility> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base_paths.h" | 10 #include "base/base_paths.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/files/file_path.h" | 13 #include "base/files/file_path.h" |
14 #include "base/files/file_util.h" | 14 #include "base/files/file_util.h" |
15 #include "base/json/json_writer.h" | 15 #include "base/json/json_writer.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/memory/linked_ptr.h" | 17 #include "base/memory/linked_ptr.h" |
18 #include "base/path_service.h" | 18 #include "base/path_service.h" |
19 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 20 #include "base/strings/string_piece.h" |
20 #include "base/strings/string_split.h" | 21 #include "base/strings/string_split.h" |
21 #include "base/strings/string_util.h" | 22 #include "base/strings/string_util.h" |
22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
23 #include "base/values.h" | 24 #include "base/values.h" |
24 #include "google_apis/gaia/gaia_constants.h" | 25 #include "google_apis/gaia/gaia_constants.h" |
25 #include "google_apis/gaia/gaia_urls.h" | 26 #include "google_apis/gaia/gaia_urls.h" |
26 #include "net/base/url_util.h" | 27 #include "net/base/url_util.h" |
27 #include "net/cookies/parsed_cookie.h" | 28 #include "net/cookies/parsed_cookie.h" |
28 #include "net/http/http_status_code.h" | 29 #include "net/http/http_status_code.h" |
29 #include "net/test/embedded_test_server/http_request.h" | 30 #include "net/test/embedded_test_server/http_request.h" |
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
741 const AccessTokenInfo* token_info = NULL; | 742 const AccessTokenInfo* token_info = NULL; |
742 std::string access_token; | 743 std::string access_token; |
743 if (GetQueryParameter(request.content, "access_token", &access_token)) | 744 if (GetQueryParameter(request.content, "access_token", &access_token)) |
744 token_info = GetAccessTokenInfo(access_token); | 745 token_info = GetAccessTokenInfo(access_token); |
745 | 746 |
746 if (token_info) { | 747 if (token_info) { |
747 base::DictionaryValue response_dict; | 748 base::DictionaryValue response_dict; |
748 response_dict.SetString("issued_to", token_info->issued_to); | 749 response_dict.SetString("issued_to", token_info->issued_to); |
749 response_dict.SetString("audience", token_info->audience); | 750 response_dict.SetString("audience", token_info->audience); |
750 response_dict.SetString("user_id", token_info->user_id); | 751 response_dict.SetString("user_id", token_info->user_id); |
751 std::vector<std::string> scope_vector(token_info->scopes.begin(), | 752 std::vector<base::StringPiece> scope_vector(token_info->scopes.begin(), |
752 token_info->scopes.end()); | 753 token_info->scopes.end()); |
753 response_dict.SetString("scope", base::JoinString(scope_vector, " ")); | 754 response_dict.SetString("scope", base::JoinString(scope_vector, " ")); |
754 response_dict.SetInteger("expires_in", token_info->expires_in); | 755 response_dict.SetInteger("expires_in", token_info->expires_in); |
755 response_dict.SetString("email", token_info->email); | 756 response_dict.SetString("email", token_info->email); |
756 FormatJSONResponse(response_dict, http_response); | 757 FormatJSONResponse(response_dict, http_response); |
757 } else { | 758 } else { |
758 http_response->set_code(net::HTTP_BAD_REQUEST); | 759 http_response->set_code(net::HTTP_BAD_REQUEST); |
759 } | 760 } |
760 } | 761 } |
761 | 762 |
762 void FakeGaia::HandleIssueToken(const HttpRequest& request, | 763 void FakeGaia::HandleIssueToken(const HttpRequest& request, |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 http_response->AddCustomHeader("Google-Accounts-SAML", "Start"); | 846 http_response->AddCustomHeader("Google-Accounts-SAML", "Start"); |
846 http_response->AddCustomHeader("Location", redirect_url); | 847 http_response->AddCustomHeader("Location", redirect_url); |
847 } | 848 } |
848 | 849 |
849 void FakeGaia::HandleGetCheckConnectionInfo( | 850 void FakeGaia::HandleGetCheckConnectionInfo( |
850 const net::test_server::HttpRequest& request, | 851 const net::test_server::HttpRequest& request, |
851 net::test_server::BasicHttpResponse* http_response) { | 852 net::test_server::BasicHttpResponse* http_response) { |
852 base::ListValue connection_list; | 853 base::ListValue connection_list; |
853 FormatJSONResponse(connection_list, http_response); | 854 FormatJSONResponse(connection_list, http_response); |
854 } | 855 } |
OLD | NEW |