| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 "components/autofill/browser/wallet/encryption_escrow_client.h" | 5 #include "components/autofill/browser/wallet/encryption_escrow_client.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/stringprintf.h" | 10 #include "base/stringprintf.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 void EncryptionEscrowClient::EncryptOneTimePad( | 54 void EncryptionEscrowClient::EncryptOneTimePad( |
| 55 const std::vector<uint8>& one_time_pad) { | 55 const std::vector<uint8>& one_time_pad) { |
| 56 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 56 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 57 size_t num_bits = one_time_pad.size() * 8; | 57 size_t num_bits = one_time_pad.size() * 8; |
| 58 DCHECK_LE(num_bits, kMaxBits); | 58 DCHECK_LE(num_bits, kMaxBits); |
| 59 DCHECK_GE(num_bits, kMinBits); | 59 DCHECK_GE(num_bits, kMinBits); |
| 60 | 60 |
| 61 request_type_ = ENCRYPT_ONE_TIME_PAD; | 61 request_type_ = ENCRYPT_ONE_TIME_PAD; |
| 62 | 62 |
| 63 std::string post_body = StringPrintf( | 63 std::string post_body = base::StringPrintf( |
| 64 kEncryptOtpBodyFormat, | 64 kEncryptOtpBodyFormat, |
| 65 base::HexEncode(&num_bits, 1).c_str(), | 65 base::HexEncode(&num_bits, 1).c_str(), |
| 66 base::HexEncode(&(one_time_pad[0]), one_time_pad.size()).c_str()); | 66 base::HexEncode(&(one_time_pad[0]), one_time_pad.size()).c_str()); |
| 67 | 67 |
| 68 MakeRequest(GetEncryptionUrl(), post_body); | 68 MakeRequest(GetEncryptionUrl(), post_body); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void EncryptionEscrowClient::EscrowInstrumentInformation( | 71 void EncryptionEscrowClient::EscrowInstrumentInformation( |
| 72 const Instrument& new_instrument, | 72 const Instrument& new_instrument, |
| 73 const std::string& obfuscated_gaia_id) { | 73 const std::string& obfuscated_gaia_id) { |
| 74 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 74 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 75 request_type_ = ESCROW_INSTRUMENT_INFORMATION; | 75 request_type_ = ESCROW_INSTRUMENT_INFORMATION; |
| 76 | 76 |
| 77 const std::string& primary_account_number = | 77 const std::string& primary_account_number = |
| 78 net::EscapeUrlEncodedData( | 78 net::EscapeUrlEncodedData( |
| 79 UTF16ToUTF8(new_instrument.primary_account_number()), true); | 79 UTF16ToUTF8(new_instrument.primary_account_number()), true); |
| 80 const std::string& card_verification_number = | 80 const std::string& card_verification_number = |
| 81 net::EscapeUrlEncodedData( | 81 net::EscapeUrlEncodedData( |
| 82 UTF16ToUTF8(new_instrument.card_verification_number()), true); | 82 UTF16ToUTF8(new_instrument.card_verification_number()), true); |
| 83 | 83 |
| 84 std::string post_body = StringPrintf( | 84 std::string post_body = base::StringPrintf( |
| 85 kEscrowInstrumentInformationFormat, | 85 kEscrowInstrumentInformationFormat, |
| 86 obfuscated_gaia_id.c_str(), | 86 obfuscated_gaia_id.c_str(), |
| 87 primary_account_number.c_str(), | 87 primary_account_number.c_str(), |
| 88 card_verification_number.c_str()); | 88 card_verification_number.c_str()); |
| 89 | 89 |
| 90 MakeRequest(GetEscrowUrl(), post_body); | 90 MakeRequest(GetEscrowUrl(), post_body); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void EncryptionEscrowClient::EscrowCardVerificationNumber( | 93 void EncryptionEscrowClient::EscrowCardVerificationNumber( |
| 94 const std::string& card_verification_number, | 94 const std::string& card_verification_number, |
| 95 const std::string& obfuscated_gaia_id) { | 95 const std::string& obfuscated_gaia_id) { |
| 96 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); | 96 DCHECK_EQ(NO_PENDING_REQUEST, request_type_); |
| 97 request_type_ = ESCROW_CARD_VERIFICATION_NUMBER; | 97 request_type_ = ESCROW_CARD_VERIFICATION_NUMBER; |
| 98 | 98 |
| 99 std::string post_body = StringPrintf( | 99 std::string post_body = base::StringPrintf( |
| 100 kEscrowCardVerficationNumberFormat, | 100 kEscrowCardVerficationNumberFormat, |
| 101 obfuscated_gaia_id.c_str(), | 101 obfuscated_gaia_id.c_str(), |
| 102 card_verification_number.c_str()); | 102 card_verification_number.c_str()); |
| 103 | 103 |
| 104 MakeRequest(GetEscrowUrl(), post_body); | 104 MakeRequest(GetEscrowUrl(), post_body); |
| 105 } | 105 } |
| 106 | 106 |
| 107 void EncryptionEscrowClient::MakeRequest(const GURL& url, | 107 void EncryptionEscrowClient::MakeRequest(const GURL& url, |
| 108 const std::string& post_body) { | 108 const std::string& post_body) { |
| 109 DCHECK(!request_.get()); | 109 DCHECK(!request_.get()); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 } | 171 } |
| 172 | 172 |
| 173 void EncryptionEscrowClient::HandleMalformedResponse(net::URLFetcher* request) { | 173 void EncryptionEscrowClient::HandleMalformedResponse(net::URLFetcher* request) { |
| 174 // Called to inform exponential backoff logic of the error. | 174 // Called to inform exponential backoff logic of the error. |
| 175 request->ReceivedContentWasMalformed(); | 175 request->ReceivedContentWasMalformed(); |
| 176 observer_->OnMalformedResponse(); | 176 observer_->OnMalformedResponse(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 } // namespace wallet | 179 } // namespace wallet |
| 180 } // namespace autofill | 180 } // namespace autofill |
| OLD | NEW |