File: autofill_save_iban_delegate.h

package info (click to toggle)
chromium 138.0.7204.157-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,864 kB
  • sloc: cpp: 34,936,859; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,967; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (67 lines) | stat: -rw-r--r-- 2,426 bytes parent folder | download | duplicates (4)
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_