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

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

Issue 23033016: Remove autocheckout code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Even more deletes, and Ilya review. Created 7 years, 3 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 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 jmerchant_domain.obj())); 286 jmerchant_domain.obj()));
287 } 287 }
288 288
289 void AutofillDialogControllerAndroid::Hide() { 289 void AutofillDialogControllerAndroid::Hide() {
290 // TODO(aruslan): http://crbug.com/177373 Autocheckout. 290 // TODO(aruslan): http://crbug.com/177373 Autocheckout.
291 NOTIMPLEMENTED(); 291 NOTIMPLEMENTED();
292 } 292 }
293 293
294 void AutofillDialogControllerAndroid::TabActivated() {} 294 void AutofillDialogControllerAndroid::TabActivated() {}
295 295
296 void AutofillDialogControllerAndroid::AddAutocheckoutStep(
297 AutocheckoutStepType step_type) {
298 // TODO(aruslan): http://crbug.com/177373 Autocheckout.
299 NOTIMPLEMENTED() << " step_type = " << step_type;
300 }
301
302 void AutofillDialogControllerAndroid::UpdateAutocheckoutStep(
303 AutocheckoutStepType step_type,
304 AutocheckoutStepStatus step_status) {
305 // TODO(aruslan): http://crbug.com/177373 Autocheckout.
306 NOTIMPLEMENTED() << " step_type=" << step_type
307 << " step_status=" << step_status;
308 }
309
310 void AutofillDialogControllerAndroid::OnAutocheckoutError() {
311 // TODO(aruslan): http://crbug.com/177373 Autocheckout.
312 NOTIMPLEMENTED();
313 DCHECK_EQ(AUTOCHECKOUT_IN_PROGRESS, autocheckout_state_);
314 GetMetricLogger().LogAutocheckoutDuration(
315 base::Time::Now() - autocheckout_started_timestamp_,
316 AutofillMetrics::AUTOCHECKOUT_FAILED);
317 SetAutocheckoutState(AUTOCHECKOUT_ERROR);
318 autocheckout_started_timestamp_ = base::Time();
319 }
320
321 void AutofillDialogControllerAndroid::OnAutocheckoutSuccess() {
322 // TODO(aruslan): http://crbug.com/177373 Autocheckout.
323 NOTIMPLEMENTED();
324 DCHECK_EQ(AUTOCHECKOUT_IN_PROGRESS, autocheckout_state_);
325 GetMetricLogger().LogAutocheckoutDuration(
326 base::Time::Now() - autocheckout_started_timestamp_,
327 AutofillMetrics::AUTOCHECKOUT_SUCCEEDED);
328 SetAutocheckoutState(AUTOCHECKOUT_SUCCESS);
329 autocheckout_started_timestamp_ = base::Time();
330 }
331
332 DialogType AutofillDialogControllerAndroid::GetDialogType() const { 296 DialogType AutofillDialogControllerAndroid::GetDialogType() const {
333 return dialog_type_; 297 return dialog_type_;
334 } 298 }
335 299
336 // static 300 // static
337 bool AutofillDialogControllerAndroid:: 301 bool AutofillDialogControllerAndroid::
338 RegisterAutofillDialogControllerAndroid(JNIEnv* env) { 302 RegisterAutofillDialogControllerAndroid(JNIEnv* env) {
339 return RegisterNativesImpl(env); 303 return RegisterNativesImpl(env);
340 } 304 }
341 305
342 void AutofillDialogControllerAndroid::DialogCancel(JNIEnv* env, 306 void AutofillDialogControllerAndroid::DialogCancel(JNIEnv* env,
343 jobject obj) { 307 jobject obj) {
344 if (autocheckout_state_ == AUTOCHECKOUT_NOT_STARTED) 308 LogOnCancelMetrics();
345 LogOnCancelMetrics();
346
347 if (autocheckout_state_ == AUTOCHECKOUT_IN_PROGRESS) {
348 GetMetricLogger().LogAutocheckoutDuration(
349 base::Time::Now() - autocheckout_started_timestamp_,
350 AutofillMetrics::AUTOCHECKOUT_CANCELLED);
351 }
352
353 callback_.Run(NULL, std::string()); 309 callback_.Run(NULL, std::string());
354 } 310 }
355 311
356 void AutofillDialogControllerAndroid::DialogContinue( 312 void AutofillDialogControllerAndroid::DialogContinue(
357 JNIEnv* env, 313 JNIEnv* env,
358 jobject obj, 314 jobject obj,
359 jobject wallet, 315 jobject wallet,
360 jboolean jlast_used_choice_is_autofill, 316 jboolean jlast_used_choice_is_autofill,
361 jstring jlast_used_account_name, 317 jstring jlast_used_account_name,
362 jstring jlast_used_billing, 318 jstring jlast_used_billing,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 defaults->SetString(kLastUsedBillingAddressGuid, last_used_billing); 353 defaults->SetString(kLastUsedBillingAddressGuid, last_used_billing);
398 if (!last_used_shipping.empty()) 354 if (!last_used_shipping.empty())
399 defaults->SetString(kLastUsedShippingAddressGuid, last_used_shipping); 355 defaults->SetString(kLastUsedShippingAddressGuid, last_used_shipping);
400 if (!last_used_card.empty()) 356 if (!last_used_card.empty())
401 defaults->SetString(kLastUsedCreditCardGuid, last_used_card); 357 defaults->SetString(kLastUsedCreditCardGuid, last_used_card);
402 } else { 358 } else {
403 LOG(ERROR) << "Failed to save AutofillDialog preferences"; 359 LOG(ERROR) << "Failed to save AutofillDialog preferences";
404 } 360 }
405 } 361 }
406 362
407 if (GetDialogType() == DIALOG_TYPE_AUTOCHECKOUT) {
408 autocheckout_started_timestamp_ = base::Time::Now();
409 SetAutocheckoutState(AUTOCHECKOUT_IN_PROGRESS);
410 }
411
412 LogOnFinishSubmitMetrics(); 363 LogOnFinishSubmitMetrics();
413 364
414 // Callback should be called as late as possible. 365 // Callback should be called as late as possible.
415 callback_.Run(&form_structure_, google_transaction_id); 366 callback_.Run(&form_structure_, google_transaction_id);
416 367
417 // This might delete us. 368 // This might delete us.
418 if (GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE) 369 if (GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE)
419 Hide(); 370 Hide();
420 } 371 }
421 372
422 AutofillDialogControllerAndroid::AutofillDialogControllerAndroid( 373 AutofillDialogControllerAndroid::AutofillDialogControllerAndroid(
423 content::WebContents* contents, 374 content::WebContents* contents,
424 const FormData& form_structure, 375 const FormData& form_structure,
425 const GURL& source_url, 376 const GURL& source_url,
426 const DialogType dialog_type, 377 const DialogType dialog_type,
427 const base::Callback<void(const FormStructure*, 378 const base::Callback<void(const FormStructure*,
428 const std::string&)>& callback) 379 const std::string&)>& callback)
429 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())), 380 : profile_(Profile::FromBrowserContext(contents->GetBrowserContext())),
430 contents_(contents), 381 contents_(contents),
431 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN), 382 initial_user_state_(AutofillMetrics::DIALOG_USER_STATE_UNKNOWN),
432 dialog_type_(dialog_type), 383 dialog_type_(dialog_type),
433 form_structure_(form_structure, std::string()), 384 form_structure_(form_structure),
434 invoked_from_same_origin_(true), 385 invoked_from_same_origin_(true),
435 source_url_(source_url), 386 source_url_(source_url),
436 callback_(callback), 387 callback_(callback),
437 cares_about_shipping_(true), 388 cares_about_shipping_(true),
438 weak_ptr_factory_(this), 389 weak_ptr_factory_(this),
439 autocheckout_state_(AUTOCHECKOUT_NOT_STARTED),
440 was_ui_latency_logged_(false) { 390 was_ui_latency_logged_(false) {
441 DCHECK(!callback_.is_null()); 391 DCHECK(!callback_.is_null());
442 } 392 }
443 393
444 bool AutofillDialogControllerAndroid::RequestingCreditCardInfo() const { 394 bool AutofillDialogControllerAndroid::RequestingCreditCardInfo() const {
445 DCHECK_GT(form_structure_.field_count(), 0U); 395 DCHECK_GT(form_structure_.field_count(), 0U);
446 396
447 for (size_t i = 0; i < form_structure_.field_count(); ++i) { 397 for (size_t i = 0; i < form_structure_.field_count(); ++i) {
448 AutofillType type = form_structure_.field(i)->Type(); 398 AutofillType type = form_structure_.field(i)->Type();
449 if (common::IsCreditCardType(type.GetStorableType())) 399 if (common::IsCreditCardType(type.GetStorableType()))
450 return true; 400 return true;
451 } 401 }
452 402
453 return false; 403 return false;
454 } 404 }
455 405
456 bool AutofillDialogControllerAndroid::TransmissionWillBeSecure() const { 406 bool AutofillDialogControllerAndroid::TransmissionWillBeSecure() const {
457 return source_url_.SchemeIs(chrome::kHttpsScheme); 407 return source_url_.SchemeIs(chrome::kHttpsScheme);
458 } 408 }
459 409
460 void AutofillDialogControllerAndroid::SetAutocheckoutState(
461 AutocheckoutState autocheckout_state) {
462 if (autocheckout_state_ == autocheckout_state)
463 return;
464
465 autocheckout_state_ = autocheckout_state;
466 }
467
468 void AutofillDialogControllerAndroid::LogOnFinishSubmitMetrics() { 410 void AutofillDialogControllerAndroid::LogOnFinishSubmitMetrics() {
469 GetMetricLogger().LogDialogUiDuration( 411 GetMetricLogger().LogDialogUiDuration(
470 base::Time::Now() - dialog_shown_timestamp_, 412 base::Time::Now() - dialog_shown_timestamp_,
471 GetDialogType(), 413 GetDialogType(),
472 AutofillMetrics::DIALOG_ACCEPTED); 414 AutofillMetrics::DIALOG_ACCEPTED);
473 415
474 GetMetricLogger().LogDialogUiEvent( 416 GetMetricLogger().LogDialogUiEvent(
475 GetDialogType(), AutofillMetrics::DIALOG_UI_ACCEPTED); 417 GetDialogType(), AutofillMetrics::DIALOG_UI_ACCEPTED);
476 } 418 }
477 419
478 void AutofillDialogControllerAndroid::LogOnCancelMetrics() { 420 void AutofillDialogControllerAndroid::LogOnCancelMetrics() {
479 GetMetricLogger().LogDialogUiDuration( 421 GetMetricLogger().LogDialogUiDuration(
480 base::Time::Now() - dialog_shown_timestamp_, 422 base::Time::Now() - dialog_shown_timestamp_,
481 GetDialogType(), 423 GetDialogType(),
482 AutofillMetrics::DIALOG_CANCELED); 424 AutofillMetrics::DIALOG_CANCELED);
483 425
484 GetMetricLogger().LogDialogUiEvent( 426 GetMetricLogger().LogDialogUiEvent(
485 GetDialogType(), AutofillMetrics::DIALOG_UI_CANCELED); 427 GetDialogType(), AutofillMetrics::DIALOG_UI_CANCELED);
486 } 428 }
487 429
488 } // namespace autofill 430 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698