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

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

Issue 2360073002: [Extensions] Isolate ExtensionFunction results_ and error_ (Closed)
Patch Set: lazyboy's Created 4 years, 2 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 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 172
173 ExtensionFunction::ResponseAction AutofillPrivateSaveAddressFunction::Run() { 173 ExtensionFunction::ResponseAction AutofillPrivateSaveAddressFunction::Run() {
174 std::unique_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 SetError(kErrorDataUnavailable);
183 return RespondNow(NoArguments()); 183 return RespondNow(NoArguments());
184 } 184 }
185 185
186 api::autofill_private::AddressEntry* address = &parameters->address; 186 api::autofill_private::AddressEntry* address = &parameters->address;
187 187
188 std::string guid = address->guid ? *address->guid : ""; 188 std::string guid = address->guid ? *address->guid : "";
189 autofill::AutofillProfile profile(guid, kSettingsOrigin); 189 autofill::AutofillProfile profile(guid, kSettingsOrigin);
190 190
191 // Strings from JavaScript use UTF-8 encoding. This container is used as an 191 // Strings from JavaScript use UTF-8 encoding. This container is used as an
192 // intermediate container for functions which require UTF-16 strings. 192 // intermediate container for functions which require UTF-16 strings.
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 361
362 ExtensionFunction::ResponseAction AutofillPrivateSaveCreditCardFunction::Run() { 362 ExtensionFunction::ResponseAction AutofillPrivateSaveCreditCardFunction::Run() {
363 std::unique_ptr<api::autofill_private::SaveCreditCard::Params> parameters = 363 std::unique_ptr<api::autofill_private::SaveCreditCard::Params> parameters =
364 api::autofill_private::SaveCreditCard::Params::Create(*args_); 364 api::autofill_private::SaveCreditCard::Params::Create(*args_);
365 EXTENSION_FUNCTION_VALIDATE(parameters.get()); 365 EXTENSION_FUNCTION_VALIDATE(parameters.get());
366 366
367 autofill::PersonalDataManager* personal_data = 367 autofill::PersonalDataManager* personal_data =
368 autofill::PersonalDataManagerFactory::GetForProfile( 368 autofill::PersonalDataManagerFactory::GetForProfile(
369 chrome_details_.GetProfile()); 369 chrome_details_.GetProfile());
370 if (!personal_data || !personal_data->IsDataLoaded()) { 370 if (!personal_data || !personal_data->IsDataLoaded()) {
371 error_ = kErrorDataUnavailable; 371 SetError(kErrorDataUnavailable);
372 return RespondNow(NoArguments()); 372 return RespondNow(NoArguments());
373 } 373 }
374 374
375 api::autofill_private::CreditCardEntry* card = &parameters->card; 375 api::autofill_private::CreditCardEntry* card = &parameters->card;
376 376
377 std::string guid = card->guid ? *card->guid : ""; 377 std::string guid = card->guid ? *card->guid : "";
378 autofill::CreditCard credit_card(guid, kSettingsOrigin); 378 autofill::CreditCard credit_card(guid, kSettingsOrigin);
379 379
380 if (card->name) { 380 if (card->name) {
381 credit_card.SetRawInfo(autofill::CREDIT_CARD_NAME_FULL, 381 credit_card.SetRawInfo(autofill::CREDIT_CARD_NAME_FULL,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 420
421 ExtensionFunction::ResponseAction AutofillPrivateRemoveEntryFunction::Run() { 421 ExtensionFunction::ResponseAction AutofillPrivateRemoveEntryFunction::Run() {
422 std::unique_ptr<api::autofill_private::RemoveEntry::Params> parameters = 422 std::unique_ptr<api::autofill_private::RemoveEntry::Params> parameters =
423 api::autofill_private::RemoveEntry::Params::Create(*args_); 423 api::autofill_private::RemoveEntry::Params::Create(*args_);
424 EXTENSION_FUNCTION_VALIDATE(parameters.get()); 424 EXTENSION_FUNCTION_VALIDATE(parameters.get());
425 425
426 autofill::PersonalDataManager* personal_data = 426 autofill::PersonalDataManager* personal_data =
427 autofill::PersonalDataManagerFactory::GetForProfile( 427 autofill::PersonalDataManagerFactory::GetForProfile(
428 chrome_details_.GetProfile()); 428 chrome_details_.GetProfile());
429 if (!personal_data || !personal_data->IsDataLoaded()) { 429 if (!personal_data || !personal_data->IsDataLoaded()) {
430 error_ = kErrorDataUnavailable; 430 SetError(kErrorDataUnavailable);
431 return RespondNow(NoArguments()); 431 return RespondNow(NoArguments());
432 } 432 }
433 433
434 personal_data->RemoveByGUID(parameters->guid); 434 personal_data->RemoveByGUID(parameters->guid);
435 435
436 return RespondNow(NoArguments()); 436 return RespondNow(NoArguments());
437 } 437 }
438 438
439 //////////////////////////////////////////////////////////////////////////////// 439 ////////////////////////////////////////////////////////////////////////////////
440 // AutofillPrivateValidatePhoneNumbersFunction 440 // AutofillPrivateValidatePhoneNumbersFunction
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 472
473 ExtensionFunction::ResponseAction AutofillPrivateMaskCreditCardFunction::Run() { 473 ExtensionFunction::ResponseAction AutofillPrivateMaskCreditCardFunction::Run() {
474 std::unique_ptr<api::autofill_private::MaskCreditCard::Params> parameters = 474 std::unique_ptr<api::autofill_private::MaskCreditCard::Params> parameters =
475 api::autofill_private::MaskCreditCard::Params::Create(*args_); 475 api::autofill_private::MaskCreditCard::Params::Create(*args_);
476 EXTENSION_FUNCTION_VALIDATE(parameters.get()); 476 EXTENSION_FUNCTION_VALIDATE(parameters.get());
477 477
478 autofill::PersonalDataManager* personal_data = 478 autofill::PersonalDataManager* personal_data =
479 autofill::PersonalDataManagerFactory::GetForProfile( 479 autofill::PersonalDataManagerFactory::GetForProfile(
480 chrome_details_.GetProfile()); 480 chrome_details_.GetProfile());
481 if (!personal_data || !personal_data->IsDataLoaded()) { 481 if (!personal_data || !personal_data->IsDataLoaded()) {
482 error_ = kErrorDataUnavailable; 482 SetError(kErrorDataUnavailable);
483 return RespondNow(NoArguments()); 483 return RespondNow(NoArguments());
484 } 484 }
485 485
486 personal_data->ResetFullServerCard(parameters->guid); 486 personal_data->ResetFullServerCard(parameters->guid);
487 487
488 return RespondNow(NoArguments()); 488 return RespondNow(NoArguments());
489 } 489 }
490 490
491 //////////////////////////////////////////////////////////////////////////////// 491 ////////////////////////////////////////////////////////////////////////////////
492 // AutofillPrivateGetCreditCardListFunction 492 // AutofillPrivateGetCreditCardListFunction
(...skipping 15 matching lines...) Expand all
508 508
509 autofill_util::CreditCardEntryList credit_card_list = 509 autofill_util::CreditCardEntryList credit_card_list =
510 autofill_util::GenerateCreditCardList(*personal_data); 510 autofill_util::GenerateCreditCardList(*personal_data);
511 511
512 return RespondNow( 512 return RespondNow(
513 ArgumentList(api::autofill_private::GetCreditCardList::Results::Create( 513 ArgumentList(api::autofill_private::GetCreditCardList::Results::Create(
514 credit_card_list))); 514 credit_card_list)));
515 } 515 }
516 516
517 } // namespace extensions 517 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698