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..ff48bb67ec3df2bb1ca241cd1f6a747a7cf3211d 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, retrieving and deleting on demand. |
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); |
}; |