| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/android/autofill/autofill_dialog_controller_android.
h" | 5 #include "chrome/browser/ui/android/autofill/autofill_dialog_controller_android.
h" |
| 6 | 6 |
| 7 #include "base/android/jni_android.h" | 7 #include "base/android/jni_android.h" |
| 8 #include "base/android/jni_array.h" | 8 #include "base/android/jni_array.h" |
| 9 #include "base/android/jni_string.h" | 9 #include "base/android/jni_string.h" |
| 10 #include "base/android/scoped_java_ref.h" | 10 #include "base/android/scoped_java_ref.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 199 bool has_sections = false; | 199 bool has_sections = false; |
| 200 form_structure_.ParseFieldTypesFromAutocompleteAttributes( | 200 form_structure_.ParseFieldTypesFromAutocompleteAttributes( |
| 201 &has_types, &has_sections); | 201 &has_types, &has_sections); |
| 202 | 202 |
| 203 // Fail if the author didn't specify autocomplete types, or | 203 // Fail if the author didn't specify autocomplete types, or |
| 204 // if the dialog shouldn't be shown in a given circumstances. | 204 // if the dialog shouldn't be shown in a given circumstances. |
| 205 if (!has_types || | 205 if (!has_types || |
| 206 !Java_AutofillDialogControllerAndroid_isDialogAllowed( | 206 !Java_AutofillDialogControllerAndroid_isDialogAllowed( |
| 207 env, | 207 env, |
| 208 invoked_from_same_origin_)) { | 208 invoked_from_same_origin_)) { |
| 209 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorUnsupported, | 209 callback_.Run( |
| 210 NULL); | 210 AutofillManagerDelegate::AutocompleteResultErrorUnsupported, |
| 211 base::ASCIIToUTF16("Form is missing autocomplete attributes."), |
| 212 NULL); |
| 211 delete this; | 213 delete this; |
| 212 return; | 214 return; |
| 213 } | 215 } |
| 214 | 216 |
| 215 // Log any relevant UI metrics and security exceptions. | 217 // Log any relevant UI metrics and security exceptions. |
| 216 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_SHOWN); | 218 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_SHOWN); |
| 217 | 219 |
| 218 GetMetricLogger().LogDialogSecurityMetric( | 220 GetMetricLogger().LogDialogSecurityMetric( |
| 219 AutofillMetrics::SECURITY_METRIC_DIALOG_SHOWN); | 221 AutofillMetrics::SECURITY_METRIC_DIALOG_SHOWN); |
| 220 | 222 |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // static | 321 // static |
| 320 bool AutofillDialogControllerAndroid:: | 322 bool AutofillDialogControllerAndroid:: |
| 321 RegisterAutofillDialogControllerAndroid(JNIEnv* env) { | 323 RegisterAutofillDialogControllerAndroid(JNIEnv* env) { |
| 322 return RegisterNativesImpl(env); | 324 return RegisterNativesImpl(env); |
| 323 } | 325 } |
| 324 | 326 |
| 325 void AutofillDialogControllerAndroid::DialogCancel(JNIEnv* env, | 327 void AutofillDialogControllerAndroid::DialogCancel(JNIEnv* env, |
| 326 jobject obj) { | 328 jobject obj) { |
| 327 LogOnCancelMetrics(); | 329 LogOnCancelMetrics(); |
| 328 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel, | 330 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel, |
| 331 base::string16(), |
| 329 NULL); | 332 NULL); |
| 330 } | 333 } |
| 331 | 334 |
| 332 void AutofillDialogControllerAndroid::DialogContinue( | 335 void AutofillDialogControllerAndroid::DialogContinue( |
| 333 JNIEnv* env, | 336 JNIEnv* env, |
| 334 jobject obj, | 337 jobject obj, |
| 335 jobject wallet, | 338 jobject wallet, |
| 336 jboolean jlast_used_choice_is_autofill, | 339 jboolean jlast_used_choice_is_autofill, |
| 337 jstring jlast_used_account_name, | 340 jstring jlast_used_account_name, |
| 338 jstring jlast_used_billing, | 341 jstring jlast_used_billing, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 defaults->SetString(kLastUsedCreditCardGuid, last_used_card); | 379 defaults->SetString(kLastUsedCreditCardGuid, last_used_card); |
| 377 } else { | 380 } else { |
| 378 LOG(ERROR) << "Failed to save AutofillDialog preferences"; | 381 LOG(ERROR) << "Failed to save AutofillDialog preferences"; |
| 379 } | 382 } |
| 380 } | 383 } |
| 381 | 384 |
| 382 LogOnFinishSubmitMetrics(); | 385 LogOnFinishSubmitMetrics(); |
| 383 | 386 |
| 384 // Callback should be called as late as possible. | 387 // Callback should be called as late as possible. |
| 385 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, | 388 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess, |
| 389 base::string16(), |
| 386 &form_structure_); | 390 &form_structure_); |
| 387 | 391 |
| 388 // This might delete us. | 392 // This might delete us. |
| 389 Hide(); | 393 Hide(); |
| 390 } | 394 } |
| 391 | 395 |
| 392 AutofillDialogControllerAndroid::AutofillDialogControllerAndroid( | 396 AutofillDialogControllerAndroid::AutofillDialogControllerAndroid( |
| 393 content::WebContents* contents, | 397 content::WebContents* contents, |
| 394 const FormData& form_structure, | 398 const FormData& form_structure, |
| 395 const GURL& source_url, | 399 const GURL& source_url, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 417 | 421 |
| 418 void AutofillDialogControllerAndroid::LogOnCancelMetrics() { | 422 void AutofillDialogControllerAndroid::LogOnCancelMetrics() { |
| 419 GetMetricLogger().LogDialogUiDuration( | 423 GetMetricLogger().LogDialogUiDuration( |
| 420 base::Time::Now() - dialog_shown_timestamp_, | 424 base::Time::Now() - dialog_shown_timestamp_, |
| 421 AutofillMetrics::DIALOG_CANCELED); | 425 AutofillMetrics::DIALOG_CANCELED); |
| 422 | 426 |
| 423 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_CANCELED); | 427 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_CANCELED); |
| 424 } | 428 } |
| 425 | 429 |
| 426 } // namespace autofill | 430 } // namespace autofill |
| OLD | NEW |