| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_ |
| 6 #define AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_ |
| 7 |
| 8 #include <memory> |
| 9 #include <unordered_map> |
| 10 |
| 11 #include "base/callback_forward.h" |
| 12 #include "base/macros.h" |
| 13 |
| 14 namespace autofill { |
| 15 |
| 16 class AutofillClient; |
| 17 class AutofillDriver; |
| 18 |
| 19 // Manages the lifetime of AutofillDrivers for a particular AutofillClient by |
| 20 // creating, retrieveing and deleting on demand. |
| 21 class AutofillDriverFactory { |
| 22 // The API is protected to guarantee subclasses that nothing else can |
| 23 // interfere with the map of drivers. |
| 24 protected: |
| 25 explicit AutofillDriverFactory(AutofillClient* client); |
| 26 |
| 27 ~AutofillDriverFactory(); |
| 28 |
| 29 // A convenience function to retrieve an AutofillDriver for the given key or |
| 30 // null if there is none. |
| 31 AutofillDriver* DriverForKey(void* key); |
| 32 |
| 33 // Adds a driver, constructed by calling |factory_method|, for |key|. If there |
| 34 // already is a driver for |key|, |factory_method| is not called. |
| 35 void AddForKey( |
| 36 void* key, |
| 37 base::Callback<std::unique_ptr<AutofillDriver>()> factory_method); |
| 38 |
| 39 // Deletes the AutofillDriver for |key|. |
| 40 void DeleteForKey(void* key); |
| 41 |
| 42 // Handles finished navigation in any of the frames. |
| 43 void NavigationFinished(); |
| 44 |
| 45 // Handles hiding of the corresponding tab. |
| 46 void TabHidden(); |
| 47 |
| 48 AutofillClient* client() { return client_; }; |
| 49 |
| 50 private: |
| 51 AutofillClient* const client_; |
| 52 |
| 53 std::unordered_map<void*, std::unique_ptr<AutofillDriver>> driver_map_; |
| 54 |
| 55 DISALLOW_COPY_AND_ASSIGN(AutofillDriverFactory); |
| 56 }; |
| 57 |
| 58 } // namespace autofill |
| 59 |
| 60 #endif // AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_ |
| OLD | NEW |