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

Side by Side Diff: components/autofill/content/browser/autocheckout_manager.cc

Issue 22040002: [Autofill] Add a separate enumeration for HTML field type hints. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add docs Created 7 years, 4 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 "components/autofill/content/browser/autocheckout_manager.h" 5 #include "components/autofill/content/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/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "components/autofill/content/browser/autocheckout_request_manager.h" 10 #include "components/autofill/content/browser/autocheckout_request_manager.h"
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 metric_logger_->LogAutocheckoutBuyFlowMetric( 344 metric_logger_->LogAutocheckoutBuyFlowMetric(
345 AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_STARTED); 345 AutofillMetrics::AUTOCHECKOUT_BUY_FLOW_STARTED);
346 346
347 profile_.reset(new AutofillProfile()); 347 profile_.reset(new AutofillProfile());
348 credit_card_.reset(new CreditCard()); 348 credit_card_.reset(new CreditCard());
349 billing_address_.reset(new AutofillProfile()); 349 billing_address_.reset(new AutofillProfile());
350 350
351 for (size_t i = 0; i < result->field_count(); ++i) { 351 for (size_t i = 0; i < result->field_count(); ++i) {
352 const AutofillType& type = result->field(i)->Type(); 352 const AutofillType& type = result->field(i)->Type();
353 const base::string16& value = result->field(i)->value; 353 const base::string16& value = result->field(i)->value;
354 if (type.native_type() == CREDIT_CARD_VERIFICATION_CODE) { 354 NativeFieldType native_type = type.GetEquivalentNativeType();
355 if (native_type == CREDIT_CARD_VERIFICATION_CODE) {
355 cvv_ = result->field(i)->value; 356 cvv_ = result->field(i)->value;
356 continue; 357 continue;
357 } 358 }
358 FieldTypeGroup group = type.group(); 359 FieldTypeGroup group = type.group();
359 if (group == CREDIT_CARD) { 360 if (group == CREDIT_CARD) {
360 credit_card_->SetRawInfo(type.native_type(), value); 361 credit_card_->SetRawInfo(native_type, value);
361 // TODO(dgwallinga): Find a way of cleanly deprecating CREDIT_CARD_NAME. 362 // TODO(dgwallinga): Find a way of cleanly deprecating CREDIT_CARD_NAME.
362 // code.google.com/p/chromium/issues/detail?id=263498 363 // code.google.com/p/chromium/issues/detail?id=263498
363 if (type.native_type() == CREDIT_CARD_NAME) 364 if (native_type == CREDIT_CARD_NAME)
364 billing_address_->SetRawInfo(NAME_BILLING_FULL, value); 365 billing_address_->SetRawInfo(NAME_BILLING_FULL, value);
365 } else if (type.native_type() == ADDRESS_HOME_COUNTRY) { 366 } else if (native_type == ADDRESS_HOME_COUNTRY) {
366 profile_->SetInfo(type, value, autofill_manager_->app_locale()); 367 if (IsBillingGroup(group))
367 } else if (type.native_type() == ADDRESS_BILLING_COUNTRY) { 368 billing_address_->SetInfo(type, value, autofill_manager_->app_locale());
368 billing_address_->SetInfo(type, value, autofill_manager_->app_locale()); 369 else
370 profile_->SetInfo(type, value, autofill_manager_->app_locale());
369 } else if (IsBillingGroup(group)) { 371 } else if (IsBillingGroup(group)) {
370 billing_address_->SetRawInfo(type.native_type(), value); 372 billing_address_->SetRawInfo(native_type, value);
371 } else { 373 } else {
372 profile_->SetRawInfo(type.native_type(), value); 374 profile_->SetRawInfo(native_type, value);
373 } 375 }
374 } 376 }
375 377
376 // Page types only available in first-page meta data, so save 378 // Page types only available in first-page meta data, so save
377 // them for use later as we navigate. 379 // them for use later as we navigate.
378 page_types_ = page_meta_data_->page_types; 380 page_types_ = page_meta_data_->page_types;
379 SetStepProgressForPage(page_meta_data_->current_page_number, 381 SetStepProgressForPage(page_meta_data_->current_page_number,
380 AUTOCHECKOUT_STEP_STARTED); 382 AUTOCHECKOUT_STEP_STARTED);
381 383
382 FillForms(); 384 FillForms();
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
442 } 444 }
443 445
444 void AutocheckoutManager::SetValue(const AutofillField& field, 446 void AutocheckoutManager::SetValue(const AutofillField& field,
445 FormFieldData* field_to_fill) { 447 FormFieldData* field_to_fill) {
446 // No-op if Autofill server doesn't know about the field. 448 // No-op if Autofill server doesn't know about the field.
447 if (field.server_type() == NO_SERVER_DATA) 449 if (field.server_type() == NO_SERVER_DATA)
448 return; 450 return;
449 451
450 const AutofillType& type = field.Type(); 452 const AutofillType& type = field.Type();
451 453
452 if (type.native_type() == FIELD_WITH_DEFAULT_VALUE) { 454 NativeFieldType native_type = type.GetEquivalentNativeType();
455 if (native_type == FIELD_WITH_DEFAULT_VALUE) {
453 // For a form with radio buttons, like: 456 // For a form with radio buttons, like:
454 // <form> 457 // <form>
455 // <input type="radio" name="sex" value="male">Male<br> 458 // <input type="radio" name="sex" value="male">Male<br>
456 // <input type="radio" name="sex" value="female">Female 459 // <input type="radio" name="sex" value="female">Female
457 // </form> 460 // </form>
458 // If the default value specified at the server is "female", then 461 // If the default value specified at the server is "female", then
459 // Autofill server responds back with following field mappings 462 // Autofill server responds back with following field mappings
460 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female") 463 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female")
461 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female") 464 // (fieldtype: FIELD_WITH_DEFAULT_VALUE, value: "female")
462 // Note that, the field mapping is repeated twice to respond to both the 465 // Note that, the field mapping is repeated twice to respond to both the
(...skipping 13 matching lines...) Expand all
476 } else if (field.form_control_type == "select-one") { 479 } else if (field.form_control_type == "select-one") {
477 field_to_fill->value = default_value; 480 field_to_fill->value = default_value;
478 } else { 481 } else {
479 // FIELD_WITH_DEFAULT_VALUE should not be used for other type of fields. 482 // FIELD_WITH_DEFAULT_VALUE should not be used for other type of fields.
480 NOTREACHED(); 483 NOTREACHED();
481 } 484 }
482 return; 485 return;
483 } 486 }
484 487
485 // Handle verification code directly. 488 // Handle verification code directly.
486 if (type.native_type() == CREDIT_CARD_VERIFICATION_CODE) { 489 if (native_type == CREDIT_CARD_VERIFICATION_CODE) {
487 field_to_fill->value = cvv_; 490 field_to_fill->value = cvv_;
488 return; 491 return;
489 } 492 }
490 493
491 if (type.group() == CREDIT_CARD) { 494 if (type.group() == CREDIT_CARD) {
492 credit_card_->FillFormField( 495 credit_card_->FillFormField(
493 field, 0, autofill_manager_->app_locale(), field_to_fill); 496 field, 0, autofill_manager_->app_locale(), field_to_fill);
494 } else if (IsBillingGroup(type.group())) { 497 } else if (IsBillingGroup(type.group())) {
495 billing_address_->FillFormField( 498 billing_address_->FillFormField(
496 field, 0, autofill_manager_->app_locale(), field_to_fill); 499 field, 0, autofill_manager_->app_locale(), field_to_fill);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 549
547 SendAutocheckoutStatus(status); 550 SendAutocheckoutStatus(status);
548 if (status == SUCCESS) 551 if (status == SUCCESS)
549 autofill_manager_->delegate()->OnAutocheckoutSuccess(); 552 autofill_manager_->delegate()->OnAutocheckoutSuccess();
550 else 553 else
551 autofill_manager_->delegate()->OnAutocheckoutError(); 554 autofill_manager_->delegate()->OnAutocheckoutError();
552 in_autocheckout_flow_ = false; 555 in_autocheckout_flow_ = false;
553 } 556 }
554 557
555 } // namespace autofill 558 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698