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

Side by Side Diff: chrome/browser/ui/webui/options/autofill_options_handler.cc

Issue 11360055: [Autofill] Rename GetInfo and SetInfo to GetRawInfo and SetRawInfo (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix names in more tests Created 8 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/webui/options/autofill_options_handler.h" 5 #include "chrome/browser/ui/webui/options/autofill_options_handler.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
481 // removed). This will activate the editor for a profile that has been 481 // removed). This will activate the editor for a profile that has been
482 // removed. Do nothing in that case. 482 // removed. Do nothing in that case.
483 return; 483 return;
484 } 484 }
485 485
486 DictionaryValue address; 486 DictionaryValue address;
487 address.SetString("guid", profile->guid()); 487 address.SetString("guid", profile->guid());
488 scoped_ptr<ListValue> list; 488 scoped_ptr<ListValue> list;
489 GetNameList(*profile, &list); 489 GetNameList(*profile, &list);
490 address.Set("fullName", list.release()); 490 address.Set("fullName", list.release());
491 address.SetString("companyName", profile->GetInfo(COMPANY_NAME)); 491 address.SetString("companyName", profile->GetRawInfo(COMPANY_NAME));
492 address.SetString("addrLine1", profile->GetInfo(ADDRESS_HOME_LINE1)); 492 address.SetString("addrLine1", profile->GetRawInfo(ADDRESS_HOME_LINE1));
493 address.SetString("addrLine2", profile->GetInfo(ADDRESS_HOME_LINE2)); 493 address.SetString("addrLine2", profile->GetRawInfo(ADDRESS_HOME_LINE2));
494 address.SetString("city", profile->GetInfo(ADDRESS_HOME_CITY)); 494 address.SetString("city", profile->GetRawInfo(ADDRESS_HOME_CITY));
495 address.SetString("state", profile->GetInfo(ADDRESS_HOME_STATE)); 495 address.SetString("state", profile->GetRawInfo(ADDRESS_HOME_STATE));
496 address.SetString("postalCode", profile->GetInfo(ADDRESS_HOME_ZIP)); 496 address.SetString("postalCode", profile->GetRawInfo(ADDRESS_HOME_ZIP));
497 address.SetString("country", profile->CountryCode()); 497 address.SetString("country", profile->CountryCode());
498 GetValueList(*profile, PHONE_HOME_WHOLE_NUMBER, &list); 498 GetValueList(*profile, PHONE_HOME_WHOLE_NUMBER, &list);
499 address.Set("phone", list.release()); 499 address.Set("phone", list.release());
500 GetValueList(*profile, EMAIL_ADDRESS, &list); 500 GetValueList(*profile, EMAIL_ADDRESS, &list);
501 address.Set("email", list.release()); 501 address.Set("email", list.release());
502 502
503 web_ui()->CallJavascriptFunction("AutofillOptions.editAddress", address); 503 web_ui()->CallJavascriptFunction("AutofillOptions.editAddress", address);
504 } 504 }
505 505
506 void AutofillOptionsHandler::LoadCreditCardEditor(const ListValue* args) { 506 void AutofillOptionsHandler::LoadCreditCardEditor(const ListValue* args) {
(...skipping 11 matching lines...) Expand all
518 // quickly click again on the list item before the item is removed (since 518 // quickly click again on the list item before the item is removed (since
519 // the list is not updated until the model tells the list an item has been 519 // the list is not updated until the model tells the list an item has been
520 // removed). This will activate the editor for a profile that has been 520 // removed). This will activate the editor for a profile that has been
521 // removed. Do nothing in that case. 521 // removed. Do nothing in that case.
522 return; 522 return;
523 } 523 }
524 524
525 DictionaryValue credit_card_data; 525 DictionaryValue credit_card_data;
526 credit_card_data.SetString("guid", credit_card->guid()); 526 credit_card_data.SetString("guid", credit_card->guid());
527 credit_card_data.SetString("nameOnCard", 527 credit_card_data.SetString("nameOnCard",
528 credit_card->GetInfo(CREDIT_CARD_NAME)); 528 credit_card->GetRawInfo(CREDIT_CARD_NAME));
529 credit_card_data.SetString("creditCardNumber", 529 credit_card_data.SetString("creditCardNumber",
530 credit_card->GetInfo(CREDIT_CARD_NUMBER)); 530 credit_card->GetRawInfo(CREDIT_CARD_NUMBER));
531 credit_card_data.SetString("expirationMonth", 531 credit_card_data.SetString("expirationMonth",
532 credit_card->GetInfo(CREDIT_CARD_EXP_MONTH)); 532 credit_card->GetRawInfo(CREDIT_CARD_EXP_MONTH));
533 credit_card_data.SetString( 533 credit_card_data.SetString(
534 "expirationYear", 534 "expirationYear",
535 credit_card->GetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR)); 535 credit_card->GetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR));
536 536
537 web_ui()->CallJavascriptFunction("AutofillOptions.editCreditCard", 537 web_ui()->CallJavascriptFunction("AutofillOptions.editCreditCard",
538 credit_card_data); 538 credit_card_data);
539 } 539 }
540 540
541 void AutofillOptionsHandler::SetAddress(const ListValue* args) { 541 void AutofillOptionsHandler::SetAddress(const ListValue* args) {
542 if (!IsPersonalDataLoaded()) 542 if (!IsPersonalDataLoaded())
543 return; 543 return;
544 544
545 std::string guid; 545 std::string guid;
546 if (!args->GetString(0, &guid)) { 546 if (!args->GetString(0, &guid)) {
547 NOTREACHED(); 547 NOTREACHED();
548 return; 548 return;
549 } 549 }
550 550
551 AutofillProfile profile(guid); 551 AutofillProfile profile(guid);
552 552
553 std::string country_code; 553 std::string country_code;
554 string16 value; 554 string16 value;
555 const ListValue* list_value; 555 const ListValue* list_value;
556 if (args->GetList(1, &list_value)) 556 if (args->GetList(1, &list_value))
557 SetNameList(list_value, &profile); 557 SetNameList(list_value, &profile);
558 if (args->GetString(2, &value)) 558 if (args->GetString(2, &value))
559 profile.SetInfo(COMPANY_NAME, value); 559 profile.SetRawInfo(COMPANY_NAME, value);
Dan Beam 2012/11/09 18:46:30 same nit re: \n after if
Ilya Sherman 2012/11/10 03:21:33 Done.
560 if (args->GetString(3, &value)) 560 if (args->GetString(3, &value))
561 profile.SetInfo(ADDRESS_HOME_LINE1, value); 561 profile.SetRawInfo(ADDRESS_HOME_LINE1, value);
562 if (args->GetString(4, &value)) 562 if (args->GetString(4, &value))
563 profile.SetInfo(ADDRESS_HOME_LINE2, value); 563 profile.SetRawInfo(ADDRESS_HOME_LINE2, value);
564 if (args->GetString(5, &value)) 564 if (args->GetString(5, &value))
565 profile.SetInfo(ADDRESS_HOME_CITY, value); 565 profile.SetRawInfo(ADDRESS_HOME_CITY, value);
566 if (args->GetString(6, &value)) 566 if (args->GetString(6, &value))
567 profile.SetInfo(ADDRESS_HOME_STATE, value); 567 profile.SetRawInfo(ADDRESS_HOME_STATE, value);
568 if (args->GetString(7, &value)) 568 if (args->GetString(7, &value))
569 profile.SetInfo(ADDRESS_HOME_ZIP, value); 569 profile.SetRawInfo(ADDRESS_HOME_ZIP, value);
570 if (args->GetString(8, &country_code)) 570 if (args->GetString(8, &country_code))
571 profile.SetCountryCode(country_code); 571 profile.SetCountryCode(country_code);
572 if (args->GetList(9, &list_value)) 572 if (args->GetList(9, &list_value))
573 SetValueList(list_value, PHONE_HOME_WHOLE_NUMBER, &profile); 573 SetValueList(list_value, PHONE_HOME_WHOLE_NUMBER, &profile);
574 if (args->GetList(10, &list_value)) 574 if (args->GetList(10, &list_value))
575 SetValueList(list_value, EMAIL_ADDRESS, &profile); 575 SetValueList(list_value, EMAIL_ADDRESS, &profile);
576 576
577 if (!base::IsValidGUID(profile.guid())) { 577 if (!base::IsValidGUID(profile.guid())) {
578 profile.set_guid(base::GenerateGUID()); 578 profile.set_guid(base::GenerateGUID());
579 personal_data_->AddProfile(profile); 579 personal_data_->AddProfile(profile);
580 } else { 580 } else {
581 personal_data_->UpdateProfile(profile); 581 personal_data_->UpdateProfile(profile);
582 } 582 }
583 } 583 }
584 584
585 void AutofillOptionsHandler::SetCreditCard(const ListValue* args) { 585 void AutofillOptionsHandler::SetCreditCard(const ListValue* args) {
586 if (!IsPersonalDataLoaded()) 586 if (!IsPersonalDataLoaded())
587 return; 587 return;
588 588
589 std::string guid; 589 std::string guid;
590 if (!args->GetString(0, &guid)) { 590 if (!args->GetString(0, &guid)) {
591 NOTREACHED(); 591 NOTREACHED();
592 return; 592 return;
593 } 593 }
594 594
595 CreditCard credit_card(guid); 595 CreditCard credit_card(guid);
596 596
597 string16 value; 597 string16 value;
598 if (args->GetString(1, &value)) 598 if (args->GetString(1, &value))
Dan Beam 2012/11/09 18:46:30 and here
Ilya Sherman 2012/11/10 03:21:33 Done.
599 credit_card.SetInfo(CREDIT_CARD_NAME, value); 599 credit_card.SetRawInfo(CREDIT_CARD_NAME, value);
600 if (args->GetString(2, &value)) 600 if (args->GetString(2, &value))
601 credit_card.SetInfo(CREDIT_CARD_NUMBER, value); 601 credit_card.SetRawInfo(CREDIT_CARD_NUMBER, value);
602 if (args->GetString(3, &value)) 602 if (args->GetString(3, &value))
603 credit_card.SetInfo(CREDIT_CARD_EXP_MONTH, value); 603 credit_card.SetRawInfo(CREDIT_CARD_EXP_MONTH, value);
604 if (args->GetString(4, &value)) 604 if (args->GetString(4, &value))
605 credit_card.SetInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, value); 605 credit_card.SetRawInfo(CREDIT_CARD_EXP_4_DIGIT_YEAR, value);
606 606
607 if (!base::IsValidGUID(credit_card.guid())) { 607 if (!base::IsValidGUID(credit_card.guid())) {
608 credit_card.set_guid(base::GenerateGUID()); 608 credit_card.set_guid(base::GenerateGUID());
609 personal_data_->AddCreditCard(credit_card); 609 personal_data_->AddCreditCard(credit_card);
610 } else { 610 } else {
611 personal_data_->UpdateCreditCard(credit_card); 611 personal_data_->UpdateCreditCard(credit_card);
612 } 612 }
613 } 613 }
614 614
615 void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) { 615 void AutofillOptionsHandler::ValidatePhoneNumbers(const ListValue* args) {
616 if (!IsPersonalDataLoaded()) 616 if (!IsPersonalDataLoaded())
617 return; 617 return;
618 618
619 scoped_ptr<ListValue> list_value = ValidatePhoneArguments(args); 619 scoped_ptr<ListValue> list_value = ValidatePhoneArguments(args);
620 620
621 web_ui()->CallJavascriptFunction( 621 web_ui()->CallJavascriptFunction(
622 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value); 622 "AutofillEditAddressOverlay.setValidatedPhoneNumbers", *list_value);
623 } 623 }
624 624
625 bool AutofillOptionsHandler::IsPersonalDataLoaded() const { 625 bool AutofillOptionsHandler::IsPersonalDataLoaded() const {
626 return personal_data_ && personal_data_->IsDataLoaded(); 626 return personal_data_ && personal_data_->IsDataLoaded();
627 } 627 }
628 628
629 } // namespace options 629 } // namespace options
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698