| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 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 | 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 "components/autofill/browser/autocheckout_manager.h" | 5 #include "components/autofill/browser/autocheckout_manager.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "components/autofill/browser/autocheckout_request_manager.h" | 10 #include "components/autofill/browser/autocheckout_request_manager.h" |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 } | 347 } |
| 348 | 348 |
| 349 // Handle verification code directly. | 349 // Handle verification code directly. |
| 350 if (type == CREDIT_CARD_VERIFICATION_CODE) { | 350 if (type == CREDIT_CARD_VERIFICATION_CODE) { |
| 351 field_to_fill->value = cvv_; | 351 field_to_fill->value = cvv_; |
| 352 return; | 352 return; |
| 353 } | 353 } |
| 354 | 354 |
| 355 // TODO(ramankk): Handle variants in a better fashion, need to distinguish | 355 // TODO(ramankk): Handle variants in a better fashion, need to distinguish |
| 356 // between shipping and billing address. | 356 // between shipping and billing address. |
| 357 if (AutofillType(type).group() == AutofillType::CREDIT_CARD) | 357 if (AutofillType(type).group() == AutofillType::CREDIT_CARD) { |
| 358 credit_card_->FillFormField(field, 0, field_to_fill); | 358 credit_card_->FillFormField( |
| 359 else | 359 field, 0, autofill_manager_->app_locale(), field_to_fill); |
| 360 profile_->FillFormField(field, 0, field_to_fill); | 360 } else { |
| 361 profile_->FillFormField( |
| 362 field, 0, autofill_manager_->app_locale(), field_to_fill); |
| 363 } |
| 361 } | 364 } |
| 362 | 365 |
| 363 void AutocheckoutManager::SendAutocheckoutStatus(AutocheckoutStatus status) { | 366 void AutocheckoutManager::SendAutocheckoutStatus(AutocheckoutStatus status) { |
| 364 // To ensure stale data isn't being sent. | 367 // To ensure stale data isn't being sent. |
| 365 DCHECK_NE(kTransactionIdNotSet, google_transaction_id_); | 368 DCHECK_NE(kTransactionIdNotSet, google_transaction_id_); |
| 366 | 369 |
| 367 AutocheckoutRequestManager::CreateForBrowserContext( | 370 AutocheckoutRequestManager::CreateForBrowserContext( |
| 368 autofill_manager_->GetWebContents()->GetBrowserContext()); | 371 autofill_manager_->GetWebContents()->GetBrowserContext()); |
| 369 AutocheckoutRequestManager* autocheckout_request_manager = | 372 AutocheckoutRequestManager* autocheckout_request_manager = |
| 370 AutocheckoutRequestManager::FromBrowserContext( | 373 AutocheckoutRequestManager::FromBrowserContext( |
| 371 autofill_manager_->GetWebContents()->GetBrowserContext()); | 374 autofill_manager_->GetWebContents()->GetBrowserContext()); |
| 372 // It is assumed that the domain Autocheckout starts on does not change | 375 // It is assumed that the domain Autocheckout starts on does not change |
| 373 // during the flow. If this proves to be incorrect, the |source_url| from | 376 // during the flow. If this proves to be incorrect, the |source_url| from |
| 374 // AutofillDialogControllerImpl will need to be provided in its callback in | 377 // AutofillDialogControllerImpl will need to be provided in its callback in |
| 375 // addition to the Google transaction id. | 378 // addition to the Google transaction id. |
| 376 autocheckout_request_manager->SendAutocheckoutStatus( | 379 autocheckout_request_manager->SendAutocheckoutStatus( |
| 377 status, | 380 status, |
| 378 autofill_manager_->GetWebContents()->GetURL(), | 381 autofill_manager_->GetWebContents()->GetURL(), |
| 379 google_transaction_id_); | 382 google_transaction_id_); |
| 380 | 383 |
| 381 // Log the result of this Autocheckout flow to UMA. | 384 // Log the result of this Autocheckout flow to UMA. |
| 382 metric_logger_->LogAutocheckoutBuyFlowMetric( | 385 metric_logger_->LogAutocheckoutBuyFlowMetric( |
| 383 AutocheckoutStatusToUmaMetric(status)); | 386 AutocheckoutStatusToUmaMetric(status)); |
| 384 | 387 |
| 385 google_transaction_id_ = kTransactionIdNotSet; | 388 google_transaction_id_ = kTransactionIdNotSet; |
| 386 } | 389 } |
| 387 | 390 |
| 388 } // namespace autofill | 391 } // namespace autofill |
| OLD | NEW |