OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/signin/core/browser/dice_header_helper.h" | 5 #include "components/signin/core/browser/dice_header_helper.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 DiceResponseParams params; | 43 DiceResponseParams params; |
44 ResponseHeaderDictionary header_dictionary = | 44 ResponseHeaderDictionary header_dictionary = |
45 ParseAccountConsistencyResponseHeader(header_value); | 45 ParseAccountConsistencyResponseHeader(header_value); |
46 ResponseHeaderDictionary::const_iterator it = header_dictionary.begin(); | 46 ResponseHeaderDictionary::const_iterator it = header_dictionary.begin(); |
47 for (; it != header_dictionary.end(); ++it) { | 47 for (; it != header_dictionary.end(); ++it) { |
48 const std::string key_name(it->first); | 48 const std::string key_name(it->first); |
49 const std::string value(it->second); | 49 const std::string value(it->second); |
50 if (key_name == kActionAttrName) { | 50 if (key_name == kActionAttrName) { |
51 params.user_intention = GetDiceActionFromHeader(value); | 51 params.user_intention = GetDiceActionFromHeader(value); |
52 } else if (key_name == kIdAttrName) { | 52 } else if (key_name == kIdAttrName) { |
53 params.obfuscated_gaia_id = value; | 53 params.gaia_id = value; |
54 } else if (key_name == kEmailAttrName) { | 54 } else if (key_name == kEmailAttrName) { |
55 params.email = value; | 55 params.email = value; |
56 } else if (key_name == kAuthUserAttrName) { | 56 } else if (key_name == kAuthUserAttrName) { |
57 bool parse_success = base::StringToInt(value, ¶ms.session_index); | 57 bool parse_success = base::StringToInt(value, ¶ms.session_index); |
58 if (!parse_success) | 58 if (!parse_success) |
59 params.session_index = -1; | 59 params.session_index = -1; |
60 } else if (key_name == kAuthorizationCodeAttrName) { | 60 } else if (key_name == kAuthorizationCodeAttrName) { |
61 params.authorization_code = value; | 61 params.authorization_code = value; |
62 } else { | 62 } else { |
63 DLOG(WARNING) << "Unexpected Gaia header attribute '" << key_name << "'."; | 63 DLOG(WARNING) << "Unexpected Gaia header attribute '" << key_name << "'."; |
64 } | 64 } |
65 } | 65 } |
66 | 66 |
67 if (params.obfuscated_gaia_id.empty() || params.email.empty() || | 67 if (params.gaia_id.empty() || params.email.empty() || |
68 params.session_index == -1) { | 68 params.session_index == -1) { |
69 DLOG(WARNING) << "Missing parameters for Dice header."; | 69 DLOG(WARNING) << "Missing parameters for Dice header."; |
70 params.user_intention = DiceAction::NONE; | 70 params.user_intention = DiceAction::NONE; |
71 } | 71 } |
72 | 72 |
73 if (params.user_intention == DiceAction::SIGNIN && | 73 if (params.user_intention == DiceAction::SIGNIN && |
74 params.authorization_code.empty()) { | 74 params.authorization_code.empty()) { |
75 DLOG(WARNING) << "Missing authorization code for Dice SIGNIN."; | 75 DLOG(WARNING) << "Missing authorization code for Dice SIGNIN."; |
76 params.user_intention = DiceAction::NONE; | 76 params.user_intention = DiceAction::NONE; |
77 } | 77 } |
(...skipping 13 matching lines...) Expand all Loading... |
91 bool sync_enabled) { | 91 bool sync_enabled) { |
92 std::vector<std::string> parts; | 92 std::vector<std::string> parts; |
93 parts.push_back("client_id=" + | 93 parts.push_back("client_id=" + |
94 GaiaUrls::GetInstance()->oauth2_chrome_client_id()); | 94 GaiaUrls::GetInstance()->oauth2_chrome_client_id()); |
95 if (sync_enabled) | 95 if (sync_enabled) |
96 parts.push_back("sync_account_id=" + account_id); | 96 parts.push_back("sync_account_id=" + account_id); |
97 return base::JoinString(parts, ","); | 97 return base::JoinString(parts, ","); |
98 } | 98 } |
99 | 99 |
100 } // namespace signin | 100 } // namespace signin |
OLD | NEW |