diff options
author | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-14 23:01:37 +0000 |
---|---|---|
committer | isherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-02-14 23:01:37 +0000 |
commit | c64f92c12fad31fa0cf49e236cb414acdbb75e1d (patch) | |
tree | eaf28da9acb11e5f4d6d4cc05c832814d7a435b7 /chrome/browser | |
parent | 08a2cb4cbfdceac827330fc7de34752d0b73efd4 (diff) | |
download | chromium_src-c64f92c12fad31fa0cf49e236cb414acdbb75e1d.zip chromium_src-c64f92c12fad31fa0cf49e236cb414acdbb75e1d.tar.gz chromium_src-c64f92c12fad31fa0cf49e236cb414acdbb75e1d.tar.bz2 |
Pass DictionaryValues directly to Autofill WebUI handlers
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/6513006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74868 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/dom_ui/options/autofill_options_handler.cc | 69 | ||||
-rw-r--r-- | chrome/browser/resources/options/autofill_options.js | 4 |
2 files changed, 32 insertions, 41 deletions
diff --git a/chrome/browser/dom_ui/options/autofill_options_handler.cc b/chrome/browser/dom_ui/options/autofill_options_handler.cc index fbb0ce9..4ab22e4 100644 --- a/chrome/browser/dom_ui/options/autofill_options_handler.cc +++ b/chrome/browser/dom_ui/options/autofill_options_handler.cc @@ -250,39 +250,34 @@ void AutoFillOptionsHandler::LoadAddressEditor(const ListValue* args) { return; } - // TODO(jhawkins): This is hacky because we can't send DictionaryValue - // directly to CallJavascriptFunction(). - ListValue addressList; - DictionaryValue* address = new DictionaryValue(); - address->SetString("guid", profile->guid()); - address->SetString("fullName", - profile->GetFieldText(AutoFillType(NAME_FULL))); - address->SetString("companyName", - profile->GetFieldText(AutoFillType(COMPANY_NAME))); - address->SetString("addrLine1", - profile->GetFieldText(AutoFillType(ADDRESS_HOME_LINE1))); - address->SetString("addrLine2", - profile->GetFieldText(AutoFillType(ADDRESS_HOME_LINE2))); - address->SetString("city", - profile->GetFieldText(AutoFillType(ADDRESS_HOME_CITY))); - address->SetString("state", - profile->GetFieldText(AutoFillType(ADDRESS_HOME_STATE))); - address->SetString("zipCode", - profile->GetFieldText(AutoFillType(ADDRESS_HOME_ZIP))); - address->SetString("country", + DictionaryValue address; + address.SetString("guid", profile->guid()); + address.SetString("fullName", + profile->GetFieldText(AutoFillType(NAME_FULL))); + address.SetString("companyName", + profile->GetFieldText(AutoFillType(COMPANY_NAME))); + address.SetString("addrLine1", + profile->GetFieldText(AutoFillType(ADDRESS_HOME_LINE1))); + address.SetString("addrLine2", + profile->GetFieldText(AutoFillType(ADDRESS_HOME_LINE2))); + address.SetString("city", + profile->GetFieldText(AutoFillType(ADDRESS_HOME_CITY))); + address.SetString("state", + profile->GetFieldText(AutoFillType(ADDRESS_HOME_STATE))); + address.SetString("zipCode", + profile->GetFieldText(AutoFillType(ADDRESS_HOME_ZIP))); + address.SetString("country", profile->GetFieldText(AutoFillType(ADDRESS_HOME_COUNTRY))); - address->SetString( + address.SetString( "phone", profile->GetFieldText(AutoFillType(PHONE_HOME_WHOLE_NUMBER))); - address->SetString( + address.SetString( "fax", profile->GetFieldText(AutoFillType(PHONE_FAX_WHOLE_NUMBER))); - address->SetString("email", + address.SetString("email", profile->GetFieldText(AutoFillType(EMAIL_ADDRESS))); - addressList.Append(address); - web_ui_->CallJavascriptFunction(L"AutoFillOptions.editAddress", - addressList); + web_ui_->CallJavascriptFunction(L"AutoFillOptions.editAddress", address); } void AutoFillOptionsHandler::LoadCreditCardEditor(const ListValue* args) { @@ -304,29 +299,25 @@ void AutoFillOptionsHandler::LoadCreditCardEditor(const ListValue* args) { return; } - // TODO(jhawkins): This is hacky because we can't send DictionaryValue - // directly to CallJavascriptFunction(). - ListValue credit_card_list; - DictionaryValue* credit_card_data = new DictionaryValue(); - credit_card_data->SetString("guid", credit_card->guid()); - credit_card_data->SetString( + DictionaryValue credit_card_data; + credit_card_data.SetString("guid", credit_card->guid()); + credit_card_data.SetString( "nameOnCard", credit_card->GetFieldText(AutoFillType(CREDIT_CARD_NAME))); - credit_card_data->SetString( + credit_card_data.SetString( "creditCardNumber", credit_card->GetFieldText(AutoFillType(CREDIT_CARD_NUMBER))); - credit_card_data->SetString("obfuscatedCardNumber", - credit_card->ObfuscatedNumber()); - credit_card_data->SetString( + credit_card_data.SetString("obfuscatedCardNumber", + credit_card->ObfuscatedNumber()); + credit_card_data.SetString( "expirationMonth", credit_card->GetFieldText(AutoFillType(CREDIT_CARD_EXP_MONTH))); - credit_card_data->SetString( + credit_card_data.SetString( "expirationYear", credit_card->GetFieldText(AutoFillType(CREDIT_CARD_EXP_4_DIGIT_YEAR))); - credit_card_list.Append(credit_card_data); web_ui_->CallJavascriptFunction(L"AutoFillOptions.editCreditCard", - credit_card_list); + credit_card_data); } void AutoFillOptionsHandler::SetAddress(const ListValue* args) { diff --git a/chrome/browser/resources/options/autofill_options.js b/chrome/browser/resources/options/autofill_options.js index a8dccd4..9f4ac3b 100644 --- a/chrome/browser/resources/options/autofill_options.js +++ b/chrome/browser/resources/options/autofill_options.js @@ -171,7 +171,7 @@ cr.define('options', function() { showEditAddressOverlay_: function(address) { var title = localStrings.getString('editAddressTitle'); AutoFillEditAddressOverlay.setTitle(title); - AutoFillEditAddressOverlay.loadAddress(address[0]); + AutoFillEditAddressOverlay.loadAddress(address); OptionsPage.navigateToPage('autoFillEditAddressOverlay'); }, @@ -184,7 +184,7 @@ cr.define('options', function() { showEditCreditCardOverlay_: function(creditCard) { var title = localStrings.getString('editCreditCardTitle'); AutoFillEditCreditCardOverlay.setTitle(title); - AutoFillEditCreditCardOverlay.loadCreditCard(creditCard[0]); + AutoFillEditCreditCardOverlay.loadCreditCard(creditCard); OptionsPage.navigateToPage('autoFillEditCreditCardOverlay'); }, }; |