Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(269)

Side by Side Diff: chrome/browser/ui/android/autofill/autofill_dialog_controller_android.cc

Issue 229723002: Better error reasons for rAc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: android Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 } 135 }
136 136
137 } // namespace 137 } // namespace
138 138
139 139
140 // static 140 // static
141 base::WeakPtr<AutofillDialogController> AutofillDialogControllerAndroid::Create( 141 base::WeakPtr<AutofillDialogController> AutofillDialogControllerAndroid::Create(
142 content::WebContents* contents, 142 content::WebContents* contents,
143 const FormData& form_structure, 143 const FormData& form_structure,
144 const GURL& source_url, 144 const GURL& source_url,
145 const base::Callback<void(const FormStructure*)>& callback) { 145 const AutofillManagerDelegate::ResultCallback& callback) {
146 // AutofillDialogControllerAndroid owns itself. 146 // AutofillDialogControllerAndroid owns itself.
147 AutofillDialogControllerAndroid* autofill_dialog_controller = 147 AutofillDialogControllerAndroid* autofill_dialog_controller =
148 new AutofillDialogControllerAndroid(contents, 148 new AutofillDialogControllerAndroid(contents,
149 form_structure, 149 form_structure,
150 source_url, 150 source_url,
151 callback); 151 callback);
152 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr(); 152 return autofill_dialog_controller->weak_ptr_factory_.GetWeakPtr();
153 } 153 }
154 154
155 #if defined(ENABLE_AUTOFILL_DIALOG) 155 #if defined(ENABLE_AUTOFILL_DIALOG)
156 // static 156 // static
157 base::WeakPtr<AutofillDialogController> 157 base::WeakPtr<AutofillDialogController>
158 AutofillDialogController::Create( 158 AutofillDialogController::Create(
159 content::WebContents* contents, 159 content::WebContents* contents,
160 const FormData& form_structure, 160 const FormData& form_structure,
161 const GURL& source_url, 161 const GURL& source_url,
162 const base::Callback<void(const FormStructure*)>& callback) { 162 const AutofillManagerDelegate::ResultCallback& callback) {
163 return AutofillDialogControllerAndroid::Create(contents, 163 return AutofillDialogControllerAndroid::Create(contents,
164 form_structure, 164 form_structure,
165 source_url, 165 source_url,
166 callback); 166 callback);
167 } 167 }
168 168
169 // static 169 // static
170 void AutofillDialogController::RegisterPrefs(PrefRegistrySimple* registry) {} 170 void AutofillDialogController::RegisterPrefs(PrefRegistrySimple* registry) {}
171 171
172 // static 172 // static
(...skipping 26 matching lines...) Expand all
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(NULL); 209 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorUnsupported,
210 NULL);
210 delete this; 211 delete this;
211 return; 212 return;
212 } 213 }
213 214
214 // Log any relevant UI metrics and security exceptions. 215 // Log any relevant UI metrics and security exceptions.
215 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_SHOWN); 216 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_SHOWN);
216 217
217 GetMetricLogger().LogDialogSecurityMetric( 218 GetMetricLogger().LogDialogSecurityMetric(
218 AutofillMetrics::SECURITY_METRIC_DIALOG_SHOWN); 219 AutofillMetrics::SECURITY_METRIC_DIALOG_SHOWN);
219 220
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 318
318 // static 319 // static
319 bool AutofillDialogControllerAndroid:: 320 bool AutofillDialogControllerAndroid::
320 RegisterAutofillDialogControllerAndroid(JNIEnv* env) { 321 RegisterAutofillDialogControllerAndroid(JNIEnv* env) {
321 return RegisterNativesImpl(env); 322 return RegisterNativesImpl(env);
322 } 323 }
323 324
324 void AutofillDialogControllerAndroid::DialogCancel(JNIEnv* env, 325 void AutofillDialogControllerAndroid::DialogCancel(JNIEnv* env,
325 jobject obj) { 326 jobject obj) {
326 LogOnCancelMetrics(); 327 LogOnCancelMetrics();
327 callback_.Run(NULL); 328 callback_.Run(AutofillManagerDelegate::AutocompleteResultErrorCancel,
329 NULL);
328 } 330 }
329 331
330 void AutofillDialogControllerAndroid::DialogContinue( 332 void AutofillDialogControllerAndroid::DialogContinue(
331 JNIEnv* env, 333 JNIEnv* env,
332 jobject obj, 334 jobject obj,
333 jobject wallet, 335 jobject wallet,
334 jboolean jlast_used_choice_is_autofill, 336 jboolean jlast_used_choice_is_autofill,
335 jstring jlast_used_account_name, 337 jstring jlast_used_account_name,
336 jstring jlast_used_billing, 338 jstring jlast_used_billing,
337 jstring jlast_used_shipping, 339 jstring jlast_used_shipping,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 if (!last_used_card.empty()) 375 if (!last_used_card.empty())
374 defaults->SetString(kLastUsedCreditCardGuid, last_used_card); 376 defaults->SetString(kLastUsedCreditCardGuid, last_used_card);
375 } else { 377 } else {
376 LOG(ERROR) << "Failed to save AutofillDialog preferences"; 378 LOG(ERROR) << "Failed to save AutofillDialog preferences";
377 } 379 }
378 } 380 }
379 381
380 LogOnFinishSubmitMetrics(); 382 LogOnFinishSubmitMetrics();
381 383
382 // Callback should be called as late as possible. 384 // Callback should be called as late as possible.
383 callback_.Run(&form_structure_); 385 callback_.Run(AutofillManagerDelegate::AutocompleteResultSuccess,
386 &form_structure_);
384 387
385 // This might delete us. 388 // This might delete us.
386 Hide(); 389 Hide();
387 } 390 }
388 391
389 AutofillDialogControllerAndroid::AutofillDialogControllerAndroid( 392 AutofillDialogControllerAndroid::AutofillDialogControllerAndroid(
390 content::WebContents* contents, 393 content::WebContents* contents,
391 const FormData& form_structure, 394 const FormData& form_structure,
392 const GURL& source_url, 395 const GURL& source_url,
393 const base::Callback<void(const FormStructure*)>& callback) 396 const AutofillManagerDelegate::ResultCallback& callback)
394 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 397 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
395 contents_(contents), 398 contents_(contents),
396 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), 399 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
397 form_structure_(form_structure), 400 form_structure_(form_structure),
398 invoked_from_same_origin_(true), 401 invoked_from_same_origin_(true),
399 source_url_(source_url), 402 source_url_(source_url),
400 callback_(callback), 403 callback_(callback),
401 cares_about_shipping_(true), 404 cares_about_shipping_(true),
402 weak_ptr_factory_(this), 405 weak_ptr_factory_(this),
403 was_ui_latency_logged_(false) { 406 was_ui_latency_logged_(false) {
(...skipping 10 matching lines...) Expand all
414 417
415 void AutofillDialogControllerAndroid::LogOnCancelMetrics() { 418 void AutofillDialogControllerAndroid::LogOnCancelMetrics() {
416 GetMetricLogger().LogDialogUiDuration( 419 GetMetricLogger().LogDialogUiDuration(
417 base::Time::Now() - dialog_shown_timestamp_, 420 base::Time::Now() - dialog_shown_timestamp_,
418 AutofillMetrics::DIALOG_CANCELED); 421 AutofillMetrics::DIALOG_CANCELED);
419 422
420 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_CANCELED); 423 GetMetricLogger().LogDialogUiEvent(AutofillMetrics::DIALOG_UI_CANCELED);
421 } 424 }
422 425
423 } // namespace autofill 426 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698