1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
|
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_SAVE_IBAN_DELEGATE_H_
#define CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_SAVE_IBAN_DELEGATE_H_
#include <string>
#include <string_view>
#include "components/autofill/core/browser/payments/payments_autofill_client.h"
#include "content/public/browser/web_contents.h"
class DeviceLockBridge;
namespace autofill {
// Delegate class providing callbacks for UIs presenting save IBAN offers.
class AutofillSaveIbanDelegate {
public:
explicit AutofillSaveIbanDelegate(
payments::PaymentsAutofillClient::SaveIbanPromptCallback
save_iban_callback,
content::WebContents* web_contents);
~AutofillSaveIbanDelegate();
void OnUiShown();
// Callback `on_save_iban_completed` will be triggered after the save IBAN
// flow has finished.
void OnUiAccepted(base::OnceClosure on_save_iban_completed,
std::u16string_view user_provided_nickname = u"");
void OnUiCanceled();
void OnUiIgnored();
void SetDeviceLockBridgeForTesting(
std::unique_ptr<DeviceLockBridge> device_lock_bridge);
private:
// Attempt to save IBAN if user successfully sets a device lock, and runs
// appropriate callbacks such as cleaning up pointers to this delegate that
// have their lifecycle extended.
void OnAfterDeviceLockUi(std::u16string_view user_provided_nickname,
bool user_decision);
// The callback to run once the user makes a decision with respect to the
// IBAN offer-to-save prompt.
payments::PaymentsAutofillClient::SaveIbanPromptCallback save_iban_callback_;
// Callback to run immediately after `save_iban_callback_`. An example of a
// callback is cleaning up pointers to delegates that have their lifecycle
// extended due to user going through device lock setup flows before saving a
// IBAN.
base::OnceClosure on_finished_gathering_consent_callback_;
raw_ptr<content::WebContents> web_contents_;
// This JNI bridge helper class launches the device lock setup flow in
// Android.
std::unique_ptr<DeviceLockBridge> device_lock_bridge_;
base::WeakPtrFactory<AutofillSaveIbanDelegate> weak_ptr_factory_{this};
};
} // namespace autofill
#endif // CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_SAVE_IBAN_DELEGATE_H_
|