Chromium Code Reviews| Index: components/autofill/core/browser/autofill_driver_factory.h |
| diff --git a/components/autofill/core/browser/autofill_driver_factory.h b/components/autofill/core/browser/autofill_driver_factory.h |
| index 8446d7af363b917a9cff21f9647892e9f5c9a78c..23995e69317aa4a68eb8eb3736526262f2364a39 100644 |
| --- a/components/autofill/core/browser/autofill_driver_factory.h |
| +++ b/components/autofill/core/browser/autofill_driver_factory.h |
| @@ -17,11 +17,9 @@ class AutofillClient; |
| class AutofillDriver; |
| // Manages the lifetime of AutofillDrivers for a particular AutofillClient by |
| -// creating, retrieveing and deleting on demand. |
| +// creating, notifying, retrieveing and deleting on demand. |
|
Mathieu
2017/02/27 15:46:29
*retrieving
vabr (Chromium)
2017/02/27 16:45:46
Done.
|
| class AutofillDriverFactory { |
| - // The API is protected to guarantee subclasses that nothing else can |
| - // interfere with the map of drivers. |
| - protected: |
| + public: |
| explicit AutofillDriverFactory(AutofillClient* client); |
| ~AutofillDriverFactory(); |
| @@ -30,28 +28,41 @@ class AutofillDriverFactory { |
| // null if there is none. |
| AutofillDriver* DriverForKey(void* key); |
| - // Adds a driver, constructed by calling |factory_method|, for |key|. If there |
| - // already is a driver for |key|, |factory_method| is not called. |
| - void AddForKey( |
| - void* key, |
| - base::Callback<std::unique_ptr<AutofillDriver>()> factory_method); |
| - |
| - // Deletes the AutofillDriver for |key|. |
| - void DeleteForKey(void* key); |
| - |
| // Handles finished navigation in any of the frames. |
| void NavigationFinished(); |
| // Handles hiding of the corresponding tab. |
| void TabHidden(); |
| + // Call this to notify the factory that one of the frames saw a user gesture. |
| + // The factory will distribute this information to all drivers when it comes |
| + // for the first time since the last main frame navigation to a different |
| + // page. It will also notify drivers added later (see AddForKey). |
| + void OnFirstUserGestureObserved(); |
| + |
| AutofillClient* client() { return client_; }; |
| + protected: |
| + // The API manipulating the drivers map is protected to guarantee subclasses |
| + // that nothing else can interfere with the map of drivers. |
| + |
| + // Adds a driver, constructed by calling |factory_method|, for |key|. If there |
| + // already is a driver for |key|, |factory_method| is not called. This might |
| + // end up notifying the driver that a user gesture has been observed. |
| + void AddForKey( |
| + void* key, |
| + base::Callback<std::unique_ptr<AutofillDriver>()> factory_method); |
| + |
| + // Deletes the AutofillDriver for |key|. |
| + void DeleteForKey(void* key); |
| + |
| private: |
| AutofillClient* const client_; |
| std::unordered_map<void*, std::unique_ptr<AutofillDriver>> driver_map_; |
| + bool user_gesture_seen_ = false; // The state for OnFirstUserGestureObserved. |
| + |
| DISALLOW_COPY_AND_ASSIGN(AutofillDriverFactory); |
| }; |