Index: components/password_manager/core/browser/form_saver.h |
diff --git a/components/password_manager/core/browser/form_saver.h b/components/password_manager/core/browser/form_saver.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..9b452d415a6336aed36000887ebabfd298c6ed45 |
--- /dev/null |
+++ b/components/password_manager/core/browser/form_saver.h |
@@ -0,0 +1,63 @@ |
+// Copyright 2016 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 COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_SAVER_H_ |
+#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_SAVER_H_ |
+ |
+#include <vector> |
+ |
+#include "base/macros.h" |
+#include "base/optional.h" |
+#include "components/autofill/core/common/password_form.h" |
+ |
+namespace password_manager { |
+ |
+// This interface allows the caller to save passwords and blacklist entries in |
+// a password store. |
+class FormSaver { |
+ public: |
+ FormSaver() = default; |
+ |
+ virtual ~FormSaver() = default; |
+ |
+ // Configures the |observed| form to become a blacklist entry and saves it. |
+ virtual void PermanentlyBlacklist(autofill::PasswordForm* observed) = 0; |
+ |
+ // Saves the |pending| form and updates the stored preference on |
+ // |best_matches|. If |old_primary_key| is given, uses it for saving |
+ // |pending|. It also updates the password store with all |
+ // |credentials_to_update|. |
+ virtual void Save(const autofill::PasswordForm& pending, |
+ const autofill::PasswordFormMap& best_matches, |
+ const autofill::PasswordForm* old_primary_key) = 0; |
+ |
+ // Updates the |pending| form and updates the stored preference on |
+ // |best_matches|. If |old_primary_key| is given, uses it for saving |
+ // |pending|. It also updates the password store with all |
+ // |credentials_to_update|. |
+ virtual void Update( |
+ const autofill::PasswordForm& pending, |
+ const autofill::PasswordFormMap& best_matches, |
+ const std::vector<const autofill::PasswordForm*>* credentials_to_update, |
+ const autofill::PasswordForm* old_primary_key) = 0; |
+ |
+ // Ensures that |generated| is saved in the store. This is in ideal case |
+ // either followed by a call to Save or RemovePresavedPassword. But if the |
+ // user interaction does not allow to call either of those, calling |
+ // PresaveGeneratedPassword alone is a legitimate thing to do to avoid data |
+ // loss. |
+ virtual void PresaveGeneratedPassword( |
+ const autofill::PasswordForm& generated) = 0; |
+ |
+ // Undo PresaveGeneratedPassword, e.g., when the user deletes the generated |
+ // password. |
+ virtual void RemovePresavedPassword() = 0; |
+ |
+ private: |
+ DISALLOW_COPY_AND_ASSIGN(FormSaver); |
+}; |
+ |
+} // namespace password_manager |
+ |
+#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_FORM_SAVER_H_ |