Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: components/autofill/core/browser/autofill_manager.cc

Issue 1515903003: If upload is enabled don't fallback to local save. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/core/browser/autofill_manager.h" 5 #include "components/autofill/core/browser/autofill_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after
878 // credentials until the user has explicitly accepted a prompt to upload. 878 // credentials until the user has explicitly accepted a prompt to upload.
879 upload_request_.context_token = context_token; 879 upload_request_.context_token = context_token;
880 user_did_accept_upload_prompt_ = false; 880 user_did_accept_upload_prompt_ = false;
881 client_->ConfirmSaveCreditCardToCloud( 881 client_->ConfirmSaveCreditCardToCloud(
882 base::Bind(&AutofillManager::OnUserDidAcceptUpload, 882 base::Bind(&AutofillManager::OnUserDidAcceptUpload,
883 weak_ptr_factory_.GetWeakPtr()), 883 weak_ptr_factory_.GetWeakPtr()),
884 legal_message.Pass()); 884 legal_message.Pass());
885 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData, 885 client_->LoadRiskData(base::Bind(&AutofillManager::OnDidGetUploadRiskData,
886 weak_ptr_factory_.GetWeakPtr())); 886 weak_ptr_factory_.GetWeakPtr()));
887 } else { 887 } else {
888 // Since the upload details request failed, fallback to a local save. 888 // If the upload details request failed, fall back to a local save. The
889 // reasoning here is as follows:
890 // - This will sometimes fail intermittently, in which case it might be
891 // better to not fall back, because sometimes offering upload and sometimes
892 // offering local save is a poor user experience.
893 // - However, in some cases, our local configuration limiting the feature to
894 // countries that Payments is known to support will not match Payments' own
895 // determination of what country the user is located in. In these cases,
896 // the upload details request will consistently fail and if we don't fall
897 // back to a local save then the user will never be offered any kind of
898 // credit card save.
889 client_->ConfirmSaveCreditCardLocally(base::Bind( 899 client_->ConfirmSaveCreditCardLocally(base::Bind(
890 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), 900 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard),
891 base::Unretained(personal_data_), upload_request_.card)); 901 base::Unretained(personal_data_), upload_request_.card));
892 } 902 }
893 } 903 }
894 904
895 void AutofillManager::OnDidUploadCard( 905 void AutofillManager::OnDidUploadCard(
896 AutofillClient::PaymentsRpcResult result) { 906 AutofillClient::PaymentsRpcResult result) {
897 // We don't do anything user-visible if the upload attempt fails. 907 // We don't do anything user-visible if the upload attempt fails.
898 // TODO(jdonnelly): Log duration. 908 // TODO(jdonnelly): Log duration.
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
994 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) { 1004 if (field->Type().GetStorableType() == CREDIT_CARD_VERIFICATION_CODE) {
995 upload_request_.cvc = field->value; 1005 upload_request_.cvc = field->value;
996 break; 1006 break;
997 } 1007 }
998 } 1008 }
999 1009
1000 // Upload also requires recently used or modified profiles with matching 1010 // Upload also requires recently used or modified profiles with matching
1001 // names. 1011 // names.
1002 upload_request_.profiles = 1012 upload_request_.profiles =
1003 GetProfilesForCreditCardUpload(*imported_credit_card); 1013 GetProfilesForCreditCardUpload(*imported_credit_card);
1004 }
1005 1014
1006 if (!upload_request_.cvc.empty() && !upload_request_.profiles.empty()) { 1015 // If the necessary conditions don't exist, do nothing. We could fall back
1007 upload_request_.card = *imported_credit_card; 1016 // to a local save here but we believe that sometimes offering upload and
1008 payments_client_->GetUploadDetails(app_locale_); 1017 // sometimes offering local save is a confusing user experience.
1018 if (!upload_request_.cvc.empty() && !upload_request_.profiles.empty()) {
1019 upload_request_.card = *imported_credit_card;
1020 payments_client_->GetUploadDetails(app_locale_);
1021 }
1009 } else { 1022 } else {
1010 // If upload isn't enabled or not possible, prompt the user for local
1011 // save.
1012 client_->ConfirmSaveCreditCardLocally(base::Bind( 1023 client_->ConfirmSaveCreditCardLocally(base::Bind(
1013 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard), 1024 base::IgnoreResult(&PersonalDataManager::SaveImportedCreditCard),
1014 base::Unretained(personal_data_), *imported_credit_card)); 1025 base::Unretained(personal_data_), *imported_credit_card));
1015 } 1026 }
1016 } 1027 }
1017 } 1028 }
1018 1029
1019 std::vector<AutofillProfile> AutofillManager::GetProfilesForCreditCardUpload( 1030 std::vector<AutofillProfile> AutofillManager::GetProfilesForCreditCardUpload(
1020 const CreditCard& card) { 1031 const CreditCard& card) {
1021 std::vector<AutofillProfile> profiles; 1032 std::vector<AutofillProfile> profiles;
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
1683 if (i > 0) 1694 if (i > 0)
1684 fputs("Next oldest form:\n", file); 1695 fputs("Next oldest form:\n", file);
1685 } 1696 }
1686 fputs("\n", file); 1697 fputs("\n", file);
1687 1698
1688 fclose(file); 1699 fclose(file);
1689 } 1700 }
1690 #endif // ENABLE_FORM_DEBUG_DUMP 1701 #endif // ENABLE_FORM_DEBUG_DUMP
1691 1702
1692 } // namespace autofill 1703 } // namespace autofill
OLDNEW
« no previous file with comments | « no previous file | components/autofill/core/browser/autofill_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698