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

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

Issue 2603623002: AutofillDriverFactory manages information about user gestures (Closed)
Patch Set: Make safe API public 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_) {
dvadym 2017/02/24 12:48:21 Nit: do we need {} here?
vabr (Chromium) 2017/02/24 12:54:25 We don't need them, but they are allowed [1]. Howe
37 driver.second->NotifyFirstUserGestureObservedInTab();
38 }
39
40 user_gesture_seen_ = true;
41 }
42
23 void AutofillDriverFactory::AddForKey( 43 void AutofillDriverFactory::AddForKey(
24 void* key, 44 void* key,
25 base::Callback<std::unique_ptr<AutofillDriver>()> factory_method) { 45 base::Callback<std::unique_ptr<AutofillDriver>()> factory_method) {
26 auto insertion_result = driver_map_.insert(std::make_pair(key, nullptr)); 46 auto insertion_result = driver_map_.insert(std::make_pair(key, nullptr));
27 // This can be called twice for the key representing the main frame. 47 // This can be called twice for the key representing the main frame.
28 if (insertion_result.second) 48 if (insertion_result.second) {
29 insertion_result.first->second = factory_method.Run(); 49 insertion_result.first->second = factory_method.Run();
50 if (user_gesture_seen_)
51 insertion_result.first->second->NotifyFirstUserGestureObservedInTab();
52 }
30 } 53 }
31 54
32 void AutofillDriverFactory::DeleteForKey(void* key) { 55 void AutofillDriverFactory::DeleteForKey(void* key) {
33 driver_map_.erase(key); 56 driver_map_.erase(key);
34 } 57 }
35 58
36 void AutofillDriverFactory::NavigationFinished() {
37 client_->HideAutofillPopup();
38 }
39
40 void AutofillDriverFactory::TabHidden() {
41 client_->HideAutofillPopup();
42 }
43
44 } // namespace autofill 59 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698