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

Side by Side Diff: chrome/browser/extensions/api/autofill_private/autofill_private_api.cc

Issue 2028903002: Update Autofill Private API to provide a list of available countries. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 4 years, 6 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
OLDNEW
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
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 autofill_util::GenerateCountryList(*personal_data);
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
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 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
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 = &parameters->params; 453 api::autofill_private::ValidatePhoneParams* params = &parameters->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
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 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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698