| 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 20 matching lines...) Expand all Loading... |
| 31 using content::WebContents; | 31 using content::WebContents; |
| 32 | 32 |
| 33 namespace autofill { | 33 namespace autofill { |
| 34 | 34 |
| 35 namespace { | 35 namespace { |
| 36 | 36 |
| 37 // Build FormFieldData based on the supplied |autocomplete_attribute|. Will | 37 // Build FormFieldData based on the supplied |autocomplete_attribute|. Will |
| 38 // fill rest of properties with default values. | 38 // fill rest of properties with default values. |
| 39 FormFieldData BuildField(const std::string& autocomplete_attribute) { | 39 FormFieldData BuildField(const std::string& autocomplete_attribute) { |
| 40 FormFieldData field; | 40 FormFieldData field; |
| 41 field.name = string16(); | 41 field.name = base::string16(); |
| 42 field.value = string16(); | 42 field.value = base::string16(); |
| 43 field.autocomplete_attribute = autocomplete_attribute; | 43 field.autocomplete_attribute = autocomplete_attribute; |
| 44 field.form_control_type = "text"; | 44 field.form_control_type = "text"; |
| 45 return field; | 45 return field; |
| 46 } | 46 } |
| 47 | 47 |
| 48 // Build Autocheckout specific form data to be consumed by | 48 // Build Autocheckout specific form data to be consumed by |
| 49 // AutofillDialogController to show the Autocheckout specific UI. | 49 // AutofillDialogController to show the Autocheckout specific UI. |
| 50 FormData BuildAutocheckoutFormData() { | 50 FormData BuildAutocheckoutFormData() { |
| 51 FormData formdata; | 51 FormData formdata; |
| 52 formdata.fields.push_back(BuildField("email")); | 52 formdata.fields.push_back(BuildField("email")); |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 273 in_autocheckout_flow_ = true; | 273 in_autocheckout_flow_ = true; |
| 274 metric_logger_->LogAutocheckoutBuyFlowMetric( | 274 metric_logger_->LogAutocheckoutBuyFlowMetric( |
| 275 AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_STARTED); | 275 AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_STARTED); |
| 276 | 276 |
| 277 profile_.reset(new AutofillProfile()); | 277 profile_.reset(new AutofillProfile()); |
| 278 credit_card_.reset(new CreditCard()); | 278 credit_card_.reset(new CreditCard()); |
| 279 billing_address_.reset(new AutofillProfile()); | 279 billing_address_.reset(new AutofillProfile()); |
| 280 | 280 |
| 281 for (size_t i = 0; i < result->field_count(); ++i) { | 281 for (size_t i = 0; i < result->field_count(); ++i) { |
| 282 AutofillFieldType type = result->field(i)->type(); | 282 AutofillFieldType type = result->field(i)->type(); |
| 283 const string16& value = result->field(i)->value; | 283 const base::string16& value = result->field(i)->value; |
| 284 if (type == CREDIT_CARD_VERIFICATION_CODE) { | 284 if (type == CREDIT_CARD_VERIFICATION_CODE) { |
| 285 cvv_ = result->field(i)->value; | 285 cvv_ = result->field(i)->value; |
| 286 continue; | 286 continue; |
| 287 } | 287 } |
| 288 FieldTypeGroup group = AutofillType(type).group(); | 288 FieldTypeGroup group = AutofillType(type).group(); |
| 289 if (group == AutofillType::CREDIT_CARD) | 289 if (group == AutofillType::CREDIT_CARD) |
| 290 credit_card_->SetRawInfo(type, value); | 290 credit_card_->SetRawInfo(type, value); |
| 291 else if (type == ADDRESS_HOME_COUNTRY) | 291 else if (type == ADDRESS_HOME_COUNTRY) |
| 292 profile_->SetInfo(type, value, autofill_manager_->app_locale()); | 292 profile_->SetInfo(type, value, autofill_manager_->app_locale()); |
| 293 else if (type == ADDRESS_BILLING_COUNTRY) | 293 else if (type == ADDRESS_BILLING_COUNTRY) |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 // <form> | 326 // <form> |
| 327 // <input type="radio" name="sex" value="male">Male<br> | 327 // <input type="radio" name="sex" value="male">Male<br> |
| 328 // <input type="radio" name="sex" value="female">Female | 328 // <input type="radio" name="sex" value="female">Female |
| 329 // </form> | 329 // </form> |
| 330 // If the default value specified at the server is "female", then | 330 // If the default value specified at the server is "female", then |
| 331 // Autofill server responds back with following field mappings | 331 // Autofill server responds back with following field mappings |
| 332 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female") | 332 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female") |
| 333 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female") | 333 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female") |
| 334 // Note that, the field mapping is repeated twice to respond to both the | 334 // Note that, the field mapping is repeated twice to respond to both the |
| 335 // input elements with the same name/signature in the form. | 335 // input elements with the same name/signature in the form. |
| 336 string16 default_value = UTF8ToUTF16(field.default_value()); | 336 base::string16 default_value = UTF8ToUTF16(field.default_value()); |
| 337 // Mark the field checked if server says the default value of the field | 337 // Mark the field checked if server says the default value of the field |
| 338 // to be this field's value. | 338 // to be this field's value. |
| 339 field_to_fill->is_checked = (field.value == default_value); | 339 field_to_fill->is_checked = (field.value == default_value); |
| 340 return; | 340 return; |
| 341 } | 341 } |
| 342 | 342 |
| 343 // Handle verification code directly. | 343 // Handle verification code directly. |
| 344 if (type == CREDIT_CARD_VERIFICATION_CODE) { | 344 if (type == CREDIT_CARD_VERIFICATION_CODE) { |
| 345 field_to_fill->value = cvv_; | 345 field_to_fill->value = cvv_; |
| 346 return; | 346 return; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 377 google_transaction_id_); | 377 google_transaction_id_); |
| 378 | 378 |
| 379 // Log the result of this Autocheckout flow to UMA. | 379 // Log the result of this Autocheckout flow to UMA. |
| 380 metric_logger_->LogAutocheckoutBuyFlowMetric( | 380 metric_logger_->LogAutocheckoutBuyFlowMetric( |
| 381 AutocheckoutStatusToUmaMetric(status)); | 381 AutocheckoutStatusToUmaMetric(status)); |
| 382 | 382 |
| 383 google_transaction_id_ = kTransactionIdNotSet; | 383 google_transaction_id_ = kTransactionIdNotSet; |
| 384 } | 384 } |
| 385 | 385 |
| 386 } // namespace autofill | 386 } // namespace autofill |
| OLD | NEW |