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