Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/extensions/api/autofill_private/autofill_private_api.h" | 5 #include "chrome/browser/extensions/api/autofill_private/autofill_private_api.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/guid.h" | 10 #include "base/guid.h" |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 272 profile.set_guid(base::GenerateGUID()); | 272 profile.set_guid(base::GenerateGUID()); |
| 273 personal_data->AddProfile(profile); | 273 personal_data->AddProfile(profile); |
| 274 } else { | 274 } else { |
| 275 personal_data->UpdateProfile(profile); | 275 personal_data->UpdateProfile(profile); |
| 276 } | 276 } |
| 277 | 277 |
| 278 return RespondNow(NoArguments()); | 278 return RespondNow(NoArguments()); |
| 279 } | 279 } |
| 280 | 280 |
| 281 //////////////////////////////////////////////////////////////////////////////// | 281 //////////////////////////////////////////////////////////////////////////////// |
| 282 // AutofillPrivateGetCountryListFunction | |
| 283 | |
| 284 AutofillPrivateGetCountryListFunction::AutofillPrivateGetCountryListFunction() | |
| 285 : chrome_details_(this) {} | |
| 286 | |
| 287 AutofillPrivateGetCountryListFunction:: | |
| 288 ~AutofillPrivateGetCountryListFunction() {} | |
| 289 | |
| 290 ExtensionFunction::ResponseAction AutofillPrivateGetCountryListFunction::Run() { | |
| 291 autofill::PersonalDataManager* personal_data = | |
| 292 autofill::PersonalDataManagerFactory::GetForProfile( | |
| 293 chrome_details_.GetProfile()); | |
| 294 | |
| 295 // Return an empty list if data is not loaded. | |
| 296 if (!(personal_data && personal_data->IsDataLoaded())) { | |
| 297 autofill_util::CountryEntryList empty_list; | |
| 298 return RespondNow(ArgumentList( | |
| 299 api::autofill_private::GetCountryList::Results::Create(empty_list))); | |
| 300 } | |
| 301 | |
| 302 autofill_util::CountryEntryList country_list = | |
| 303 extensions::autofill_util::GenerateCountryList(*personal_data); | |
|
Devlin
2016/06/10 18:25:11
nitty nit: no extensions::
hcarmona
2016/06/10 20:42:51
Done.
| |
| 304 | |
| 305 return RespondNow(ArgumentList( | |
| 306 api::autofill_private::GetCountryList::Results::Create(country_list))); | |
| 307 } | |
| 308 | |
| 309 //////////////////////////////////////////////////////////////////////////////// | |
| 282 // AutofillPrivateGetAddressComponentsFunction | 310 // AutofillPrivateGetAddressComponentsFunction |
| 283 | 311 |
| 284 AutofillPrivateGetAddressComponentsFunction:: | 312 AutofillPrivateGetAddressComponentsFunction:: |
| 285 ~AutofillPrivateGetAddressComponentsFunction() {} | 313 ~AutofillPrivateGetAddressComponentsFunction() {} |
| 286 | 314 |
| 287 ExtensionFunction::ResponseAction | 315 ExtensionFunction::ResponseAction |
| 288 AutofillPrivateGetAddressComponentsFunction::Run() { | 316 AutofillPrivateGetAddressComponentsFunction::Run() { |
| 289 std::unique_ptr<api::autofill_private::GetAddressComponents::Params> | 317 std::unique_ptr<api::autofill_private::GetAddressComponents::Params> |
| 290 parameters = | 318 parameters = |
| 291 api::autofill_private::GetAddressComponents::Params::Create(*args_); | 319 api::autofill_private::GetAddressComponents::Params::Create(*args_); |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 309 AutofillPrivateGetAddressListFunction:: | 337 AutofillPrivateGetAddressListFunction:: |
| 310 ~AutofillPrivateGetAddressListFunction() {} | 338 ~AutofillPrivateGetAddressListFunction() {} |
| 311 | 339 |
| 312 ExtensionFunction::ResponseAction AutofillPrivateGetAddressListFunction::Run() { | 340 ExtensionFunction::ResponseAction AutofillPrivateGetAddressListFunction::Run() { |
| 313 autofill::PersonalDataManager* personal_data = | 341 autofill::PersonalDataManager* personal_data = |
| 314 autofill::PersonalDataManagerFactory::GetForProfile( | 342 autofill::PersonalDataManagerFactory::GetForProfile( |
| 315 chrome_details_.GetProfile()); | 343 chrome_details_.GetProfile()); |
| 316 | 344 |
| 317 DCHECK(personal_data && personal_data->IsDataLoaded()); | 345 DCHECK(personal_data && personal_data->IsDataLoaded()); |
| 318 | 346 |
| 319 autofill_util::AddressEntryList addressList = | 347 autofill_util::AddressEntryList address_list = |
| 320 extensions::autofill_util::GenerateAddressList(*personal_data); | 348 extensions::autofill_util::GenerateAddressList(*personal_data); |
| 321 | 349 |
| 322 return RespondNow(ArgumentList( | 350 return RespondNow(ArgumentList( |
| 323 api::autofill_private::GetAddressList::Results::Create(addressList))); | 351 api::autofill_private::GetAddressList::Results::Create(address_list))); |
| 324 } | 352 } |
| 325 | 353 |
| 326 //////////////////////////////////////////////////////////////////////////////// | 354 //////////////////////////////////////////////////////////////////////////////// |
| 327 // AutofillPrivateSaveCreditCardFunction | 355 // AutofillPrivateSaveCreditCardFunction |
| 328 | 356 |
| 329 AutofillPrivateSaveCreditCardFunction::AutofillPrivateSaveCreditCardFunction() | 357 AutofillPrivateSaveCreditCardFunction::AutofillPrivateSaveCreditCardFunction() |
| 330 : chrome_details_(this) {} | 358 : chrome_details_(this) {} |
| 331 | 359 |
| 332 AutofillPrivateSaveCreditCardFunction:: | 360 AutofillPrivateSaveCreditCardFunction:: |
| 333 ~AutofillPrivateSaveCreditCardFunction() {} | 361 ~AutofillPrivateSaveCreditCardFunction() {} |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 418 ExtensionFunction::ResponseAction | 446 ExtensionFunction::ResponseAction |
| 419 AutofillPrivateValidatePhoneNumbersFunction::Run() { | 447 AutofillPrivateValidatePhoneNumbersFunction::Run() { |
| 420 std::unique_ptr<api::autofill_private::ValidatePhoneNumbers::Params> | 448 std::unique_ptr<api::autofill_private::ValidatePhoneNumbers::Params> |
| 421 parameters = | 449 parameters = |
| 422 api::autofill_private::ValidatePhoneNumbers::Params::Create(*args_); | 450 api::autofill_private::ValidatePhoneNumbers::Params::Create(*args_); |
| 423 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 451 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
| 424 | 452 |
| 425 api::autofill_private::ValidatePhoneParams* params = ¶meters->params; | 453 api::autofill_private::ValidatePhoneParams* params = ¶meters->params; |
| 426 | 454 |
| 427 // Extract the phone numbers into a ListValue. | 455 // Extract the phone numbers into a ListValue. |
| 428 std::unique_ptr<base::ListValue> phoneNumbers(new base::ListValue); | 456 std::unique_ptr<base::ListValue> phone_numbers(new base::ListValue); |
| 429 phoneNumbers->AppendStrings(params->phone_numbers); | 457 phone_numbers->AppendStrings(params->phone_numbers); |
| 430 | 458 |
| 431 RemoveDuplicatePhoneNumberAtIndex( | 459 RemoveDuplicatePhoneNumberAtIndex(params->index_of_new_number, |
| 432 params->index_of_new_number, params->country_code, phoneNumbers.get()); | 460 params->country_code, phone_numbers.get()); |
| 433 | 461 |
| 434 return RespondNow(OneArgument(std::move(phoneNumbers))); | 462 return RespondNow(OneArgument(std::move(phone_numbers))); |
| 435 } | 463 } |
| 436 | 464 |
| 437 //////////////////////////////////////////////////////////////////////////////// | 465 //////////////////////////////////////////////////////////////////////////////// |
| 438 // AutofillPrivateMaskCreditCardFunction | 466 // AutofillPrivateMaskCreditCardFunction |
| 439 | 467 |
| 440 AutofillPrivateMaskCreditCardFunction::AutofillPrivateMaskCreditCardFunction() | 468 AutofillPrivateMaskCreditCardFunction::AutofillPrivateMaskCreditCardFunction() |
| 441 : chrome_details_(this) {} | 469 : chrome_details_(this) {} |
| 442 | 470 |
| 443 AutofillPrivateMaskCreditCardFunction:: | 471 AutofillPrivateMaskCreditCardFunction:: |
| 444 ~AutofillPrivateMaskCreditCardFunction() {} | 472 ~AutofillPrivateMaskCreditCardFunction() {} |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 472 ~AutofillPrivateGetCreditCardListFunction() {} | 500 ~AutofillPrivateGetCreditCardListFunction() {} |
| 473 | 501 |
| 474 ExtensionFunction::ResponseAction | 502 ExtensionFunction::ResponseAction |
| 475 AutofillPrivateGetCreditCardListFunction::Run() { | 503 AutofillPrivateGetCreditCardListFunction::Run() { |
| 476 autofill::PersonalDataManager* personal_data = | 504 autofill::PersonalDataManager* personal_data = |
| 477 autofill::PersonalDataManagerFactory::GetForProfile( | 505 autofill::PersonalDataManagerFactory::GetForProfile( |
| 478 chrome_details_.GetProfile()); | 506 chrome_details_.GetProfile()); |
| 479 | 507 |
| 480 DCHECK(personal_data && personal_data->IsDataLoaded()); | 508 DCHECK(personal_data && personal_data->IsDataLoaded()); |
| 481 | 509 |
| 482 autofill_util::CreditCardEntryList creditCardList = | 510 autofill_util::CreditCardEntryList credit_card_list = |
| 483 extensions::autofill_util::GenerateCreditCardList(*personal_data); | 511 extensions::autofill_util::GenerateCreditCardList(*personal_data); |
| 484 | 512 |
| 485 return RespondNow( | 513 return RespondNow( |
| 486 ArgumentList(api::autofill_private::GetCreditCardList::Results::Create( | 514 ArgumentList(api::autofill_private::GetCreditCardList::Results::Create( |
| 487 creditCardList))); | 515 credit_card_list))); |
| 488 } | 516 } |
| 489 | 517 |
| 490 } // namespace extensions | 518 } // namespace extensions |
| OLD | NEW |