OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef COMPONENTS_AUTOFILL_CORE_BROWSER_ASSIST_MANAGER_H_ |
| 6 #define COMPONENTS_AUTOFILL_CORE_BROWSER_ASSIST_MANAGER_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <vector> |
| 10 |
| 11 #include "base/macros.h" |
| 12 #include "base/memory/weak_ptr.h" |
| 13 #include "components/autofill/core/common/form_data.h" |
| 14 |
| 15 namespace autofill { |
| 16 |
| 17 class AutofillManager; |
| 18 class CreditCard; |
| 19 class FormStructure; |
| 20 |
| 21 class AssistManager { |
| 22 public: |
| 23 explicit AssistManager(AutofillManager* autofill_manager); |
| 24 ~AssistManager(); |
| 25 |
| 26 // Should be called at every page navigation to clear state. |
| 27 void Reset(); |
| 28 |
| 29 // Returns whether an assist can be shown. Will go through the forms in |
| 30 // |form_structures| and extract the credit card form. |
| 31 bool CanShowCreditCardAssist( |
| 32 const std::vector<FormStructure*>& form_structures); |
| 33 |
| 34 // Will show an assist infobar for the previously extracted form. Can only |
| 35 // be called if CanShowCreditCardAssist() returned true. |
| 36 void ShowAssistForCreditCard(const CreditCard& card); |
| 37 |
| 38 private: |
| 39 void OnUserDidAcceptCreditCardFill(const CreditCard& card); |
| 40 |
| 41 // Holds the FormData to be filled with a credit card. |
| 42 std::unique_ptr<FormData> credit_card_form_data_; |
| 43 |
| 44 // Weak reference to the AutofillManager that created and maintains this |
| 45 // AssistManager. |
| 46 AutofillManager* autofill_manager_; |
| 47 |
| 48 base::WeakPtrFactory<AssistManager> weak_ptr_factory_; |
| 49 |
| 50 DISALLOW_COPY_AND_ASSIGN(AssistManager); |
| 51 }; |
| 52 |
| 53 } // namespace autofill |
| 54 |
| 55 #endif // COMPONENTS_AUTOFILL_CORE_BROWSER_ASSIST_MANAGER_H_ |
OLD | NEW |