File: android_autofill_provider_bridge_impl.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (97 lines) | stat: -rw-r--r-- 4,027 bytes parent folder | download | duplicates (5)
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// 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 COMPONENTS_ANDROID_AUTOFILL_BROWSER_ANDROID_AUTOFILL_PROVIDER_BRIDGE_IMPL_H_
#define COMPONENTS_ANDROID_AUTOFILL_BROWSER_ANDROID_AUTOFILL_PROVIDER_BRIDGE_IMPL_H_

#include <jni.h>

#include <optional>
#include <string>

#include "base/android/jni_weak_ref.h"
#include "base/containers/span.h"
#include "base/memory/raw_ref.h"
#include "components/android_autofill/browser/android_autofill_provider_bridge.h"
#include "components/autofill/core/common/mojom/autofill_types.mojom.h"

namespace autofill {

class AndroidAutofillProviderBridgeImpl : public AndroidAutofillProviderBridge {
 public:
  explicit AndroidAutofillProviderBridgeImpl(Delegate* delegate);
  ~AndroidAutofillProviderBridgeImpl() override;

  // AndroidAutofillProviderBridge:
  void AttachToJavaAutofillProvider(
      JNIEnv* env,
      const base::android::JavaRef<jobject>& jcaller) override;
  void SendPrefillRequest(FormDataAndroid& form) override;
  void StartAutofillSession(FormDataAndroid& form,
                            const FieldInfo& field,
                            bool has_server_predictions) override;
  void OnServerPredictionsAvailable() override;
  void ShowDatalistPopup(base::span<const SelectOption> options,
                         bool is_rtl) override;
  void HideDatalistPopup() override;
  void OnFocusChanged(const std::optional<FieldInfo>& field) override;
  void OnFormFieldDidChange(const FieldInfo& field) override;
  void OnFormFieldVisibilitiesDidChange(base::span<const int> indices) override;
  void OnTextFieldDidScroll(const FieldInfo& field) override;
  void OnFormSubmitted(mojom::SubmissionSource submission_source) override;
  void OnDidFillAutofillFormData() override;
  void CancelSession() override;
  void Reset() override;

  // Called by Java:

  // Resets the weak reference to its Java counterpart. Invoked when the
  // WebContents associated with the Java `AutofillProvider` is changed or the
  // Java `AutofillProvider` is destroyed. It indicates that the Java Peer is
  // about to be destroyed.
  void DetachFromJavaAutofillProvider(JNIEnv* env);

  // Asks the `Delegate` whether passkeys options are available.
  jboolean HasPasskeyRequest(JNIEnv* env);

  // Informs the `Delegate` that the linked form should be sent to the renderer
  // for filling. Invoked when the user has accepted Autofill.
  void OnAutofillAvailable(JNIEnv* env);

  // Informs the `Delegate` that the datalist `value` should be accepted in the
  // renderer. Invoked when the user has accepted a datalist entry.
  void OnAcceptDataListSuggestion(JNIEnv* env, std::u16string value);

  // Informs the `Delegate` that the `WebContents`' native view should set the
  // anchor rect for `anchor_view` to the specified bounds. Invoked when opening
  // a datalist popup.
  void SetAnchorViewRect(JNIEnv* env,
                         jobject anchor_view,
                         jfloat x,
                         jfloat y,
                         jfloat width,
                         jfloat height);

  // Informs the `Delegate` of the outcome of an attempt to show a bottom sheet.
  // `is_shown` indicates whether the bottom sheet was shown and
  // `provided_autofill_structure` describes whether an Autofill ViewStructure
  // was provided to the Autofill framework prior to showing the bottom sheet.
  void OnShowBottomSheetResult(JNIEnv* env,
                               jboolean is_shown,
                               jboolean provided_autofill_structure);

  // Informs the `Delegate` that the user explicitly requested passkeys options.
  void OnTriggerPasskeyRequest(JNIEnv* env);

 private:
  // The delegate of the bridge.
  raw_ref<Delegate> delegate_;

  // The Java counterpart of `this`.
  JavaObjectWeakGlobalRef java_ref_;
};

}  // namespace autofill

#endif  // COMPONENTS_ANDROID_AUTOFILL_BROWSER_ANDROID_AUTOFILL_PROVIDER_BRIDGE_IMPL_H_