Commit 69304271 authored by Alfonso Garza's avatar Alfonso Garza Committed by Commit Bot

[AF] Add missing cardholder name fix flow on iOS.

https://screenshot.googleplex.com/7iRASUwruB7.png
https://screenshot.googleplex.com/vHdkSZJ5DG5.png
https://screenshot.googleplex.com/rVqAk1hM6ES.png

BUG=993849

Change-Id: I3efc298f5bd8481af5392e0e76a6dc3c5fb23c00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1757210Reviewed-by: default avatarOlivier Robin <olivierrobin@chromium.org>
Reviewed-by: default avatarJohn Wu <jzw@chromium.org>
Reviewed-by: default avatarJared Saul <jsaul@google.com>
Reviewed-by: default avatarFabio Tirelo <ftirelo@chromium.org>
Commit-Queue: Alfonso Garza <alfonsogarza@google.com>
Cr-Commit-Position: refs/heads/master@{#702987}
parent 6563c7fb
......@@ -31,6 +31,10 @@
#include "components/zoom/zoom_observer.h"
#endif
#if defined(OS_ANDROID)
#include "components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.h"
#endif // defined(OS_ANDROID)
namespace content {
class WebContents;
}
......
......@@ -336,11 +336,14 @@ class AutofillClient : public RiskDataLoader {
AutofillClient::SaveCreditCardOptions options,
LocalSaveCardPromptCallback callback) = 0;
#if defined(OS_ANDROID)
#if defined(OS_ANDROID) || defined(OS_IOS)
// Display the cardholder name fix flow prompt and run the |callback| if
// the card should be uploaded to payments with updated name from the user.
virtual void ConfirmAccountNameFixFlow(
base::OnceCallback<void(const base::string16&)> callback) = 0;
#endif // defined(OS_ANDROID) || defined(OS_IOS)
#if defined(OS_ANDROID)
// Display the expiration date fix flow prompt with the |card| details
// and run the |callback| if the card should be uploaded to payments with
// updated expiration date from the user.
......
......@@ -776,25 +776,27 @@ void CreditCardSaveManager::OnUserDidDecideOnUploadSave(
const AutofillClient::UserProvidedCardDetails& user_provided_card_details) {
switch (user_decision) {
case AutofillClient::ACCEPTED:
// On Android, requesting cardholder name or expiration date is a two step
// flow.
#if defined(OS_ANDROID)
#if defined(OS_ANDROID) || defined(OS_IOS)
// On Android and iOS, requesting cardholder name is a two step flow.
if (should_request_name_from_user_) {
client_->ConfirmAccountNameFixFlow(base::BindOnce(
&CreditCardSaveManager::OnUserDidAcceptAccountNameFixFlow,
weak_ptr_factory_.GetWeakPtr()));
#if defined(OS_ANDROID)
// On Android, requesting expiration date is a two step flow.
} else if (should_request_expiration_date_from_user_) {
client_->ConfirmExpirationDateFixFlow(
upload_request_.card,
base::BindOnce(
&CreditCardSaveManager::OnUserDidAcceptExpirationDateFixFlow,
weak_ptr_factory_.GetWeakPtr()));
#endif // defined(OS_ANDROID)
} else {
OnUserDidAcceptUploadHelper(user_provided_card_details);
}
#else
OnUserDidAcceptUploadHelper(user_provided_card_details);
#endif
#endif // defined(OS_ANDROID) || defined(OS_IOS)
break;
case AutofillClient::DECLINED:
......@@ -806,7 +808,7 @@ void CreditCardSaveManager::OnUserDidDecideOnUploadSave(
personal_data_manager_->OnUserAcceptedUpstreamOffer();
}
#if defined(OS_ANDROID)
#if defined(OS_ANDROID) || defined(OS_IOS)
void CreditCardSaveManager::OnUserDidAcceptAccountNameFixFlow(
const base::string16& cardholder_name) {
DCHECK(should_request_name_from_user_);
......@@ -815,7 +817,9 @@ void CreditCardSaveManager::OnUserDidAcceptAccountNameFixFlow(
/*expiration_date_month=*/base::string16(),
/*expiration_date_year=*/base::string16()});
}
#endif
#if defined(OS_ANDROID)
void CreditCardSaveManager::OnUserDidAcceptExpirationDateFixFlow(
const base::string16& month,
const base::string16& year) {
......
......@@ -218,12 +218,14 @@ class CreditCardSaveManager {
const AutofillClient::UserProvidedCardDetails&
user_provided_card_details);
#if defined(OS_ANDROID)
#if defined(OS_ANDROID) || defined(OS_IOS)
// Upload the card details with the user provided cardholder_name.
// Only relevant for mobile as fix flow is two steps on mobile compared to
// one step on desktop.
void OnUserDidAcceptAccountNameFixFlow(const base::string16& cardholder_name);
#endif // defined(OS_ANDROID) || defined(OS_IOS)
#if defined(OS_ANDROID)
// Upload the card details with the user provided expiration date month and
// year. Only relevant for mobile as fix flow is two steps on mobile compared
// to one step on desktop.
......
......@@ -132,13 +132,15 @@ void TestAutofillClient::ConfirmSaveCreditCardLocally(
std::move(callback).Run(AutofillClient::ACCEPTED);
}
#if defined(OS_ANDROID)
#if defined(OS_ANDROID) || defined(OS_IOS)
void TestAutofillClient::ConfirmAccountNameFixFlow(
base::OnceCallback<void(const base::string16&)> callback) {
credit_card_name_fix_flow_bubble_was_shown_ = true;
std::move(callback).Run(base::string16(base::ASCIIToUTF16("Gaia Name")));
}
#endif // defined(OS_ANDROID) || defined(OS_IOS)
#if defined(OS_ANDROID)
void TestAutofillClient::ConfirmExpirationDateFixFlow(
const CreditCard& card,
base::OnceCallback<void(const base::string16&, const base::string16&)>
......
......@@ -73,9 +73,12 @@ class TestAutofillClient : public AutofillClient {
const CreditCard& card,
SaveCreditCardOptions options,
LocalSaveCardPromptCallback callback) override;
#if defined(OS_ANDROID)
#if defined(OS_ANDROID) || defined(OS_IOS)
void ConfirmAccountNameFixFlow(
base::OnceCallback<void(const base::string16&)> callback) override;
#endif // defined(OS_ANDROID) || defined(OS_IOS)
#if defined(OS_ANDROID)
void ConfirmExpirationDateFixFlow(
const CreditCard& card,
base::OnceCallback<void(const base::string16&, const base::string16&)>
......
......@@ -22,7 +22,11 @@ class CardNameFixFlowController {
// State.
virtual int GetIconId() const = 0;
virtual base::string16 GetCancelButtonLabel() const = 0;
virtual base::string16 GetInferredCardholderName() const = 0;
virtual base::string16 GetInferredNameTooltipText() const = 0;
virtual base::string16 GetInputLabel() const = 0;
virtual base::string16 GetInputPlaceholderText() const = 0;
virtual base::string16 GetSaveButtonLabel() const = 0;
virtual base::string16 GetTitleText() const = 0;
};
......
......@@ -11,6 +11,7 @@
#include "base/strings/utf_string_conversions.h"
#include "base/values.h"
#include "build/branding_buildflags.h"
#include "build/build_config.h"
#include "components/autofill/core/browser/autofill_metrics.h"
#include "components/autofill/core/browser/ui/payments/card_name_fix_flow_view.h"
#include "components/grit/components_scaled_resources.h"
......@@ -84,14 +85,38 @@ int CardNameFixFlowControllerImpl::GetIconId() const {
#endif
}
base::string16 CardNameFixFlowControllerImpl::GetCancelButtonLabel() const {
return l10n_util::GetStringUTF16(IDS_CANCEL);
}
base::string16 CardNameFixFlowControllerImpl::GetInferredCardholderName()
const {
return inferred_cardholder_name_;
}
base::string16 CardNameFixFlowControllerImpl::GetInferredNameTooltipText()
const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME_TOOLTIP);
}
base::string16 CardNameFixFlowControllerImpl::GetInputLabel() const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME);
}
base::string16 CardNameFixFlowControllerImpl::GetInputPlaceholderText() const {
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME);
}
base::string16 CardNameFixFlowControllerImpl::GetSaveButtonLabel() const {
#if defined(OS_IOS)
return l10n_util::GetStringUTF16(IDS_SAVE);
#else
return l10n_util::GetStringUTF16(
IDS_AUTOFILL_FIX_FLOW_PROMPT_SAVE_CARD_LABEL);
#endif
}
base::string16 CardNameFixFlowControllerImpl::GetTitleText() const {
......
......@@ -30,7 +30,11 @@ class CardNameFixFlowControllerImpl : public CardNameFixFlowController {
void OnNameAccepted(const base::string16& name) override;
void OnDismissed() override;
int GetIconId() const override;
base::string16 GetCancelButtonLabel() const override;
base::string16 GetInferredCardholderName() const override;
base::string16 GetInferredNameTooltipText() const override;
base::string16 GetInputLabel() const override;
base::string16 GetInputPlaceholderText() const override;
base::string16 GetSaveButtonLabel() const override;
base::string16 GetTitleText() const override;
......
......@@ -107,9 +107,18 @@
Confirm
</message>
</if>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CONTINUE" desc="Text to show for the Autofill upload save credit card prompt accept button when more information (e.g., CVC) was needed in order to save the card and was entered.">
Continue
</message>
<if expr="is_ios">
<then>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CONTINUE" desc="Text to show for the Autofill upload save credit card prompt accept button when more information (e.g., CVC) was needed in order to save the card and was entered.">
Save...
</message>
</then>
<else>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CONTINUE" desc="Text to show for the Autofill upload save credit card prompt accept button when more information (e.g., CVC) was needed in order to save the card and was entered.">
Continue
</message>
</else>
</if>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_TITLE_LOCAL" desc="Title text for the Autofill save card prompt when the card is to be saved locally. The prompt can be either a bubble or an infobar.">
Save card?
</message>
......@@ -164,9 +173,19 @@
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_UPLOAD_EXPLANATION_V3_WITH_NAME_AND_DEVICE" desc="Explanation of the effect of the Autofill save card prompt when the card is to be saved by uploading it to Google Payments and also saved locally, according to April 2018 UI guidelines. The prompt can be either a bubble or an infobar.">
To pay faster next time, save your card, name, and billing address to your Google Account and to this device.
</message>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME" desc="The label text for the cardholder name textfield.">
Cardholder name
</message>
<if expr="is_ios">
<then>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME" desc="The label text for the cardholder name textfield.">
Name on Card
</message>
</then>
<else>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME" desc="The label text for the cardholder name textfield.">
Cardholder name
</message>
</else>
</if>
<message name="IDS_AUTOFILL_SAVE_CARD_PROMPT_CARDHOLDER_NAME_TOOLTIP" desc="The tooltip text for the cardholder name textfield. Note that the translation should not have period" formatter_data="android_java">
This name is from your Google Account
</message>
......
......@@ -69,6 +69,8 @@ source_set("autofill") {
source_set("bridges") {
configs += [ "//build/config/compiler:enable_arc" ]
sources = [
"card_name_fix_flow_view_bridge.h",
"card_name_fix_flow_view_bridge.mm",
"card_unmask_prompt_view_bridge.h",
"card_unmask_prompt_view_bridge.mm",
]
......@@ -80,6 +82,8 @@ source_set("bridges") {
"//ios/chrome/browser/ui/autofill/cells",
"//ios/chrome/browser/ui/collection_view/cells",
"//ios/chrome/browser/ui/colors",
"//ios/chrome/browser/ui/list_model",
"//ios/chrome/browser/ui/table_view/cells",
"//ios/chrome/browser/ui/util",
"//ios/chrome/common/colors",
"//ios/third_party/material_components_ios",
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_CHROME_BROWSER_UI_AUTOFILL_CARD_NAME_FIX_FLOW_VIEW_BRIDGE_H_
#define IOS_CHROME_BROWSER_UI_AUTOFILL_CARD_NAME_FIX_FLOW_VIEW_BRIDGE_H_
#import <UIKit/UIKit.h>
#include <memory>
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "components/autofill/core/browser/ui/payments/card_name_fix_flow_controller.h"
#include "components/autofill/core/browser/ui/payments/card_name_fix_flow_view.h"
namespace autofill {
class CardNameFixFlowController;
class CardNameFixFlowViewBridge : public CardNameFixFlowView {
public:
CardNameFixFlowViewBridge(CardNameFixFlowController* controller,
UIViewController* base_view_controller);
~CardNameFixFlowViewBridge() override;
// CardUnmaskPromptView:
void Show() override;
void ControllerGone() override;
CardNameFixFlowController* GetController();
// Called when the user confirms their name.
void OnConfirmedName(const base::string16& confirmed_name);
// Closes the view.
void PerformClose();
// Deletes self. This should only be called by CardNameFixFlowViewController
// after it finishes dismissing its own UI elements.
void DeleteSelf();
protected:
UIViewController* view_controller_;
private:
// The controller |this| queries for logic and state.
CardNameFixFlowController* controller_; // weak
// Weak reference to the view controller used to present UI.
__weak UIViewController* presenting_view_controller_;
base::WeakPtrFactory<CardNameFixFlowViewBridge> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(CardNameFixFlowViewBridge);
};
} // namespace autofill
@interface CardNameFixFlowViewController : UITableViewController
// Designated initializer. |bridge| must not be null.
- (instancetype)initWithBridge:(autofill::CardNameFixFlowViewBridge*)bridge
NS_DESIGNATED_INITIALIZER;
- (instancetype)initWithCoder:(NSCoder*)aDecoder NS_UNAVAILABLE;
- (instancetype)initWithStyle:(UITableViewStyle)style NS_UNAVAILABLE;
- (instancetype)initWithNibName:(NSString*)nibNameOrNil
bundle:(NSBundle*)nibBundleOrNil NS_UNAVAILABLE;
@end
#endif // IOS_CHROME_BROWSER_UI_AUTOFILL_CARD_NAME_FIX_FLOW_VIEW_BRIDGE_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include <memory>
#include <string>
#include "base/mac/foundation_util.h"
#include "base/strings/sys_string_conversions.h"
#include "base/values.h"
#include "components/strings/grit/components_strings.h"
#include "ios/chrome/browser/ui/autofill/card_name_fix_flow_view_bridge.h"
#import "ios/chrome/browser/ui/list_model/list_model.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_edit_item.h"
#import "ios/chrome/browser/ui/table_view/cells/table_view_text_header_footer_item.h"
#import "ios/chrome/browser/ui/util/label_link_controller.h"
#import "ios/chrome/browser/ui/util/rtl_geometry.h"
#import "ios/chrome/browser/ui/util/uikit_ui_util.h"
#import "ios/chrome/common/colors/semantic_color_names.h"
#include "ui/base/l10n/l10n_util.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
NSString* const kCellReuseID = @"ConfirmNameTableViewTextEditCell";
CGFloat const kMainSection = 0;
CGFloat const kNumberOfRowsInMainSection = 1;
namespace autofill {
#pragma mark CardNameFixFlowViewBridge
CardNameFixFlowViewBridge::CardNameFixFlowViewBridge(
CardNameFixFlowController* controller,
UIViewController* presenting_view_controller)
: controller_(controller),
presenting_view_controller_(presenting_view_controller) {
DCHECK(controller_);
DCHECK(presenting_view_controller_);
}
CardNameFixFlowViewBridge::~CardNameFixFlowViewBridge() {
if (controller_)
controller_->OnDismissed();
}
void CardNameFixFlowViewBridge::Show() {
// Wrap CardNameFixFlowViewController with navigation controller to include
// a navigation bar.
view_controller_ = [[UINavigationController alloc]
initWithRootViewController:[[CardNameFixFlowViewController alloc]
initWithBridge:this]];
[presenting_view_controller_ presentViewController:view_controller_
animated:YES
completion:nil];
}
void CardNameFixFlowViewBridge::ControllerGone() {
controller_ = nullptr;
PerformClose();
}
CardNameFixFlowController* CardNameFixFlowViewBridge::GetController() {
return controller_;
}
void CardNameFixFlowViewBridge::OnConfirmedName(
const base::string16& confirmed_name) {
controller_->OnNameAccepted(confirmed_name);
PerformClose();
}
void CardNameFixFlowViewBridge::PerformClose() {
base::WeakPtr<CardNameFixFlowViewBridge> weakSelf =
weak_ptr_factory_.GetWeakPtr();
[view_controller_ dismissViewControllerAnimated:YES
completion:^{
weakSelf->DeleteSelf();
}];
}
void CardNameFixFlowViewBridge::DeleteSelf() {
delete this;
}
} // namespace autofill
@interface CardNameFixFlowViewController () <UITextFieldDelegate,
UITableViewDelegate> {
UIBarButtonItem* _confirmButton;
NSString* _confirmedName;
TableViewTextHeaderFooterView* _footerView;
// Owns |self|.
autofill::CardNameFixFlowViewBridge* _bridge; // weak
}
@end
@implementation CardNameFixFlowViewController
- (instancetype)initWithBridge:(autofill::CardNameFixFlowViewBridge*)bridge {
DCHECK(bridge);
if (self = [super initWithStyle:UITableViewStyleGrouped]) {
_bridge = bridge;
self.title =
base::SysUTF16ToNSString(_bridge->GetController()->GetTitleText());
}
return self;
}
#pragma mark - UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.delegate = self;
autofill::CardNameFixFlowController* controller = _bridge->GetController();
NSString* cancelButtonLabel =
base::SysUTF16ToNSString(controller->GetCancelButtonLabel());
self.navigationItem.leftBarButtonItem =
[[UIBarButtonItem alloc] initWithTitle:cancelButtonLabel
style:UIBarButtonItemStylePlain
target:self
action:@selector(onCancel:)];
NSString* saveButtonLabel =
base::SysUTF16ToNSString(controller->GetSaveButtonLabel());
_confirmButton =
[[UIBarButtonItem alloc] initWithTitle:saveButtonLabel
style:UIBarButtonItemStylePlain
target:self
action:@selector(onConfirm:)];
self.navigationItem.rightBarButtonItem = _confirmButton;
_confirmedName =
base::SysUTF16ToNSString(controller->GetInferredCardholderName());
[self updateSaveButtonEnabledStatus];
NSString* inferredNameTooltipText =
(_confirmedName.length > 0)
? base::SysUTF16ToNSString(controller->GetInferredNameTooltipText())
: nil;
_footerView = [[TableViewTextHeaderFooterView alloc] init];
_footerView.subtitleLabel.textColor =
[UIColor colorNamed:kTextSecondaryColor];
_footerView.subtitleLabel.text = inferredNameTooltipText;
[self.tableView registerClass:[TableViewTextEditCell class]
forCellReuseIdentifier:kCellReuseID];
}
#pragma mark - UITableViewDataSource
- (NSInteger)tableView:(UITableView*)tableView
numberOfRowsInSection:(NSInteger)section {
DCHECK(section == kMainSection);
return kNumberOfRowsInMainSection;
}
- (UITableViewCell*)tableView:(UITableView*)tableView
cellForRowAtIndexPath:(NSIndexPath*)indexPath {
DCHECK(indexPath.section == kMainSection);
UITableViewCell* cellAtIndex =
[self.tableView dequeueReusableCellWithIdentifier:kCellReuseID
forIndexPath:indexPath];
DCHECK([cellAtIndex isKindOfClass:[TableViewTextEditCell class]]);
autofill::CardNameFixFlowController* controller = _bridge->GetController();
TableViewTextEditCell* confirmNameCell = (TableViewTextEditCell*)cellAtIndex;
confirmNameCell.selectionStyle = UITableViewCellSelectionStyleNone;
confirmNameCell.useCustomSeparator = NO;
confirmNameCell.textLabel.text =
base::SysUTF16ToNSString(controller->GetInputLabel());
UITextField* textField = confirmNameCell.textField;
textField.placeholder =
base::SysUTF16ToNSString(controller->GetInputPlaceholderText());
textField.text = _confirmedName;
textField.textColor = [UIColor colorNamed:kBlueColor];
textField.delegate = self;
return confirmNameCell;
}
#pragma mark - UITableViewDelegate
- (UIView*)tableView:(UITableView*)tableView
viewForFooterInSection:(NSInteger)section {
DCHECK(section == kMainSection);
return _footerView;
}
#pragma mark - UITextFieldDelegate
- (BOOL)textField:(UITextField*)textField
shouldChangeCharactersInRange:(NSRange)range
replacementString:(NSString*)string {
[self didChangeConfirmedName:[textField.text
stringByReplacingCharactersInRange:range
withString:string]];
return YES;
}
- (BOOL)textFieldShouldClear:(UITextField*)textField {
[self didChangeConfirmedName:@""];
return YES;
}
#pragma mark - Private
- (void)onCancel:(id)sender {
_bridge->PerformClose();
}
- (void)onConfirm:(id)sender {
DCHECK(_confirmedName.length > 0);
_bridge->OnConfirmedName(base::SysNSStringToUTF16(_confirmedName));
}
- (void)updateSaveButtonEnabledStatus {
_confirmButton.enabled = _confirmedName.length > 0;
}
- (void)didChangeConfirmedName:(NSString*)confirmedName {
confirmedName = [confirmedName
stringByTrimmingCharactersInSet:NSCharacterSet
.whitespaceAndNewlineCharacterSet];
// After an edit, refresh footer text to no longer include name tooltip.
_footerView.subtitleLabel.text = nil;
_confirmedName = confirmedName;
[self updateSaveButtonEnabledStatus];
}
@end
......@@ -17,6 +17,7 @@
#include "components/autofill/core/browser/payments/legal_message_line.h"
#include "components/autofill/core/browser/payments/strike_database.h"
#include "components/autofill/core/browser/personal_data_manager.h"
#include "components/autofill/core/browser/ui/payments/card_name_fix_flow_controller_impl.h"
#include "components/autofill/core/browser/ui/payments/card_unmask_prompt_controller_impl.h"
#include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
#import "components/autofill/ios/browser/autofill_client_ios_bridge.h"
......@@ -87,6 +88,8 @@ class ChromeAutofillClientIOS : public AutofillClient {
const CreditCard& card,
SaveCreditCardOptions options,
LocalSaveCardPromptCallback callback) override;
void ConfirmAccountNameFixFlow(
base::OnceCallback<void(const base::string16&)> callback) override;
void ConfirmSaveCreditCardToCloud(
const CreditCard& card,
const LegalMessageLines& legal_message_lines,
......@@ -141,6 +144,7 @@ class ChromeAutofillClientIOS : public AutofillClient {
password_manager::PasswordManager* password_manager_;
CardUnmaskPromptControllerImpl unmask_controller_;
std::unique_ptr<LogManager> log_manager_;
CardNameFixFlowControllerImpl card_name_fix_flow_controller_;
// A weak reference to the view controller used to present UI.
__weak UIViewController* base_view_controller_;
......
......@@ -10,6 +10,7 @@
#include "base/feature_list.h"
#include "base/logging.h"
#include "base/memory/ptr_util.h"
#include "base/strings/utf_string_conversions.h"
#include "components/autofill/core/browser/form_data_importer.h"
#include "components/autofill/core/browser/logging/log_manager.h"
#include "components/autofill/core/browser/payments/autofill_credit_card_filling_infobar_delegate_mobile.h"
......@@ -36,6 +37,7 @@
#include "ios/chrome/browser/ssl/ios_security_state_tab_helper.h"
#include "ios/chrome/browser/sync/profile_sync_service_factory.h"
#include "ios/chrome/browser/translate/chrome_ios_translate_client.h"
#include "ios/chrome/browser/ui/autofill/card_name_fix_flow_view_bridge.h"
#include "ios/chrome/browser/ui/autofill/card_unmask_prompt_view_bridge.h"
#include "ios/chrome/browser/ui/autofill/save_card_infobar_controller.h"
#include "ios/chrome/browser/webdata_services/web_data_service_factory.h"
......@@ -257,6 +259,23 @@ void ChromeAutofillClientIOS::ConfirmSaveCreditCardLocally(
payments_client_->is_off_the_record())));
}
void ChromeAutofillClientIOS::ConfirmAccountNameFixFlow(
base::OnceCallback<void(const base::string16&)> callback) {
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();
card_name_fix_flow_controller_.Show(
// autofill::CardNameFixFlowViewBridge manages its own lifetime, so
// do not use std::unique_ptr<> here.
new autofill::CardNameFixFlowViewBridge(&card_name_fix_flow_controller_,
base_view_controller_),
account_name, std::move(callback));
}
void ChromeAutofillClientIOS::ConfirmSaveCreditCardToCloud(
const CreditCard& card,
const LegalMessageLines& legal_message_lines,
......
......@@ -80,6 +80,8 @@ class WebViewAutofillClientIOS : public AutofillClient {
const CreditCard& card,
SaveCreditCardOptions options,
LocalSaveCardPromptCallback callback) override;
void ConfirmAccountNameFixFlow(
base::OnceCallback<void(const base::string16&)> callback) override;
void ConfirmSaveCreditCardToCloud(
const CreditCard& card,
const LegalMessageLines& legal_message_lines,
......
......@@ -184,6 +184,11 @@ void WebViewAutofillClientIOS::ConfirmSaveCreditCardLocally(
callback:std::move(callback)];
}
void WebViewAutofillClientIOS::ConfirmAccountNameFixFlow(
base::OnceCallback<void(const base::string16&)> callback) {
NOTIMPLEMENTED();
}
void WebViewAutofillClientIOS::ConfirmSaveCreditCardToCloud(
const CreditCard& card,
const LegalMessageLines& legal_message_lines,
......
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