OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_ASSISTANT_H_ | 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_ASSISTANT_H_ |
6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_ASSISTANT_H_ | 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_ASSISTANT_H_ |
7 | 7 |
8 #include <memory> | 8 #include <memory> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/macros.h" | 11 #include "base/macros.h" |
12 #include "base/memory/weak_ptr.h" | 12 #include "base/memory/weak_ptr.h" |
| 13 #include "components/autofill/core/browser/payments/full_card_request.h" |
13 #include "components/autofill/core/common/form_data.h" | 14 #include "components/autofill/core/common/form_data.h" |
14 | 15 |
15 namespace autofill { | 16 namespace autofill { |
16 | 17 |
17 class AutofillManager; | 18 class AutofillManager; |
18 class CreditCard; | 19 class CreditCard; |
19 class FormStructure; | 20 class FormStructure; |
20 | 21 |
21 // This class encompasses the triggering rules and the logic for the autofill | 22 // This class encompasses the triggering rules and the logic for the autofill |
22 // assisted filling mechanisms. | 23 // assisted filling mechanisms. |
23 class AutofillAssistant { | 24 class AutofillAssistant : public payments::FullCardRequest::Delegate { |
24 public: | 25 public: |
25 explicit AutofillAssistant(AutofillManager* autofill_manager); | 26 explicit AutofillAssistant(AutofillManager* autofill_manager); |
26 ~AutofillAssistant(); | 27 ~AutofillAssistant(); |
27 | 28 |
28 // Should be called at every page navigation to clear state. | 29 // Should be called at every page navigation to clear state. |
29 void Reset(); | 30 void Reset(); |
30 | 31 |
31 // Returns whether a credit card assist can be shown. Will go through the | 32 // Returns whether a credit card assist can be shown. Will go through the |
32 // forms in |form_structures| and extract the credit card form. | 33 // forms in |form_structures| and extract the credit card form. |
33 bool CanShowCreditCardAssist( | 34 bool CanShowCreditCardAssist( |
34 const std::vector<FormStructure*>& form_structures); | 35 const std::vector<FormStructure*>& form_structures); |
35 | 36 |
36 // Will show an assist infobar for the previously extracted form proposing to | 37 // Will show an assist infobar for the previously extracted form proposing to |
37 // autofill it. Should only be called if CanShowCreditCardAssist() returned | 38 // autofill it. Should only be called if CanShowCreditCardAssist() returned |
38 // true. | 39 // true. |
39 void ShowAssistForCreditCard(const CreditCard& card); | 40 void ShowAssistForCreditCard(const CreditCard& card); |
40 | 41 |
41 private: | 42 private: |
42 // Called by the infobar delegate when the user accepts the infobar. | 43 // Called by the infobar delegate when the user accepts the infobar. |
43 void OnUserDidAcceptCreditCardFill(const CreditCard& card); | 44 void OnUserDidAcceptCreditCardFill(const CreditCard& card); |
44 | 45 |
| 46 // payments::FullCardRequest::Delegate: |
| 47 void OnFullCardRequestSucceeded(const CreditCard& card, |
| 48 const base::string16& cvc) override; |
| 49 void OnFullCardRequestFailed() override; |
| 50 |
45 // Holds the FormData to be filled with a credit card. | 51 // Holds the FormData to be filled with a credit card. |
46 std::unique_ptr<FormData> credit_card_form_data_; | 52 std::unique_ptr<FormData> credit_card_form_data_; |
47 | 53 |
48 // Weak reference to the AutofillManager that created and maintains this | 54 // Weak reference to the AutofillManager that created and maintains this |
49 // AutofillAssistant. | 55 // AutofillAssistant. |
50 AutofillManager* autofill_manager_; | 56 AutofillManager* autofill_manager_; |
51 | 57 |
52 base::WeakPtrFactory<AutofillAssistant> weak_ptr_factory_; | 58 base::WeakPtrFactory<AutofillAssistant> weak_ptr_factory_; |
53 | 59 |
54 DISALLOW_COPY_AND_ASSIGN(AutofillAssistant); | 60 DISALLOW_COPY_AND_ASSIGN(AutofillAssistant); |
55 }; | 61 }; |
56 | 62 |
57 } // namespace autofill | 63 } // namespace autofill |
58 | 64 |
59 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_ASSISTANT_H_ | 65 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_AUTOFILL_ASSISTANT_H_ |
OLD | NEW |