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/content/browser/wallet/wallet_client.h" | 5 #include "components/autofill/content/browser/wallet/wallet_client.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 const size_t kOneTimePadLength = 6; | 45 const size_t kOneTimePadLength = 6; |
46 | 46 |
47 // The maximum number of bits in the one time pad that the server is willing to | 47 // The maximum number of bits in the one time pad that the server is willing to |
48 // accept. | 48 // accept. |
49 const size_t kMaxBits = 56; | 49 const size_t kMaxBits = 56; |
50 | 50 |
51 // The minimum number of bits in the one time pad that the server is willing to | 51 // The minimum number of bits in the one time pad that the server is willing to |
52 // accept. | 52 // accept. |
53 const size_t kMinBits = 40; | 53 const size_t kMinBits = 40; |
54 | 54 |
55 std::string DialogTypeToFeatureString(autofill::DialogType dialog_type) { | |
56 switch (dialog_type) { | |
57 case DIALOG_TYPE_REQUEST_AUTOCOMPLETE: | |
58 return "REQUEST_AUTOCOMPLETE"; | |
59 case DIALOG_TYPE_AUTOCHECKOUT: | |
60 return "AUTOCHECKOUT"; | |
61 } | |
62 NOTREACHED(); | |
63 return "NOT_POSSIBLE"; | |
64 } | |
65 | |
66 std::string RiskCapabilityToString( | 55 std::string RiskCapabilityToString( |
67 WalletClient::RiskCapability risk_capability) { | 56 WalletClient::RiskCapability risk_capability) { |
68 switch (risk_capability) { | 57 switch (risk_capability) { |
69 case WalletClient::RELOGIN: | 58 case WalletClient::RELOGIN: |
70 return "RELOGIN"; | 59 return "RELOGIN"; |
71 case WalletClient::VERIFY_CVC: | 60 case WalletClient::VERIFY_CVC: |
72 return "VERIFY_CVC"; | 61 return "VERIFY_CVC"; |
73 } | 62 } |
74 NOTREACHED(); | 63 NOTREACHED(); |
75 return "NOT_POSSIBLE"; | 64 return "NOT_POSSIBLE"; |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 request_dict.SetBoolean(kNewWalletUser, full_wallet_request.new_wallet_user); | 339 request_dict.SetBoolean(kNewWalletUser, full_wallet_request.new_wallet_user); |
351 | 340 |
352 request_dict.SetString(kSelectedInstrumentIdKey, | 341 request_dict.SetString(kSelectedInstrumentIdKey, |
353 full_wallet_request.instrument_id); | 342 full_wallet_request.instrument_id); |
354 request_dict.SetString(kSelectedAddressIdKey, full_wallet_request.address_id); | 343 request_dict.SetString(kSelectedAddressIdKey, full_wallet_request.address_id); |
355 request_dict.SetString( | 344 request_dict.SetString( |
356 kMerchantDomainKey, | 345 kMerchantDomainKey, |
357 full_wallet_request.source_url.GetWithEmptyPath().spec()); | 346 full_wallet_request.source_url.GetWithEmptyPath().spec()); |
358 request_dict.SetString(kGoogleTransactionIdKey, | 347 request_dict.SetString(kGoogleTransactionIdKey, |
359 full_wallet_request.google_transaction_id); | 348 full_wallet_request.google_transaction_id); |
360 request_dict.SetString(kFeatureKey, | 349 request_dict.SetString(kFeatureKey, "REQUEST_AUTOCOMPLETE"); |
361 DialogTypeToFeatureString(delegate_->GetDialogType())); | |
362 | 350 |
363 scoped_ptr<base::ListValue> risk_capabilities_list(new base::ListValue()); | 351 scoped_ptr<base::ListValue> risk_capabilities_list(new base::ListValue()); |
364 for (std::vector<RiskCapability>::const_iterator it = | 352 for (std::vector<RiskCapability>::const_iterator it = |
365 full_wallet_request.risk_capabilities.begin(); | 353 full_wallet_request.risk_capabilities.begin(); |
366 it != full_wallet_request.risk_capabilities.end(); | 354 it != full_wallet_request.risk_capabilities.end(); |
367 ++it) { | 355 ++it) { |
368 risk_capabilities_list->AppendString(RiskCapabilityToString(*it)); | 356 risk_capabilities_list->AppendString(RiskCapabilityToString(*it)); |
369 } | 357 } |
370 request_dict.Set(kRiskCapabilitiesKey, risk_capabilities_list.release()); | 358 request_dict.Set(kRiskCapabilitiesKey, risk_capabilities_list.release()); |
371 | 359 |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 VLOG(1) << "Making request to " << url << " with post_body=" << post_body; | 554 VLOG(1) << "Making request to " << url << " with post_body=" << post_body; |
567 request_->SetUploadData(mime_type, post_body); | 555 request_->SetUploadData(mime_type, post_body); |
568 request_->AddExtraRequestHeader("Authorization: GoogleLogin auth=" + | 556 request_->AddExtraRequestHeader("Authorization: GoogleLogin auth=" + |
569 delegate_->GetWalletCookieValue()); | 557 delegate_->GetWalletCookieValue()); |
570 DVLOG(1) << "Setting authorization header value to " | 558 DVLOG(1) << "Setting authorization header value to " |
571 << delegate_->GetWalletCookieValue(); | 559 << delegate_->GetWalletCookieValue(); |
572 request_started_timestamp_ = base::Time::Now(); | 560 request_started_timestamp_ = base::Time::Now(); |
573 request_->Start(); | 561 request_->Start(); |
574 | 562 |
575 delegate_->GetMetricLogger().LogWalletErrorMetric( | 563 delegate_->GetMetricLogger().LogWalletErrorMetric( |
576 delegate_->GetDialogType(), | |
577 AutofillMetrics::WALLET_ERROR_BASELINE_ISSUED_REQUEST); | 564 AutofillMetrics::WALLET_ERROR_BASELINE_ISSUED_REQUEST); |
578 delegate_->GetMetricLogger().LogWalletRequiredActionMetric( | 565 delegate_->GetMetricLogger().LogWalletRequiredActionMetric( |
579 delegate_->GetDialogType(), | |
580 AutofillMetrics::WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST); | 566 AutofillMetrics::WALLET_REQUIRED_ACTION_BASELINE_ISSUED_REQUEST); |
581 } | 567 } |
582 | 568 |
583 // TODO(ahutter): Add manual retry logic if it's necessary. | 569 // TODO(ahutter): Add manual retry logic if it's necessary. |
584 void WalletClient::OnURLFetchComplete( | 570 void WalletClient::OnURLFetchComplete( |
585 const net::URLFetcher* source) { | 571 const net::URLFetcher* source) { |
586 delegate_->GetMetricLogger().LogWalletApiCallDuration( | 572 delegate_->GetMetricLogger().LogWalletApiCallDuration( |
587 RequestTypeToUmaMetric(request_type_), | 573 RequestTypeToUmaMetric(request_type_), |
588 base::Time::Now() - request_started_timestamp_); | 574 base::Time::Now() - request_started_timestamp_); |
589 | 575 |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
795 break; | 781 break; |
796 case WalletClient::UNKNOWN_ERROR: | 782 case WalletClient::UNKNOWN_ERROR: |
797 error_message = "WALLET_UNKNOWN_ERROR"; | 783 error_message = "WALLET_UNKNOWN_ERROR"; |
798 break; | 784 break; |
799 } | 785 } |
800 | 786 |
801 VLOG(1) << "Wallet encountered a " << error_message; | 787 VLOG(1) << "Wallet encountered a " << error_message; |
802 | 788 |
803 delegate_->OnWalletError(error_type); | 789 delegate_->OnWalletError(error_type); |
804 delegate_->GetMetricLogger().LogWalletErrorMetric( | 790 delegate_->GetMetricLogger().LogWalletErrorMetric( |
805 delegate_->GetDialogType(), ErrorTypeToUmaMetric(error_type)); | 791 ErrorTypeToUmaMetric(error_type)); |
806 } | 792 } |
807 | 793 |
808 // Logs an UMA metric for each of the |required_actions|. | 794 // Logs an UMA metric for each of the |required_actions|. |
809 void WalletClient::LogRequiredActions( | 795 void WalletClient::LogRequiredActions( |
810 const std::vector<RequiredAction>& required_actions) const { | 796 const std::vector<RequiredAction>& required_actions) const { |
811 for (size_t i = 0; i < required_actions.size(); ++i) { | 797 for (size_t i = 0; i < required_actions.size(); ++i) { |
812 delegate_->GetMetricLogger().LogWalletRequiredActionMetric( | 798 delegate_->GetMetricLogger().LogWalletRequiredActionMetric( |
813 delegate_->GetDialogType(), | |
814 RequiredActionToUmaMetric(required_actions[i])); | 799 RequiredActionToUmaMetric(required_actions[i])); |
815 } | 800 } |
816 } | 801 } |
817 | 802 |
818 AutofillMetrics::WalletApiCallMetric WalletClient::RequestTypeToUmaMetric( | 803 AutofillMetrics::WalletApiCallMetric WalletClient::RequestTypeToUmaMetric( |
819 RequestType request_type) const { | 804 RequestType request_type) const { |
820 switch (request_type) { | 805 switch (request_type) { |
821 case ACCEPT_LEGAL_DOCUMENTS: | 806 case ACCEPT_LEGAL_DOCUMENTS: |
822 return AutofillMetrics::ACCEPT_LEGAL_DOCUMENTS; | 807 return AutofillMetrics::ACCEPT_LEGAL_DOCUMENTS; |
823 case AUTHENTICATE_INSTRUMENT: | 808 case AUTHENTICATE_INSTRUMENT: |
824 return AutofillMetrics::AUTHENTICATE_INSTRUMENT; | 809 return AutofillMetrics::AUTHENTICATE_INSTRUMENT; |
825 case GET_FULL_WALLET: | 810 case GET_FULL_WALLET: |
826 return AutofillMetrics::GET_FULL_WALLET; | 811 return AutofillMetrics::GET_FULL_WALLET; |
827 case GET_WALLET_ITEMS: | 812 case GET_WALLET_ITEMS: |
828 return AutofillMetrics::GET_WALLET_ITEMS; | 813 return AutofillMetrics::GET_WALLET_ITEMS; |
829 case SAVE_TO_WALLET: | 814 case SAVE_TO_WALLET: |
830 return AutofillMetrics::SAVE_TO_WALLET; | 815 return AutofillMetrics::SAVE_TO_WALLET; |
831 case NO_PENDING_REQUEST: | 816 case NO_PENDING_REQUEST: |
832 NOTREACHED(); | 817 NOTREACHED(); |
833 return AutofillMetrics::UNKNOWN_API_CALL; | 818 return AutofillMetrics::UNKNOWN_API_CALL; |
834 } | 819 } |
835 | 820 |
836 NOTREACHED(); | 821 NOTREACHED(); |
837 return AutofillMetrics::UNKNOWN_API_CALL; | 822 return AutofillMetrics::UNKNOWN_API_CALL; |
838 } | 823 } |
839 | 824 |
840 } // namespace wallet | 825 } // namespace wallet |
841 } // namespace autofill | 826 } // namespace autofill |
OLD | NEW |