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.cc

Issue 2603623002: AutofillDriverFactory manages information about user gestures (Closed)
Patch Set: Fix typo Created 3 years, 9 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 #include "components/autofill/core/browser/autofill_driver_factory.h" 5 #include "components/autofill/core/browser/autofill_driver_factory.h"
6 6
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "components/autofill/core/browser/autofill_client.h" 8 #include "components/autofill/core/browser/autofill_client.h"
9 #include "components/autofill/core/browser/autofill_driver.h" 9 #include "components/autofill/core/browser/autofill_driver.h"
10 10
11 namespace autofill { 11 namespace autofill {
12 12
13 AutofillDriverFactory::AutofillDriverFactory(AutofillClient* client) 13 AutofillDriverFactory::AutofillDriverFactory(AutofillClient* client)
14 : client_(client) {} 14 : client_(client) {}
15 15
16 AutofillDriverFactory::~AutofillDriverFactory() {} 16 AutofillDriverFactory::~AutofillDriverFactory() {}
17 17
18 AutofillDriver* AutofillDriverFactory::DriverForKey(void* key) { 18 AutofillDriver* AutofillDriverFactory::DriverForKey(void* key) {
19 auto mapping = driver_map_.find(key); 19 auto mapping = driver_map_.find(key);
20 return mapping == driver_map_.end() ? nullptr : mapping->second.get(); 20 return mapping == driver_map_.end() ? nullptr : mapping->second.get();
21 } 21 }
22 22
23 void AutofillDriverFactory::NavigationFinished() {
24 user_gesture_seen_ = false;
25 client_->HideAutofillPopup();
26 }
27
28 void AutofillDriverFactory::TabHidden() {
29 client_->HideAutofillPopup();
30 }
31
32 void AutofillDriverFactory::OnFirstUserGestureObserved() {
33 if (user_gesture_seen_)
34 return;
35
36 for (auto& driver : driver_map_)
37 driver.second->NotifyFirstUserGestureObservedInTab();
38
39 user_gesture_seen_ = true;
40 }
41
23 void AutofillDriverFactory::AddForKey( 42 void AutofillDriverFactory::AddForKey(
24 void* key, 43 void* key,
25 base::Callback<std::unique_ptr<AutofillDriver>()> factory_method) { 44 base::Callback<std::unique_ptr<AutofillDriver>()> factory_method) {
26 auto insertion_result = driver_map_.insert(std::make_pair(key, nullptr)); 45 auto insertion_result = driver_map_.insert(std::make_pair(key, nullptr));
27 // This can be called twice for the key representing the main frame. 46 // This can be called twice for the key representing the main frame.
28 if (insertion_result.second) 47 if (insertion_result.second) {
29 insertion_result.first->second = factory_method.Run(); 48 insertion_result.first->second = factory_method.Run();
49 if (user_gesture_seen_)
50 insertion_result.first->second->NotifyFirstUserGestureObservedInTab();
51 }
30 } 52 }
31 53
32 void AutofillDriverFactory::DeleteForKey(void* key) { 54 void AutofillDriverFactory::DeleteForKey(void* key) {
33 driver_map_.erase(key); 55 driver_map_.erase(key);
34 } 56 }
35 57
36 void AutofillDriverFactory::NavigationFinished() {
37 client_->HideAutofillPopup();
38 }
39
40 void AutofillDriverFactory::TabHidden() {
41 client_->HideAutofillPopup();
42 }
43
44 } // namespace autofill 58 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698