OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 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/time/time.h" |
| 13 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
| 14 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
| 15 |
| 16 class Profile; |
| 17 |
| 18 namespace user_prefs { |
| 19 class PrefRegistrySyncable; |
| 20 } |
| 21 |
| 22 namespace autofill { |
| 23 |
| 24 // This class defines the form-filling host and JNI glue for the Java-side |
| 25 // implementation of the requestAutocomplete dialog. |
| 26 class AutofillDialogControllerAndroid : public AutofillDialogController { |
| 27 public: |
| 28 // Creates an instance of the AutofillDialogControllerAndroid. |
| 29 static base::WeakPtr<AutofillDialogController> Create( |
| 30 content::WebContents* contents, |
| 31 const FormData& form_structure, |
| 32 const GURL& source_url, |
| 33 const DialogType dialog_type, |
| 34 const base::Callback<void(const FormStructure*, |
| 35 const std::string&)>& callback); |
| 36 |
| 37 // Registers profile preferences for the AutofillDialogControllerAndroid. |
| 38 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 39 |
| 40 virtual ~AutofillDialogControllerAndroid(); |
| 41 |
| 42 // AutofillDialogController implementation: |
| 43 virtual void Show() OVERRIDE; |
| 44 virtual void Hide() OVERRIDE; |
| 45 virtual void TabActivated() OVERRIDE; |
| 46 virtual void AddAutocheckoutStep(AutocheckoutStepType step_type) OVERRIDE; |
| 47 virtual void UpdateAutocheckoutStep( |
| 48 AutocheckoutStepType step_type, |
| 49 AutocheckoutStepStatus step_status) OVERRIDE; |
| 50 virtual void OnAutocheckoutError() OVERRIDE; |
| 51 virtual void OnAutocheckoutSuccess() OVERRIDE; |
| 52 virtual DialogType GetDialogType() const OVERRIDE; |
| 53 |
| 54 // JNI bindings for Java-side AutofillDialogDelegate: |
| 55 void DialogCancel(JNIEnv* env, jobject obj); |
| 56 void DialogContinue(JNIEnv* env, |
| 57 jobject obj, |
| 58 jobject full_wallet, |
| 59 jboolean last_used_choice_is_autofill, |
| 60 jstring last_used_account_name, |
| 61 jstring last_used_billing, |
| 62 jstring last_used_shipping, |
| 63 jstring last_used_credit_card); |
| 64 |
| 65 // Establishes JNI bindings. |
| 66 static bool RegisterAutofillDialogControllerAndroid(JNIEnv* env); |
| 67 |
| 68 private: |
| 69 AutofillDialogControllerAndroid( |
| 70 content::WebContents* contents, |
| 71 const FormData& form_structure, |
| 72 const GURL& source_url, |
| 73 const DialogType dialog_type, |
| 74 const base::Callback<void(const FormStructure*, |
| 75 const std::string&)>& callback); |
| 76 |
| 77 const AutofillMetrics& GetMetricLogger() const { |
| 78 return metric_logger_; |
| 79 } |
| 80 |
| 81 // Logs metrics when the dialog is submitted. |
| 82 void LogOnFinishSubmitMetrics(); |
| 83 |
| 84 // Logs metrics when the dialog is canceled. |
| 85 void LogOnCancelMetrics(); |
| 86 |
| 87 bool RequestingCreditCardInfo() const; |
| 88 bool TransmissionWillBeSecure() const; |
| 89 |
| 90 void SetAutocheckoutState(AutocheckoutState autocheckout_state); |
| 91 |
| 92 // The |profile| for |contents_|. |
| 93 Profile* const profile_; |
| 94 |
| 95 // The WebContents where the Autocomplete/Checkout action originated. |
| 96 content::WebContents* const contents_; |
| 97 |
| 98 // For logging UMA metrics. |
| 99 const AutofillMetrics metric_logger_; |
| 100 base::Time dialog_shown_timestamp_; |
| 101 AutofillMetrics::DialogInitialUserStateMetric initial_user_state_; |
| 102 |
| 103 // The time that Autocheckout started running. Reset on error. While this is |
| 104 // a valid time, |AutocheckoutIsRunning()| will return true. |
| 105 base::Time autocheckout_started_timestamp_; |
| 106 |
| 107 // Whether this is an Autocheckout or a requestAutocomplete dialog. |
| 108 const DialogType dialog_type_; |
| 109 |
| 110 FormStructure form_structure_; |
| 111 |
| 112 // Whether the URL visible to the user when this dialog was requested to be |
| 113 // invoked is the same as |source_url_|. |
| 114 bool invoked_from_same_origin_; |
| 115 |
| 116 // The URL of the invoking site. |
| 117 GURL source_url_; |
| 118 |
| 119 // The callback via which we return the collected data and, if Online Wallet |
| 120 // was used, the Google transaction id. |
| 121 base::Callback<void(const FormStructure*, const std::string&)> callback_; |
| 122 |
| 123 // Whether |form_structure_| has asked for any details that would indicate |
| 124 // we should show a shipping section. |
| 125 bool cares_about_shipping_; |
| 126 |
| 127 base::WeakPtrFactory<AutofillDialogControllerAndroid> |
| 128 weak_ptr_factory_; |
| 129 |
| 130 // The current state of the Autocheckout flow. |
| 131 AutocheckoutState autocheckout_state_; |
| 132 |
| 133 // Whether the latency to display to the UI was logged to UMA yet. |
| 134 bool was_ui_latency_logged_; |
| 135 |
| 136 // The corresponding java object. |
| 137 base::android::ScopedJavaGlobalRef<jobject> java_object_; |
| 138 |
| 139 DISALLOW_COPY_AND_ASSIGN(AutofillDialogControllerAndroid); |
| 140 }; |
| 141 |
| 142 } // namespace autofill |
| 143 |
| 144 #endif // CHROME_BROWSER_UI_ANDROID_AUTOFILL_AUTOFILL_DIALOG_CONTROLLER_ANDROID
_H_ |
OLD | NEW |