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" |
11 #include "base/strings/utf_string_conversions.h" | 11 #include "base/strings/utf_string_conversions.h" |
12 #include "base/values.h" | 12 #include "base/values.h" |
13 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 13 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
| 15 #include "chrome/browser/extensions/api/autofill_private/autofill_util.h" |
15 #include "chrome/common/extensions/api/autofill_private.h" | 16 #include "chrome/common/extensions/api/autofill_private.h" |
16 #include "chrome/grit/generated_resources.h" | 17 #include "chrome/grit/generated_resources.h" |
17 #include "components/autofill/core/browser/autofill_profile.h" | 18 #include "components/autofill/core/browser/autofill_profile.h" |
18 #include "components/autofill/core/browser/personal_data_manager.h" | 19 #include "components/autofill/core/browser/personal_data_manager.h" |
19 #include "extensions/browser/extension_function.h" | 20 #include "extensions/browser/extension_function.h" |
20 #include "extensions/browser/extension_function_registry.h" | 21 #include "extensions/browser/extension_function_registry.h" |
21 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" | 22 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
.h" |
22 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
_component.h" | 23 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/address_ui
_component.h" |
23 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati
on.h" | 24 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/localizati
on.h" |
24 #include "ui/base/l10n/l10n_util.h" | 25 #include "ui/base/l10n/l10n_util.h" |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 autofill_private::AddressComponents components; | 294 autofill_private::AddressComponents components; |
294 PopulateAddressComponents( | 295 PopulateAddressComponents( |
295 parameters->country_code, | 296 parameters->country_code, |
296 g_browser_process->GetApplicationLocale(), | 297 g_browser_process->GetApplicationLocale(), |
297 &components); | 298 &components); |
298 | 299 |
299 return RespondNow(OneArgument(components.ToValue().release())); | 300 return RespondNow(OneArgument(components.ToValue().release())); |
300 } | 301 } |
301 | 302 |
302 //////////////////////////////////////////////////////////////////////////////// | 303 //////////////////////////////////////////////////////////////////////////////// |
| 304 // AutofillPrivateGetAddressListFunction |
| 305 |
| 306 AutofillPrivateGetAddressListFunction::AutofillPrivateGetAddressListFunction() |
| 307 : chrome_details_(this) {} |
| 308 |
| 309 AutofillPrivateGetAddressListFunction:: |
| 310 ~AutofillPrivateGetAddressListFunction() {} |
| 311 |
| 312 ExtensionFunction::ResponseAction AutofillPrivateGetAddressListFunction::Run() { |
| 313 autofill::PersonalDataManager* personal_data = |
| 314 autofill::PersonalDataManagerFactory::GetForProfile( |
| 315 chrome_details_.GetProfile()); |
| 316 |
| 317 DCHECK(personal_data && personal_data->IsDataLoaded()); |
| 318 |
| 319 autofill_util::AddressEntryList addressList = |
| 320 extensions::autofill_util::GenerateAddressList(*personal_data); |
| 321 |
| 322 return RespondNow(ArgumentList( |
| 323 api::autofill_private::GetAddressList::Results::Create(addressList))); |
| 324 } |
| 325 |
| 326 //////////////////////////////////////////////////////////////////////////////// |
303 // AutofillPrivateSaveCreditCardFunction | 327 // AutofillPrivateSaveCreditCardFunction |
304 | 328 |
305 AutofillPrivateSaveCreditCardFunction::AutofillPrivateSaveCreditCardFunction() | 329 AutofillPrivateSaveCreditCardFunction::AutofillPrivateSaveCreditCardFunction() |
306 : chrome_details_(this) {} | 330 : chrome_details_(this) {} |
307 | 331 |
308 AutofillPrivateSaveCreditCardFunction:: | 332 AutofillPrivateSaveCreditCardFunction:: |
309 ~AutofillPrivateSaveCreditCardFunction() {} | 333 ~AutofillPrivateSaveCreditCardFunction() {} |
310 | 334 |
311 ExtensionFunction::ResponseAction AutofillPrivateSaveCreditCardFunction::Run() { | 335 ExtensionFunction::ResponseAction AutofillPrivateSaveCreditCardFunction::Run() { |
312 std::unique_ptr<api::autofill_private::SaveCreditCard::Params> parameters = | 336 std::unique_ptr<api::autofill_private::SaveCreditCard::Params> parameters = |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
430 if (!personal_data || !personal_data->IsDataLoaded()) { | 454 if (!personal_data || !personal_data->IsDataLoaded()) { |
431 error_ = kErrorDataUnavailable; | 455 error_ = kErrorDataUnavailable; |
432 return RespondNow(NoArguments()); | 456 return RespondNow(NoArguments()); |
433 } | 457 } |
434 | 458 |
435 personal_data->ResetFullServerCard(parameters->guid); | 459 personal_data->ResetFullServerCard(parameters->guid); |
436 | 460 |
437 return RespondNow(NoArguments()); | 461 return RespondNow(NoArguments()); |
438 } | 462 } |
439 | 463 |
| 464 //////////////////////////////////////////////////////////////////////////////// |
| 465 // AutofillPrivateGetCreditCardListFunction |
| 466 |
| 467 AutofillPrivateGetCreditCardListFunction:: |
| 468 AutofillPrivateGetCreditCardListFunction() |
| 469 : chrome_details_(this) {} |
| 470 |
| 471 AutofillPrivateGetCreditCardListFunction:: |
| 472 ~AutofillPrivateGetCreditCardListFunction() {} |
| 473 |
| 474 ExtensionFunction::ResponseAction |
| 475 AutofillPrivateGetCreditCardListFunction::Run() { |
| 476 autofill::PersonalDataManager* personal_data = |
| 477 autofill::PersonalDataManagerFactory::GetForProfile( |
| 478 chrome_details_.GetProfile()); |
| 479 |
| 480 DCHECK(personal_data && personal_data->IsDataLoaded()); |
| 481 |
| 482 autofill_util::CreditCardEntryList creditCardList = |
| 483 extensions::autofill_util::GenerateCreditCardList(*personal_data); |
| 484 |
| 485 return RespondNow( |
| 486 ArgumentList(api::autofill_private::GetCreditCardList::Results::Create( |
| 487 creditCardList))); |
| 488 } |
| 489 |
440 } // namespace extensions | 490 } // namespace extensions |
OLD | NEW |