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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
164 | 164 |
165 //////////////////////////////////////////////////////////////////////////////// | 165 //////////////////////////////////////////////////////////////////////////////// |
166 // AutofillPrivateSaveAddressFunction | 166 // AutofillPrivateSaveAddressFunction |
167 | 167 |
168 AutofillPrivateSaveAddressFunction::AutofillPrivateSaveAddressFunction() | 168 AutofillPrivateSaveAddressFunction::AutofillPrivateSaveAddressFunction() |
169 : chrome_details_(this) {} | 169 : chrome_details_(this) {} |
170 | 170 |
171 AutofillPrivateSaveAddressFunction::~AutofillPrivateSaveAddressFunction() {} | 171 AutofillPrivateSaveAddressFunction::~AutofillPrivateSaveAddressFunction() {} |
172 | 172 |
173 ExtensionFunction::ResponseAction AutofillPrivateSaveAddressFunction::Run() { | 173 ExtensionFunction::ResponseAction AutofillPrivateSaveAddressFunction::Run() { |
174 scoped_ptr<api::autofill_private::SaveAddress::Params> parameters = | 174 std::unique_ptr<api::autofill_private::SaveAddress::Params> parameters = |
175 api::autofill_private::SaveAddress::Params::Create(*args_); | 175 api::autofill_private::SaveAddress::Params::Create(*args_); |
176 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 176 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
177 | 177 |
178 autofill::PersonalDataManager* personal_data = | 178 autofill::PersonalDataManager* personal_data = |
179 autofill::PersonalDataManagerFactory::GetForProfile( | 179 autofill::PersonalDataManagerFactory::GetForProfile( |
180 chrome_details_.GetProfile()); | 180 chrome_details_.GetProfile()); |
181 if (!personal_data || !personal_data->IsDataLoaded()) { | 181 if (!personal_data || !personal_data->IsDataLoaded()) { |
182 error_ = kErrorDataUnavailable; | 182 error_ = kErrorDataUnavailable; |
183 return RespondNow(NoArguments()); | 183 return RespondNow(NoArguments()); |
184 } | 184 } |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 } | 278 } |
279 | 279 |
280 //////////////////////////////////////////////////////////////////////////////// | 280 //////////////////////////////////////////////////////////////////////////////// |
281 // AutofillPrivateGetAddressComponentsFunction | 281 // AutofillPrivateGetAddressComponentsFunction |
282 | 282 |
283 AutofillPrivateGetAddressComponentsFunction:: | 283 AutofillPrivateGetAddressComponentsFunction:: |
284 ~AutofillPrivateGetAddressComponentsFunction() {} | 284 ~AutofillPrivateGetAddressComponentsFunction() {} |
285 | 285 |
286 ExtensionFunction::ResponseAction | 286 ExtensionFunction::ResponseAction |
287 AutofillPrivateGetAddressComponentsFunction::Run() { | 287 AutofillPrivateGetAddressComponentsFunction::Run() { |
288 scoped_ptr<api::autofill_private::GetAddressComponents::Params> parameters = | 288 std::unique_ptr<api::autofill_private::GetAddressComponents::Params> |
289 api::autofill_private::GetAddressComponents::Params::Create(*args_); | 289 parameters = |
| 290 api::autofill_private::GetAddressComponents::Params::Create(*args_); |
290 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 291 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
291 | 292 |
292 autofill_private::AddressComponents components; | 293 autofill_private::AddressComponents components; |
293 PopulateAddressComponents( | 294 PopulateAddressComponents( |
294 parameters->country_code, | 295 parameters->country_code, |
295 g_browser_process->GetApplicationLocale(), | 296 g_browser_process->GetApplicationLocale(), |
296 &components); | 297 &components); |
297 | 298 |
298 return RespondNow(OneArgument(components.ToValue().release())); | 299 return RespondNow(OneArgument(components.ToValue().release())); |
299 } | 300 } |
300 | 301 |
301 //////////////////////////////////////////////////////////////////////////////// | 302 //////////////////////////////////////////////////////////////////////////////// |
302 // AutofillPrivateSaveCreditCardFunction | 303 // AutofillPrivateSaveCreditCardFunction |
303 | 304 |
304 AutofillPrivateSaveCreditCardFunction::AutofillPrivateSaveCreditCardFunction() | 305 AutofillPrivateSaveCreditCardFunction::AutofillPrivateSaveCreditCardFunction() |
305 : chrome_details_(this) {} | 306 : chrome_details_(this) {} |
306 | 307 |
307 AutofillPrivateSaveCreditCardFunction:: | 308 AutofillPrivateSaveCreditCardFunction:: |
308 ~AutofillPrivateSaveCreditCardFunction() {} | 309 ~AutofillPrivateSaveCreditCardFunction() {} |
309 | 310 |
310 ExtensionFunction::ResponseAction AutofillPrivateSaveCreditCardFunction::Run() { | 311 ExtensionFunction::ResponseAction AutofillPrivateSaveCreditCardFunction::Run() { |
311 scoped_ptr<api::autofill_private::SaveCreditCard::Params> parameters = | 312 std::unique_ptr<api::autofill_private::SaveCreditCard::Params> parameters = |
312 api::autofill_private::SaveCreditCard::Params::Create(*args_); | 313 api::autofill_private::SaveCreditCard::Params::Create(*args_); |
313 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 314 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
314 | 315 |
315 autofill::PersonalDataManager* personal_data = | 316 autofill::PersonalDataManager* personal_data = |
316 autofill::PersonalDataManagerFactory::GetForProfile( | 317 autofill::PersonalDataManagerFactory::GetForProfile( |
317 chrome_details_.GetProfile()); | 318 chrome_details_.GetProfile()); |
318 if (!personal_data || !personal_data->IsDataLoaded()) { | 319 if (!personal_data || !personal_data->IsDataLoaded()) { |
319 error_ = kErrorDataUnavailable; | 320 error_ = kErrorDataUnavailable; |
320 return RespondNow(NoArguments()); | 321 return RespondNow(NoArguments()); |
321 } | 322 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 | 361 |
361 //////////////////////////////////////////////////////////////////////////////// | 362 //////////////////////////////////////////////////////////////////////////////// |
362 // AutofillPrivateRemoveEntryFunction | 363 // AutofillPrivateRemoveEntryFunction |
363 | 364 |
364 AutofillPrivateRemoveEntryFunction::AutofillPrivateRemoveEntryFunction() | 365 AutofillPrivateRemoveEntryFunction::AutofillPrivateRemoveEntryFunction() |
365 : chrome_details_(this) {} | 366 : chrome_details_(this) {} |
366 | 367 |
367 AutofillPrivateRemoveEntryFunction::~AutofillPrivateRemoveEntryFunction() {} | 368 AutofillPrivateRemoveEntryFunction::~AutofillPrivateRemoveEntryFunction() {} |
368 | 369 |
369 ExtensionFunction::ResponseAction AutofillPrivateRemoveEntryFunction::Run() { | 370 ExtensionFunction::ResponseAction AutofillPrivateRemoveEntryFunction::Run() { |
370 scoped_ptr<api::autofill_private::RemoveEntry::Params> parameters = | 371 std::unique_ptr<api::autofill_private::RemoveEntry::Params> parameters = |
371 api::autofill_private::RemoveEntry::Params::Create(*args_); | 372 api::autofill_private::RemoveEntry::Params::Create(*args_); |
372 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 373 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
373 | 374 |
374 autofill::PersonalDataManager* personal_data = | 375 autofill::PersonalDataManager* personal_data = |
375 autofill::PersonalDataManagerFactory::GetForProfile( | 376 autofill::PersonalDataManagerFactory::GetForProfile( |
376 chrome_details_.GetProfile()); | 377 chrome_details_.GetProfile()); |
377 if (!personal_data || !personal_data->IsDataLoaded()) { | 378 if (!personal_data || !personal_data->IsDataLoaded()) { |
378 error_ = kErrorDataUnavailable; | 379 error_ = kErrorDataUnavailable; |
379 return RespondNow(NoArguments()); | 380 return RespondNow(NoArguments()); |
380 } | 381 } |
381 | 382 |
382 personal_data->RemoveByGUID(parameters->guid); | 383 personal_data->RemoveByGUID(parameters->guid); |
383 | 384 |
384 return RespondNow(NoArguments()); | 385 return RespondNow(NoArguments()); |
385 } | 386 } |
386 | 387 |
387 //////////////////////////////////////////////////////////////////////////////// | 388 //////////////////////////////////////////////////////////////////////////////// |
388 // AutofillPrivateValidatePhoneNumbersFunction | 389 // AutofillPrivateValidatePhoneNumbersFunction |
389 | 390 |
390 AutofillPrivateValidatePhoneNumbersFunction:: | 391 AutofillPrivateValidatePhoneNumbersFunction:: |
391 ~AutofillPrivateValidatePhoneNumbersFunction() {} | 392 ~AutofillPrivateValidatePhoneNumbersFunction() {} |
392 | 393 |
393 ExtensionFunction::ResponseAction | 394 ExtensionFunction::ResponseAction |
394 AutofillPrivateValidatePhoneNumbersFunction::Run() { | 395 AutofillPrivateValidatePhoneNumbersFunction::Run() { |
395 scoped_ptr<api::autofill_private::ValidatePhoneNumbers::Params> parameters = | 396 std::unique_ptr<api::autofill_private::ValidatePhoneNumbers::Params> |
396 api::autofill_private::ValidatePhoneNumbers::Params::Create(*args_); | 397 parameters = |
| 398 api::autofill_private::ValidatePhoneNumbers::Params::Create(*args_); |
397 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 399 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
398 | 400 |
399 api::autofill_private::ValidatePhoneParams* params = ¶meters->params; | 401 api::autofill_private::ValidatePhoneParams* params = ¶meters->params; |
400 | 402 |
401 // Extract the phone numbers into a ListValue. | 403 // Extract the phone numbers into a ListValue. |
402 scoped_ptr<base::ListValue> phoneNumbers(new base::ListValue); | 404 std::unique_ptr<base::ListValue> phoneNumbers(new base::ListValue); |
403 phoneNumbers->AppendStrings(params->phone_numbers); | 405 phoneNumbers->AppendStrings(params->phone_numbers); |
404 | 406 |
405 RemoveDuplicatePhoneNumberAtIndex( | 407 RemoveDuplicatePhoneNumberAtIndex( |
406 params->index_of_new_number, params->country_code, phoneNumbers.get()); | 408 params->index_of_new_number, params->country_code, phoneNumbers.get()); |
407 | 409 |
408 return RespondNow(OneArgument(std::move(phoneNumbers))); | 410 return RespondNow(OneArgument(std::move(phoneNumbers))); |
409 } | 411 } |
410 | 412 |
411 //////////////////////////////////////////////////////////////////////////////// | 413 //////////////////////////////////////////////////////////////////////////////// |
412 // AutofillPrivateMaskCreditCardFunction | 414 // AutofillPrivateMaskCreditCardFunction |
413 | 415 |
414 AutofillPrivateMaskCreditCardFunction::AutofillPrivateMaskCreditCardFunction() | 416 AutofillPrivateMaskCreditCardFunction::AutofillPrivateMaskCreditCardFunction() |
415 : chrome_details_(this) {} | 417 : chrome_details_(this) {} |
416 | 418 |
417 AutofillPrivateMaskCreditCardFunction:: | 419 AutofillPrivateMaskCreditCardFunction:: |
418 ~AutofillPrivateMaskCreditCardFunction() {} | 420 ~AutofillPrivateMaskCreditCardFunction() {} |
419 | 421 |
420 ExtensionFunction::ResponseAction AutofillPrivateMaskCreditCardFunction::Run() { | 422 ExtensionFunction::ResponseAction AutofillPrivateMaskCreditCardFunction::Run() { |
421 scoped_ptr<api::autofill_private::MaskCreditCard::Params> parameters = | 423 std::unique_ptr<api::autofill_private::MaskCreditCard::Params> parameters = |
422 api::autofill_private::MaskCreditCard::Params::Create(*args_); | 424 api::autofill_private::MaskCreditCard::Params::Create(*args_); |
423 EXTENSION_FUNCTION_VALIDATE(parameters.get()); | 425 EXTENSION_FUNCTION_VALIDATE(parameters.get()); |
424 | 426 |
425 autofill::PersonalDataManager* personal_data = | 427 autofill::PersonalDataManager* personal_data = |
426 autofill::PersonalDataManagerFactory::GetForProfile( | 428 autofill::PersonalDataManagerFactory::GetForProfile( |
427 chrome_details_.GetProfile()); | 429 chrome_details_.GetProfile()); |
428 if (!personal_data || !personal_data->IsDataLoaded()) { | 430 if (!personal_data || !personal_data->IsDataLoaded()) { |
429 error_ = kErrorDataUnavailable; | 431 error_ = kErrorDataUnavailable; |
430 return RespondNow(NoArguments()); | 432 return RespondNow(NoArguments()); |
431 } | 433 } |
432 | 434 |
433 personal_data->ResetFullServerCard(parameters->guid); | 435 personal_data->ResetFullServerCard(parameters->guid); |
434 | 436 |
435 return RespondNow(NoArguments()); | 437 return RespondNow(NoArguments()); |
436 } | 438 } |
437 | 439 |
438 } // namespace extensions | 440 } // namespace extensions |
OLD | NEW |