Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 class AutofillClient; | 57 class AutofillClient; |
| 58 class AutofillManagerTestDelegate; | 58 class AutofillManagerTestDelegate; |
| 59 class AutofillProfile; | 59 class AutofillProfile; |
| 60 class AutofillType; | 60 class AutofillType; |
| 61 class CreditCard; | 61 class CreditCard; |
| 62 class FormStructureBrowserTest; | 62 class FormStructureBrowserTest; |
| 63 | 63 |
| 64 struct FormData; | 64 struct FormData; |
| 65 struct FormFieldData; | 65 struct FormFieldData; |
| 66 | 66 |
| 67 // The signature for the callback to be invoked when a card is unmasked. | |
| 68 using UnmaskCallback = base::Callback<void( | |
| 69 bool, // success | |
| 70 const CreditCard&, // original card | |
| 71 const CreditCard&, // unmasked card | |
| 72 const base::string16&)>; // the cvc for the card | |
| 73 | |
| 67 // Manages saving and restoring the user's personal information entered into web | 74 // Manages saving and restoring the user's personal information entered into web |
| 68 // forms. One per frame; owned by the AutofillDriver. | 75 // forms. One per frame; owned by the AutofillDriver. |
| 69 class AutofillManager : public AutofillDownloadManager::Observer, | 76 class AutofillManager : public AutofillDownloadManager::Observer, |
| 70 public CardUnmaskDelegate, | 77 public CardUnmaskDelegate, |
| 71 public payments::PaymentsClientDelegate { | 78 public payments::PaymentsClientDelegate { |
| 72 public: | 79 public: |
| 73 enum AutofillDownloadManagerState { | 80 enum AutofillDownloadManagerState { |
| 74 ENABLE_AUTOFILL_DOWNLOAD_MANAGER, | 81 ENABLE_AUTOFILL_DOWNLOAD_MANAGER, |
| 75 DISABLE_AUTOFILL_DOWNLOAD_MANAGER, | 82 DISABLE_AUTOFILL_DOWNLOAD_MANAGER, |
| 76 }; | 83 }; |
| 77 | 84 |
| 78 // Registers our Enable/Disable Autofill pref. | 85 // Registers our Enable/Disable Autofill pref. |
| 79 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 86 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
| 80 | 87 |
| 81 AutofillManager(AutofillDriver* driver, | 88 AutofillManager(AutofillDriver* driver, |
| 82 AutofillClient* client, | 89 AutofillClient* client, |
| 83 const std::string& app_locale, | 90 const std::string& app_locale, |
| 84 AutofillDownloadManagerState enable_download_manager); | 91 AutofillDownloadManagerState enable_download_manager); |
| 85 ~AutofillManager() override; | 92 ~AutofillManager() override; |
| 86 | 93 |
| 87 // Sets an external delegate. | 94 // Sets an external delegate. |
| 88 void SetExternalDelegate(AutofillExternalDelegate* delegate); | 95 void SetExternalDelegate(AutofillExternalDelegate* delegate); |
| 89 | 96 |
| 90 void ShowAutofillSettings(); | 97 void ShowAutofillSettings(); |
| 91 | 98 |
| 99 // Prompts the user for the CVC, uses the CVC to unmask the | |
| 100 // |maybe_masked_card| (if it's masked), and invokes |callback| with the | |
| 101 // unmasked card and the CVC. Only one unmask request should be active at a | |
| 102 // time. If there's already a pending unmask request, this |callback| is | |
| 103 // invoked immediately to indicate failure to the caller. | |
| 104 void UnmaskCardForPayment(const CreditCard& maybe_masked_card, | |
| 105 const UnmaskCallback& callback); | |
| 106 | |
| 92 // Whether the |field| should show an entry to scan a credit card. | 107 // Whether the |field| should show an entry to scan a credit card. |
| 93 virtual bool ShouldShowScanCreditCard(const FormData& form, | 108 virtual bool ShouldShowScanCreditCard(const FormData& form, |
| 94 const FormFieldData& field); | 109 const FormFieldData& field); |
| 95 | 110 |
| 96 // Called from our external delegate so they cannot be private. | 111 // Called from our external delegate so they cannot be private. |
| 97 virtual void FillOrPreviewForm(AutofillDriver::RendererFormDataAction action, | 112 virtual void FillOrPreviewForm(AutofillDriver::RendererFormDataAction action, |
| 98 int query_id, | 113 int query_id, |
| 99 const FormData& form, | 114 const FormData& form, |
| 100 const FormFieldData& field, | 115 const FormFieldData& field, |
| 101 int unique_id); | 116 int unique_id); |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 274 // payments::PaymentsClientDelegate: | 289 // payments::PaymentsClientDelegate: |
| 275 IdentityProvider* GetIdentityProvider() override; | 290 IdentityProvider* GetIdentityProvider() override; |
| 276 void OnDidGetRealPan(AutofillClient::PaymentsRpcResult result, | 291 void OnDidGetRealPan(AutofillClient::PaymentsRpcResult result, |
| 277 const std::string& real_pan) override; | 292 const std::string& real_pan) override; |
| 278 void OnDidGetUploadDetails( | 293 void OnDidGetUploadDetails( |
| 279 AutofillClient::PaymentsRpcResult result, | 294 AutofillClient::PaymentsRpcResult result, |
| 280 const base::string16& context_token, | 295 const base::string16& context_token, |
| 281 std::unique_ptr<base::DictionaryValue> legal_message) override; | 296 std::unique_ptr<base::DictionaryValue> legal_message) override; |
| 282 void OnDidUploadCard(AutofillClient::PaymentsRpcResult result) override; | 297 void OnDidUploadCard(AutofillClient::PaymentsRpcResult result) override; |
| 283 | 298 |
| 299 // UnmaskCallback: | |
|
Mathieu
2016/04/19 13:24:25
Mention here or elsewhere why you are not using th
| |
| 300 void OnCardUnmasked(bool success, | |
| 301 const CreditCard& original_card, | |
| 302 const CreditCard& unmasked_card, | |
| 303 const base::string16& unused_cvc); | |
| 304 | |
| 284 // Saves risk data in |unmasking_risk_data_| and calls UnmaskCard if the user | 305 // Saves risk data in |unmasking_risk_data_| and calls UnmaskCard if the user |
| 285 // has accepted the prompt. | 306 // has accepted the prompt. |
| 286 void OnDidGetUnmaskRiskData(const std::string& risk_data); | 307 void OnDidGetUnmaskRiskData(const std::string& risk_data); |
| 287 | 308 |
| 288 // Sets |user_did_accept_upload_prompt_| and calls UploadCard if the risk data | 309 // Sets |user_did_accept_upload_prompt_| and calls UploadCard if the risk data |
| 289 // is available. | 310 // is available. |
| 290 void OnUserDidAcceptUpload(); | 311 void OnUserDidAcceptUpload(); |
| 291 | 312 |
| 292 // Saves risk data in |uploading_risk_data_| and calls UploadCard if the user | 313 // Saves risk data in |uploading_risk_data_| and calls UploadCard if the user |
| 293 // has accepted the prompt. | 314 // has accepted the prompt. |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 490 base::TimeTicks initial_interaction_timestamp_; | 511 base::TimeTicks initial_interaction_timestamp_; |
| 491 | 512 |
| 492 // Our copy of the form data. | 513 // Our copy of the form data. |
| 493 ScopedVector<FormStructure> form_structures_; | 514 ScopedVector<FormStructure> form_structures_; |
| 494 | 515 |
| 495 // A copy of the currently interacted form data. | 516 // A copy of the currently interacted form data. |
| 496 std::unique_ptr<FormData> pending_form_data_; | 517 std::unique_ptr<FormData> pending_form_data_; |
| 497 | 518 |
| 498 // Collected information about a pending unmask request, and data about the | 519 // Collected information about a pending unmask request, and data about the |
| 499 // form. | 520 // form. |
| 521 std::unique_ptr<UnmaskCallback> unmask_callback_; | |
| 500 payments::PaymentsClient::UnmaskRequestDetails unmask_request_; | 522 payments::PaymentsClient::UnmaskRequestDetails unmask_request_; |
| 501 int unmasking_query_id_; | 523 int unmasking_query_id_; |
| 502 FormData unmasking_form_; | 524 FormData unmasking_form_; |
| 503 FormFieldData unmasking_field_; | 525 FormFieldData unmasking_field_; |
| 504 // Time when we requested the last real pan. | 526 // Time when we requested the last real pan. |
| 505 base::Time real_pan_request_timestamp_; | 527 base::Time real_pan_request_timestamp_; |
| 506 | 528 |
| 507 // Collected information about a pending upload request. | 529 // Collected information about a pending upload request. |
| 508 payments::PaymentsClient::UploadRequestDetails upload_request_; | 530 payments::PaymentsClient::UploadRequestDetails upload_request_; |
| 509 bool user_did_accept_upload_prompt_; | 531 bool user_did_accept_upload_prompt_; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 587 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, | 609 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, |
| 588 DontSaveCvcInAutocompleteHistory); | 610 DontSaveCvcInAutocompleteHistory); |
| 589 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, DontOfferToSavePaymentsCard); | 611 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, DontOfferToSavePaymentsCard); |
| 590 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillInUpdatedExpirationDate); | 612 FRIEND_TEST_ALL_PREFIXES(AutofillManagerTest, FillInUpdatedExpirationDate); |
| 591 DISALLOW_COPY_AND_ASSIGN(AutofillManager); | 613 DISALLOW_COPY_AND_ASSIGN(AutofillManager); |
| 592 }; | 614 }; |
| 593 | 615 |
| 594 } // namespace autofill | 616 } // namespace autofill |
| 595 | 617 |
| 596 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ | 618 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_MANAGER_H_ |
| OLD | NEW |