| 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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 } | 331 } |
| 332 | 332 |
| 333 // Handle verification code directly. | 333 // Handle verification code directly. |
| 334 if (type == CREDIT_CARD_VERIFICATION_CODE) { | 334 if (type == CREDIT_CARD_VERIFICATION_CODE) { |
| 335 field_to_fill->value = cvv_; | 335 field_to_fill->value = cvv_; |
| 336 return; | 336 return; |
| 337 } | 337 } |
| 338 | 338 |
| 339 // TODO(ramankk): Handle variants in a better fashion, need to distinguish | 339 // TODO(ramankk): Handle variants in a better fashion, need to distinguish |
| 340 // between shipping and billing address. | 340 // between shipping and billing address. |
| 341 if (AutofillType(type).group() == AutofillType::CREDIT_CARD) | 341 if (AutofillType(type).group() == AutofillType::CREDIT_CARD) { |
| 342 credit_card_->FillFormField(field, 0, field_to_fill); | 342 credit_card_->FillFormField( |
| 343 else | 343 field, 0, autofill_manager_->app_locale(), field_to_fill); |
| 344 profile_->FillFormField(field, 0, field_to_fill); | 344 } else { |
| 345 profile_->FillFormField( |
| 346 field, 0, autofill_manager_->app_locale(), field_to_fill); |
| 347 } |
| 345 } | 348 } |
| 346 | 349 |
| 347 void AutocheckoutManager::SendAutocheckoutStatus(AutocheckoutStatus status) { | 350 void AutocheckoutManager::SendAutocheckoutStatus(AutocheckoutStatus status) { |
| 348 // To ensure stale data isn't being sent. | 351 // To ensure stale data isn't being sent. |
| 349 DCHECK_NE(kTransactionIdNotSet, google_transaction_id_); | 352 DCHECK_NE(kTransactionIdNotSet, google_transaction_id_); |
| 350 | 353 |
| 351 AutocheckoutRequestManager::CreateForBrowserContext( | 354 AutocheckoutRequestManager::CreateForBrowserContext( |
| 352 autofill_manager_->GetWebContents()->GetBrowserContext()); | 355 autofill_manager_->GetWebContents()->GetBrowserContext()); |
| 353 AutocheckoutRequestManager* autocheckout_request_manager = | 356 AutocheckoutRequestManager* autocheckout_request_manager = |
| 354 AutocheckoutRequestManager::FromBrowserContext( | 357 AutocheckoutRequestManager::FromBrowserContext( |
| 355 autofill_manager_->GetWebContents()->GetBrowserContext()); | 358 autofill_manager_->GetWebContents()->GetBrowserContext()); |
| 356 // It is assumed that the domain Autocheckout starts on does not change | 359 // It is assumed that the domain Autocheckout starts on does not change |
| 357 // during the flow. If this proves to be incorrect, the |source_url| from | 360 // during the flow. If this proves to be incorrect, the |source_url| from |
| 358 // AutofillDialogControllerImpl will need to be provided in its callback in | 361 // AutofillDialogControllerImpl will need to be provided in its callback in |
| 359 // addition to the Google transaction id. | 362 // addition to the Google transaction id. |
| 360 autocheckout_request_manager->SendAutocheckoutStatus( | 363 autocheckout_request_manager->SendAutocheckoutStatus( |
| 361 status, | 364 status, |
| 362 autofill_manager_->GetWebContents()->GetURL(), | 365 autofill_manager_->GetWebContents()->GetURL(), |
| 363 google_transaction_id_); | 366 google_transaction_id_); |
| 364 | 367 |
| 365 // Log the result of this Autocheckout flow to UMA. | 368 // Log the result of this Autocheckout flow to UMA. |
| 366 metric_logger_->LogAutocheckoutBuyFlowMetric( | 369 metric_logger_->LogAutocheckoutBuyFlowMetric( |
| 367 AutocheckoutStatusToUmaMetric(status)); | 370 AutocheckoutStatusToUmaMetric(status)); |
| 368 | 371 |
| 369 google_transaction_id_ = kTransactionIdNotSet; | 372 google_transaction_id_ = kTransactionIdNotSet; |
| 370 } | 373 } |
| 371 | 374 |
| 372 } // namespace autofill | 375 } // namespace autofill |
| OLD | NEW |