OLD | NEW |
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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 348 |
349 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); | 349 std::unique_ptr<base::DictionaryValue> value(new base::DictionaryValue); |
350 value->SetString("guid", profiles[i]->guid()); | 350 value->SetString("guid", profiles[i]->guid()); |
351 value->SetString("label", label_parts[0]); | 351 value->SetString("label", label_parts[0]); |
352 value->SetString("sublabel", labels[i].substr(label_parts[0].size())); | 352 value->SetString("sublabel", labels[i].substr(label_parts[0].size())); |
353 value->SetBoolean("isLocal", profiles[i]->record_type() == | 353 value->SetBoolean("isLocal", profiles[i]->record_type() == |
354 AutofillProfile::LOCAL_PROFILE); | 354 AutofillProfile::LOCAL_PROFILE); |
355 addresses.Append(value.release()); | 355 addresses.Append(value.release()); |
356 } | 356 } |
357 | 357 |
358 web_ui()->CallJavascriptFunction("AutofillOptions.setAddressList", addresses); | 358 web_ui()->CallJavascriptFunctionUnsafe("AutofillOptions.setAddressList", |
| 359 addresses); |
359 | 360 |
360 base::ListValue credit_cards; | 361 base::ListValue credit_cards; |
361 const std::vector<CreditCard*>& cards = personal_data_->GetCreditCards(); | 362 const std::vector<CreditCard*>& cards = personal_data_->GetCreditCards(); |
362 for (const CreditCard* card : cards) { | 363 for (const CreditCard* card : cards) { |
363 credit_cards.Append(CreditCardToDictionary(*card).release()); | 364 credit_cards.Append(CreditCardToDictionary(*card).release()); |
364 } | 365 } |
365 | 366 |
366 web_ui()->CallJavascriptFunction("AutofillOptions.setCreditCardList", | 367 web_ui()->CallJavascriptFunctionUnsafe("AutofillOptions.setCreditCardList", |
367 credit_cards); | 368 credit_cards); |
368 } | 369 } |
369 | 370 |
370 void AutofillOptionsHandler::RemoveData(const base::ListValue* args) { | 371 void AutofillOptionsHandler::RemoveData(const base::ListValue* args) { |
371 DCHECK(IsPersonalDataLoaded()); | 372 DCHECK(IsPersonalDataLoaded()); |
372 | 373 |
373 std::string guid; | 374 std::string guid; |
374 if (!args->GetString(0, &guid)) { | 375 if (!args->GetString(0, &guid)) { |
375 NOTREACHED(); | 376 NOTREACHED(); |
376 return; | 377 return; |
377 } | 378 } |
(...skipping 16 matching lines...) Expand all Loading... |
394 // quickly click again on the list item before the item is removed (since | 395 // quickly click again on the list item before the item is removed (since |
395 // the list is not updated until the model tells the list an item has been | 396 // the list is not updated until the model tells the list an item has been |
396 // removed). This will activate the editor for a profile that has been | 397 // removed). This will activate the editor for a profile that has been |
397 // removed. Do nothing in that case. | 398 // removed. Do nothing in that case. |
398 return; | 399 return; |
399 } | 400 } |
400 | 401 |
401 base::DictionaryValue address; | 402 base::DictionaryValue address; |
402 AutofillProfileToDictionary(*prior_profile, &address); | 403 AutofillProfileToDictionary(*prior_profile, &address); |
403 | 404 |
404 web_ui()->CallJavascriptFunction("AutofillOptions.editAddress", address); | 405 web_ui()->CallJavascriptFunctionUnsafe("AutofillOptions.editAddress", |
| 406 address); |
405 } | 407 } |
406 | 408 |
407 void AutofillOptionsHandler::LoadAddressEditorComponents( | 409 void AutofillOptionsHandler::LoadAddressEditorComponents( |
408 const base::ListValue* args) { | 410 const base::ListValue* args) { |
409 std::string country_code; | 411 std::string country_code; |
410 if (!args->GetString(0, &country_code)) { | 412 if (!args->GetString(0, &country_code)) { |
411 NOTREACHED(); | 413 NOTREACHED(); |
412 return; | 414 return; |
413 } | 415 } |
414 | 416 |
415 base::DictionaryValue input; | 417 base::DictionaryValue input; |
416 std::unique_ptr<base::ListValue> components(new base::ListValue); | 418 std::unique_ptr<base::ListValue> components(new base::ListValue); |
417 std::string language_code; | 419 std::string language_code; |
418 GetAddressComponents(country_code, g_browser_process->GetApplicationLocale(), | 420 GetAddressComponents(country_code, g_browser_process->GetApplicationLocale(), |
419 components.get(), &language_code); | 421 components.get(), &language_code); |
420 input.Set(kComponents, components.release()); | 422 input.Set(kComponents, components.release()); |
421 input.SetString(kLanguageCode, language_code); | 423 input.SetString(kLanguageCode, language_code); |
422 | 424 |
423 web_ui()->CallJavascriptFunction( | 425 web_ui()->CallJavascriptFunctionUnsafe( |
424 "AutofillEditAddressOverlay.loadAddressComponents", input); | 426 "AutofillEditAddressOverlay.loadAddressComponents", input); |
425 } | 427 } |
426 | 428 |
427 void AutofillOptionsHandler::LoadCreditCardEditor(const base::ListValue* args) { | 429 void AutofillOptionsHandler::LoadCreditCardEditor(const base::ListValue* args) { |
428 DCHECK(IsPersonalDataLoaded()); | 430 DCHECK(IsPersonalDataLoaded()); |
429 | 431 |
430 std::string guid; | 432 std::string guid; |
431 if (!args->GetString(0, &guid)) { | 433 if (!args->GetString(0, &guid)) { |
432 NOTREACHED(); | 434 NOTREACHED(); |
433 return; | 435 return; |
(...skipping 16 matching lines...) Expand all Loading... |
450 credit_card_data.SetString( | 452 credit_card_data.SetString( |
451 "creditCardNumber", | 453 "creditCardNumber", |
452 credit_card->GetRawInfo(autofill::CREDIT_CARD_NUMBER)); | 454 credit_card->GetRawInfo(autofill::CREDIT_CARD_NUMBER)); |
453 credit_card_data.SetString( | 455 credit_card_data.SetString( |
454 "expirationMonth", | 456 "expirationMonth", |
455 credit_card->GetRawInfo(autofill::CREDIT_CARD_EXP_MONTH)); | 457 credit_card->GetRawInfo(autofill::CREDIT_CARD_EXP_MONTH)); |
456 credit_card_data.SetString( | 458 credit_card_data.SetString( |
457 "expirationYear", | 459 "expirationYear", |
458 credit_card->GetRawInfo(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR)); | 460 credit_card->GetRawInfo(autofill::CREDIT_CARD_EXP_4_DIGIT_YEAR)); |
459 | 461 |
460 web_ui()->CallJavascriptFunction("AutofillOptions.editCreditCard", | 462 web_ui()->CallJavascriptFunctionUnsafe("AutofillOptions.editCreditCard", |
461 credit_card_data); | 463 credit_card_data); |
462 } | 464 } |
463 | 465 |
464 void AutofillOptionsHandler::SetAddress(const base::ListValue* args) { | 466 void AutofillOptionsHandler::SetAddress(const base::ListValue* args) { |
465 if (!IsPersonalDataLoaded()) | 467 if (!IsPersonalDataLoaded()) |
466 return; | 468 return; |
467 | 469 |
468 int arg_counter = 0; | 470 int arg_counter = 0; |
469 std::string guid; | 471 std::string guid; |
470 if (!args->GetString(arg_counter++, &guid)) { | 472 if (!args->GetString(arg_counter++, &guid)) { |
471 NOTREACHED(); | 473 NOTREACHED(); |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
625 address->SetString(kLanguageCode, profile.language_code()); | 627 address->SetString(kLanguageCode, profile.language_code()); |
626 | 628 |
627 std::unique_ptr<base::ListValue> components(new base::ListValue); | 629 std::unique_ptr<base::ListValue> components(new base::ListValue); |
628 GetAddressComponents( | 630 GetAddressComponents( |
629 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), | 631 base::UTF16ToUTF8(profile.GetRawInfo(autofill::ADDRESS_HOME_COUNTRY)), |
630 profile.language_code(), components.get(), nullptr); | 632 profile.language_code(), components.get(), nullptr); |
631 address->Set(kComponents, components.release()); | 633 address->Set(kComponents, components.release()); |
632 } | 634 } |
633 | 635 |
634 } // namespace options | 636 } // namespace options |
OLD | NEW |