OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_ANDROID_AUTOFILL_PROVIDER_ANDROID_H_ |
| 6 #define COMPONENTS_AUTOFILL_ANDROID_AUTOFILL_PROVIDER_ANDROID_H_ |
| 7 |
| 8 #include "base/android/jni_weak_ref.h" |
| 9 #include "base/memory/weak_ptr.h" |
| 10 #include "components/autofill/core/browser/autofill_provider.h" |
| 11 |
| 12 namespace content { |
| 13 class WebContents; |
| 14 } |
| 15 |
| 16 namespace autofill { |
| 17 |
| 18 class FormDataAndroid; |
| 19 |
| 20 // Android implementation of AutofillProvider, it has one instance per |
| 21 // WebContents, this class is native peer of AutofillProvider.java. |
| 22 class AutofillProviderAndroid : public AutofillProvider { |
| 23 public: |
| 24 AutofillProviderAndroid(const base::android::JavaRef<jobject>& jcaller, |
| 25 content::WebContents* web_contents); |
| 26 ~AutofillProviderAndroid() override; |
| 27 |
| 28 // AutofillProvider: |
| 29 void OnQueryFormFieldAutofill(AutofillHandlerProxy* handler, |
| 30 int32_t id, |
| 31 const FormData& form, |
| 32 const FormFieldData& field, |
| 33 const gfx::RectF& bounding_box) override; |
| 34 void OnTextFieldDidChange(AutofillHandlerProxy* handler, |
| 35 const FormData& form, |
| 36 const FormFieldData& field, |
| 37 const base::TimeTicks timestamp) override; |
| 38 bool OnWillSubmitForm(AutofillHandlerProxy* handler, |
| 39 const FormData& form, |
| 40 const base::TimeTicks timestamp) override; |
| 41 void OnFocusNoLongerOnForm(AutofillHandlerProxy* handler) override; |
| 42 void OnDidFillAutofillFormData(AutofillHandlerProxy* handler, |
| 43 const FormData& form, |
| 44 base::TimeTicks timestamp) override; |
| 45 void Reset(AutofillHandlerProxy* handler) override; |
| 46 |
| 47 // Methods called by Java. |
| 48 void OnAutofillAvailable(JNIEnv* env, jobject jcaller, jobject form_data); |
| 49 |
| 50 private: |
| 51 void OnFocusChanged(bool focus_on_form, |
| 52 size_t index, |
| 53 const gfx::RectF& bounding_box); |
| 54 |
| 55 bool ValidateHandler(AutofillHandlerProxy* handler); |
| 56 |
| 57 int32_t id_; |
| 58 std::unique_ptr<FormDataAndroid> form_; |
| 59 base::WeakPtr<AutofillHandlerProxy> handler_; |
| 60 JavaObjectWeakGlobalRef java_ref_; |
| 61 content::WebContents* web_contents_; |
| 62 |
| 63 DISALLOW_COPY_AND_ASSIGN(AutofillProviderAndroid); |
| 64 }; |
| 65 |
| 66 bool RegisterAutofillProvider(JNIEnv* env); |
| 67 |
| 68 } // namespace autofill |
| 69 |
| 70 #endif // COMPONENTS_AUTOFILL_ANDROID_AUTOFILL_PROVIDER_ANDROID_H_ |
OLD | NEW |