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

Unified Diff: components/autofill/core/browser/autofill_driver_factory.h

Issue 2715483002: Split non-//content parts from ContentAutofillDriverFactory (Closed)
Patch Set: Add instances check 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 side-by-side diff with in-line comments
Download patch
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
new file mode 100644
index 0000000000000000000000000000000000000000..8446d7af363b917a9cff21f9647892e9f5c9a78c
--- /dev/null
+++ b/components/autofill/core/browser/autofill_driver_factory.h
@@ -0,0 +1,60 @@
+// 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.
+
+#ifndef AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_
+#define AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_
+
+#include <memory>
+#include <unordered_map>
+
+#include "base/callback_forward.h"
+#include "base/macros.h"
+
+namespace autofill {
+
+class AutofillClient;
+class AutofillDriver;
+
+// Manages the lifetime of AutofillDrivers for a particular AutofillClient by
+// creating, retrieveing and deleting on demand.
+class AutofillDriverFactory {
+ // The API is protected to guarantee subclasses that nothing else can
+ // interfere with the map of drivers.
+ protected:
+ explicit AutofillDriverFactory(AutofillClient* client);
+
+ ~AutofillDriverFactory();
+
+ // A convenience function to retrieve an AutofillDriver for the given key or
+ // 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();
+
+ AutofillClient* client() { return client_; };
+
+ private:
+ AutofillClient* const client_;
+
+ std::unordered_map<void*, std::unique_ptr<AutofillDriver>> driver_map_;
+
+ DISALLOW_COPY_AND_ASSIGN(AutofillDriverFactory);
+};
+
+} // namespace autofill
+
+#endif // AUTOFILL_CORE_BROWSER_AUTOFILL_DRIVER_FACTORY_H_
« no previous file with comments | « components/autofill/core/browser/BUILD.gn ('k') | components/autofill/core/browser/autofill_driver_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698