OLD | NEW |
| (Empty) |
1 // Copyright 2013 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 CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_ANDROID_H_ | |
6 #define CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_ANDROID_H_ | |
7 | |
8 #include <jni.h> | |
9 | |
10 #include "base/android/jni_string.h" | |
11 #include "base/android/scoped_java_ref.h" | |
12 #include "base/macros.h" | |
13 #include "base/time/time.h" | |
14 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | |
15 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | |
16 #include "components/autofill/core/browser/autofill_client.h" | |
17 #include "components/autofill/core/browser/autofill_metrics.h" | |
18 | |
19 class Profile; | |
20 | |
21 namespace autofill { | |
22 | |
23 // This class defines the form-filling host and JNI glue for the Java-side | |
24 // implementation of the requestAutocomplete dialog. | |
25 class AutofillDialogControllerAndroid : public AutofillDialogController { | |
26 public: | |
27 // Creates an instance of the AutofillDialogControllerAndroid. | |
28 static base::WeakPtr<AutofillDialogController> Create( | |
29 content::WebContents* contents, | |
30 const FormData& form_structure, | |
31 const GURL& source_url, | |
32 const AutofillClient::ResultCallback& callback); | |
33 | |
34 ~AutofillDialogControllerAndroid() override; | |
35 | |
36 // AutofillDialogController implementation: | |
37 void Show() override; | |
38 void Hide() override; | |
39 void TabActivated() override; | |
40 | |
41 // JNI bindings for Java-side AutofillDialogDelegate: | |
42 void DialogCancel(JNIEnv* env, | |
43 const base::android::JavaParamRef<jobject>& obj); | |
44 void DialogContinue( | |
45 JNIEnv* env, | |
46 const base::android::JavaParamRef<jobject>& obj, | |
47 const base::android::JavaParamRef<jobject>& full_wallet, | |
48 jboolean last_used_choice_is_autofill, | |
49 const base::android::JavaParamRef<jstring>& last_used_account_name, | |
50 const base::android::JavaParamRef<jstring>& last_used_billing, | |
51 const base::android::JavaParamRef<jstring>& last_used_shipping, | |
52 const base::android::JavaParamRef<jstring>& last_used_credit_card); | |
53 | |
54 // Establishes JNI bindings. | |
55 static bool RegisterAutofillDialogControllerAndroid(JNIEnv* env); | |
56 | |
57 private: | |
58 AutofillDialogControllerAndroid( | |
59 content::WebContents* contents, | |
60 const FormData& form_structure, | |
61 const GURL& source_url, | |
62 const AutofillClient::ResultCallback& callback); | |
63 | |
64 // Logs metrics when the dialog is submitted. | |
65 void LogOnFinishSubmitMetrics(); | |
66 | |
67 // Logs metrics when the dialog is canceled. | |
68 void LogOnCancelMetrics(); | |
69 | |
70 // The |profile| for |contents_|. | |
71 Profile* const profile_; | |
72 | |
73 // The WebContents where the Autocomplete/Checkout action originated. | |
74 content::WebContents* const contents_; | |
75 | |
76 // For logging UMA metrics. | |
77 base::Time dialog_shown_timestamp_; | |
78 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; | |
79 | |
80 FormStructure form_structure_; | |
81 | |
82 // Whether the URL visible to the user when this dialog was requested to be | |
83 // invoked is the same as |source_url_|. | |
84 bool invoked_from_same_origin_; | |
85 | |
86 // The URL of the invoking site. | |
87 GURL source_url_; | |
88 | |
89 // The callback via which we return the collected data. | |
90 AutofillClient::ResultCallback callback_; | |
91 | |
92 // Whether |form_structure_| has asked for any details that would indicate | |
93 // we should show a shipping section. | |
94 bool cares_about_shipping_; | |
95 | |
96 // Whether the latency to display to the UI was logged to UMA yet. | |
97 bool was_ui_latency_logged_; | |
98 | |
99 // The corresponding java object. | |
100 base::android::ScopedJavaGlobalRef<jobject> java_object_; | |
101 | |
102 base::WeakPtrFactory<AutofillDialogControllerAndroid> | |
103 weak_ptr_factory_; | |
104 | |
105 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerAndroid); | |
106 }; | |
107 | |
108 } // namespace autofill | |
109 | |
110 #endif // CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_ANDROID
_H_ | |
OLD | NEW |