| Index: components/autofill/core/browser/autofill_driver_factory.cc
|
| diff --git a/components/autofill/core/browser/autofill_driver_factory.cc b/components/autofill/core/browser/autofill_driver_factory.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..19d369bb1f9427631db2ebed991123de6af2fd14
|
| --- /dev/null
|
| +++ b/components/autofill/core/browser/autofill_driver_factory.cc
|
| @@ -0,0 +1,44 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "components/autofill/core/browser/autofill_driver_factory.h"
|
| +
|
| +#include "base/callback.h"
|
| +#include "components/autofill/core/browser/autofill_client.h"
|
| +#include "components/autofill/core/browser/autofill_driver.h"
|
| +
|
| +namespace autofill {
|
| +
|
| +AutofillDriverFactory::AutofillDriverFactory(AutofillClient* client)
|
| + : client_(client) {}
|
| +
|
| +AutofillDriverFactory::~AutofillDriverFactory() {}
|
| +
|
| +AutofillDriver* AutofillDriverFactory::DriverForKey(void* key) {
|
| + auto mapping = driver_map_.find(key);
|
| + return mapping == driver_map_.end() ? nullptr : mapping->second.get();
|
| +}
|
| +
|
| +void AutofillDriverFactory::AddForKey(
|
| + void* key,
|
| + base::Callback<std::unique_ptr<AutofillDriver>()> factory_method) {
|
| + auto insertion_result = driver_map_.insert(std::make_pair(key, nullptr));
|
| + // This can be called twice for the key representing the main frame.
|
| + if (insertion_result.second)
|
| + insertion_result.first->second = factory_method.Run();
|
| +}
|
| +
|
| +void AutofillDriverFactory::DeleteForKey(void* key) {
|
| + driver_map_.erase(key);
|
| +}
|
| +
|
| +void AutofillDriverFactory::NavigationFinished() {
|
| + client_->HideAutofillPopup();
|
| +}
|
| +
|
| +void AutofillDriverFactory::TabHidden() {
|
| + client_->HideAutofillPopup();
|
| +}
|
| +
|
| +} // namespace autofill
|
|
|