summaryrefslogtreecommitdiffstats
path: root/chrome/browser/password_manager/native_backend_gnome_x.h
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser/password_manager/native_backend_gnome_x.h')
-rw-r--r--chrome/browser/password_manager/native_backend_gnome_x.h62
1 files changed, 62 insertions, 0 deletions
diff --git a/chrome/browser/password_manager/native_backend_gnome_x.h b/chrome/browser/password_manager/native_backend_gnome_x.h
new file mode 100644
index 0000000..aa554be
--- /dev/null
+++ b/chrome/browser/password_manager/native_backend_gnome_x.h
@@ -0,0 +1,62 @@
+// Copyright (c) 2010 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 CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_
+#define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_
+
+extern "C" {
+#include <gnome-keyring.h>
+}
+
+#include <vector>
+
+#include "base/basictypes.h"
+#include "base/time.h"
+#include "chrome/browser/password_manager/password_store_x.h"
+
+namespace webkit_glue {
+struct PasswordForm;
+}
+
+// NativeBackend implementation using GNOME Keyring.
+class NativeBackendGnome : public PasswordStoreX::NativeBackend {
+ public:
+ NativeBackendGnome();
+
+ virtual ~NativeBackendGnome();
+
+ virtual bool Init();
+
+ // Implements NativeBackend interface.
+ virtual bool AddLogin(const webkit_glue::PasswordForm& form);
+ virtual bool UpdateLogin(const webkit_glue::PasswordForm& form);
+ virtual bool RemoveLogin(const webkit_glue::PasswordForm& form);
+ virtual bool RemoveLoginsCreatedBetween(const base::Time& delete_begin,
+ const base::Time& delete_end);
+ virtual bool GetLogins(const webkit_glue::PasswordForm& form,
+ PasswordFormList* forms);
+ virtual bool GetLoginsCreatedBetween(const base::Time& get_begin,
+ const base::Time& get_end,
+ PasswordFormList* forms);
+ virtual bool GetAutofillableLogins(PasswordFormList* forms);
+ virtual bool GetBlacklistLogins(PasswordFormList* forms);
+
+ private:
+ // Reads PasswordForms from the keyring with the given autofillability state.
+ bool GetLoginsList(PasswordFormList* forms, bool autofillable);
+
+ // Helper for GetLoginsCreatedBetween().
+ bool GetAllLogins(PasswordFormList* forms);
+
+ // Parse all the results from the given GList into a PasswordFormList, and
+ // free the GList. PasswordForms are allocated on the heap, and should be
+ // deleted by the consumer.
+ void ConvertFormList(GList* found, PasswordFormList* forms);
+
+ static const GnomeKeyringPasswordSchema kGnomeSchema;
+
+ DISALLOW_COPY_AND_ASSIGN(NativeBackendGnome);
+};
+
+#endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_GNOME_X_H_