Commit e71659c2 authored by John Z Wu's avatar John Z Wu Committed by Commit Bot

Define APIs for credit card fix flows

Bug: 1066690
Change-Id: I3fdf503aceb45dd93d51187ab30f38c887c2ccdf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2134958
Commit-Queue: John Wu <jzw@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#756151}
parent 2e8ac7a3
......@@ -47,6 +47,20 @@ class FormStructure;
callback:(autofill::AutofillClient::
UploadSaveCardPromptCallback)callback;
// Bridge For AutofillClient's method |ConfirmAccountNameFixFlow|.
- (void)
confirmCreditCardAccountName:(const base::string16&)name
callback:
(base::OnceCallback<void(const base::string16&)>)
callback;
// Bridge For AutofillClient's method |ConfirmExpirationDateFixFlow|.
- (void)confirmCreditCardExpirationWithCard:(const autofill::CreditCard&)card
callback:
(base::OnceCallback<void(
const base::string16&,
const base::string16&)>)callback;
// Bridge for AutofillClient's method |CreditCardUploadCompleted|.
- (void)handleCreditCardUploadCompleted:(BOOL)cardSaved;
......
......@@ -37,7 +37,9 @@
#import "ios/web_view/internal/autofill/cwv_autofill_form_internal.h"
#import "ios/web_view/internal/autofill/cwv_autofill_profile_internal.h"
#import "ios/web_view/internal/autofill/cwv_autofill_suggestion_internal.h"
#import "ios/web_view/internal/autofill/cwv_credit_card_expiration_fixer_internal.h"
#import "ios/web_view/internal/autofill/cwv_credit_card_internal.h"
#import "ios/web_view/internal/autofill/cwv_credit_card_name_fixer_internal.h"
#import "ios/web_view/internal/autofill/cwv_credit_card_saver_internal.h"
#import "ios/web_view/internal/autofill/cwv_credit_card_verifier_internal.h"
#include "ios/web_view/internal/autofill/web_view_autocomplete_history_manager_factory.h"
......@@ -424,6 +426,39 @@ fetchNonPasswordSuggestionsForFormWithName:(NSString*)formName
_saver = saver;
}
- (void)
confirmCreditCardAccountName:(const base::string16&)name
callback:
(base::OnceCallback<void(const base::string16&)>)
callback {
if (![_delegate respondsToSelector:@selector(autofillController:
confirmCreditCardNameWithFixer:)]) {
return;
}
CWVCreditCardNameFixer* fixer = [[CWVCreditCardNameFixer alloc]
initWithName:base::SysUTF16ToNSString(name)
callback:std::move(callback)];
[_delegate autofillController:self confirmCreditCardNameWithFixer:fixer];
}
- (void)confirmCreditCardExpirationWithCard:(const autofill::CreditCard&)card
callback:
(base::OnceCallback<void(
const base::string16&,
const base::string16&)>)callback {
if (![_delegate respondsToSelector:@selector
(autofillController:confirmCreditCardExpirationWithFixer:)]) {
return;
}
CWVCreditCardExpirationFixer* fixer = [[CWVCreditCardExpirationFixer alloc]
initWithCreditCard:card
callback:std::move(callback)];
[_delegate autofillController:self
confirmCreditCardExpirationWithFixer:fixer];
}
- (void)
confirmSaveCreditCardToCloud:(const autofill::CreditCard&)creditCard
legalMessageLines:(autofill::LegalMessageLines)legalMessageLines
......
......@@ -181,14 +181,22 @@ void WebViewAutofillClientIOS::ConfirmSaveCreditCardLocally(
void WebViewAutofillClientIOS::ConfirmAccountNameFixFlow(
base::OnceCallback<void(const base::string16&)> callback) {
NOTIMPLEMENTED();
base::Optional<AccountInfo> primary_account_info =
identity_manager_->FindExtendedAccountInfoForAccountWithRefreshToken(
identity_manager_->GetPrimaryAccountInfo());
base::string16 account_name =
primary_account_info ? base::UTF8ToUTF16(primary_account_info->full_name)
: base::string16();
[bridge_ confirmCreditCardAccountName:account_name
callback:std::move(callback)];
}
void WebViewAutofillClientIOS::ConfirmExpirationDateFixFlow(
const CreditCard& card,
base::OnceCallback<void(const base::string16&, const base::string16&)>
callback) {
NOTIMPLEMENTED();
[bridge_ confirmCreditCardExpirationWithCard:card
callback:std::move(callback)];
}
void WebViewAutofillClientIOS::ConfirmSaveCreditCardToCloud(
......
......@@ -14,6 +14,8 @@ NS_ASSUME_NONNULL_BEGIN
@class CWVAutofillFormSuggestion;
@class CWVAutofillProfile;
@class CWVCreditCard;
@class CWVCreditCardExpirationFixer;
@class CWVCreditCardNameFixer;
@class CWVCreditCardSaver;
@class CWVCreditCardVerifier;
@class CWVPassword;
......@@ -101,6 +103,22 @@ typedef NS_ENUM(NSInteger, CWVPasswordUserDecision) {
- (void)autofillController:(CWVAutofillController*)autofillController
saveCreditCardWithSaver:(CWVCreditCardSaver*)saver;
// Called if the card holder's name needs to be confirmed by the user before the
// card can be saved. This can happen if a user doesn't have a GPay account or
// attempted to save a credit card without providing a name for it.
// |fixer| encapsulates information needed to assist with this fix attempt.
// Life time of |fixer| should be managed by the delegate.
- (void)autofillController:(CWVAutofillController*)autofillController
confirmCreditCardNameWithFixer:(CWVCreditCardNameFixer*)fixer;
// Called if the card's expiration needs to be corrected before the the card can
// be saved. This can happen if a user attempted to save a credit card with an
// expired expiration date.
// |fixer| encapsulates information needed to assist with this fix attempt.
// Life time of |fixer| should be managed by the delegate.
- (void)autofillController:(CWVAutofillController*)autofillController
confirmCreditCardExpirationWithFixer:(CWVCreditCardExpirationFixer*)fixer;
// Called when the user needs to use |verifier| to verify a credit card.
// Lifetime of |verifier| should be managed by the delegate.
- (void)autofillController:(CWVAutofillController*)autofillController
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment