Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(77)

Side by Side Diff: components/autofill/core/browser/autofill_driver_factory.h

Issue 2603623002: AutofillDriverFactory manages information about user gestures (Closed)
Patch Set: Remove braces Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 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 AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_ 5 #ifndef AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_
6 #define AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_ 6 #define AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <unordered_map> 9 #include <unordered_map>
10 10
11 #include "base/callback_forward.h" 11 #include "base/callback_forward.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 13
14 namespace autofill { 14 namespace autofill {
15 15
16 class AutofillClient; 16 class AutofillClient;
17 class AutofillDriver; 17 class AutofillDriver;
18 18
19 // Manages the lifetime of AutofillDrivers for a particular AutofillClient by 19 // Manages the lifetime of AutofillDrivers for a particular AutofillClient by
20 // creating, retrieveing and deleting on demand. 20 // creating, notifying, retrieveing and deleting on demand.
Mathieu 2017/02/27 15:46:29 *retrieving
vabr (Chromium) 2017/02/27 16:45:46 Done.
21 class AutofillDriverFactory { 21 class AutofillDriverFactory {
22 // The API is protected to guarantee subclasses that nothing else can 22 public:
23 // interfere with the map of drivers.
24 protected:
25 explicit AutofillDriverFactory(AutofillClient* client); 23 explicit AutofillDriverFactory(AutofillClient* client);
26 24
27 ~AutofillDriverFactory(); 25 ~AutofillDriverFactory();
28 26
29 // A convenience function to retrieve an AutofillDriver for the given key or 27 // A convenience function to retrieve an AutofillDriver for the given key or
30 // null if there is none. 28 // null if there is none.
31 AutofillDriver* DriverForKey(void* key); 29 AutofillDriver* DriverForKey(void* key);
32 30
31 // Handles finished navigation in any of the frames.
32 void NavigationFinished();
33
34 // Handles hiding of the corresponding tab.
35 void TabHidden();
36
37 // Call this to notify the factory that one of the frames saw a user gesture.
38 // The factory will distribute this information to all drivers when it comes
39 // for the first time since the last main frame navigation to a different
40 // page. It will also notify drivers added later (see AddForKey).
41 void OnFirstUserGestureObserved();
42
43 AutofillClient* client() { return client_; };
44
45 protected:
46 // The API manipulating the drivers map is protected to guarantee subclasses
47 // that nothing else can interfere with the map of drivers.
48
33 // Adds a driver, constructed by calling |factory_method|, for |key|. If there 49 // Adds a driver, constructed by calling |factory_method|, for |key|. If there
34 // already is a driver for |key|, |factory_method| is not called. 50 // already is a driver for |key|, |factory_method| is not called. This might
51 // end up notifying the driver that a user gesture has been observed.
35 void AddForKey( 52 void AddForKey(
36 void* key, 53 void* key,
37 base::Callback<std::unique_ptr<AutofillDriver>()> factory_method); 54 base::Callback<std::unique_ptr<AutofillDriver>()> factory_method);
38 55
39 // Deletes the AutofillDriver for |key|. 56 // Deletes the AutofillDriver for |key|.
40 void DeleteForKey(void* key); 57 void DeleteForKey(void* key);
41 58
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: 59 private:
51 AutofillClient* const client_; 60 AutofillClient* const client_;
52 61
53 std::unordered_map<void*, std::unique_ptr<AutofillDriver>> driver_map_; 62 std::unordered_map<void*, std::unique_ptr<AutofillDriver>> driver_map_;
54 63
64 bool user_gesture_seen_ = false; // The state for OnFirstUserGestureObserved.
65
55 DISALLOW_COPY_AND_ASSIGN(AutofillDriverFactory); 66 DISALLOW_COPY_AND_ASSIGN(AutofillDriverFactory);
56 }; 67 };
57 68
58 } // namespace autofill 69 } // namespace autofill
59 70
60 #endif // AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_ 71 #endif // AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_
OLDNEW
« no previous file with comments | « components/autofill/core/browser/autofill_driver.h ('k') | components/autofill/core/browser/autofill_driver_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698