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

Side by Side Diff: chrome/browser/password_manager/native_backend_kwallet_x.h

Issue 2806002: Linux: refactor GNOME Keyring and KWallet integration to allow migration. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_ 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_
7 7
8 #include <dbus/dbus-glib.h> 8 #include <dbus/dbus-glib.h>
9 #include <glib.h> 9 #include <glib.h>
10 10
11 #include <string> 11 #include <string>
12 #include <vector>
13 12
14 #include "base/lock.h" 13 #include "base/basictypes.h"
15 #include "chrome/browser/password_manager/login_database.h" 14 #include "base/time.h"
16 #include "chrome/browser/password_manager/password_store.h" 15 #include "chrome/browser/password_manager/password_store_x.h"
17 #include "chrome/browser/webdata/web_data_service.h"
18 #include "webkit/glue/password_form.h" 16 #include "webkit/glue/password_form.h"
19 17
20 class Pickle; 18 class Pickle;
21 class Profile;
22 class Task;
23 19
24 class PasswordStoreKWallet : public PasswordStore { 20 // NativeBackend implementation using KWallet.
21 class NativeBackendKWallet : public PasswordStoreX::NativeBackend {
25 public: 22 public:
26 PasswordStoreKWallet(LoginDatabase* login_db, 23 NativeBackendKWallet();
27 Profile* profile,
28 WebDataService* web_data_service);
29 24
30 bool Init(); 25 virtual ~NativeBackendKWallet();
26
27 virtual bool Init();
28
29 // Implements NativeBackend interface.
30 virtual bool AddLogin(const webkit_glue::PasswordForm& form);
31 virtual bool UpdateLogin(const webkit_glue::PasswordForm& form);
32 virtual bool RemoveLogin(const webkit_glue::PasswordForm& form);
33 virtual bool RemoveLoginsCreatedBetween(const base::Time& delete_begin,
34 const base::Time& delete_end);
35 virtual bool GetLogins(const webkit_glue::PasswordForm& form,
36 PasswordFormList* forms);
37 virtual bool GetLoginsCreatedBetween(const base::Time& delete_begin,
38 const base::Time& delete_end,
39 PasswordFormList* forms);
40 virtual bool GetAutofillableLogins(PasswordFormList* forms);
41 virtual bool GetBlacklistLogins(PasswordFormList* forms);
31 42
32 private: 43 private:
33 typedef std::vector<webkit_glue::PasswordForm*> PasswordFormList;
34
35 virtual ~PasswordStoreKWallet();
36
37 // Implements PasswordStore interface.
38 virtual void AddLoginImpl(const webkit_glue::PasswordForm& form);
39 virtual void UpdateLoginImpl(const webkit_glue::PasswordForm& form);
40 virtual void RemoveLoginImpl(const webkit_glue::PasswordForm& form);
41 virtual void RemoveLoginsCreatedBetweenImpl(const base::Time& delete_begin,
42 const base::Time& delete_end);
43 virtual void GetLoginsImpl(GetLoginsRequest* request,
44 const webkit_glue::PasswordForm& form);
45 virtual void GetAutofillableLoginsImpl(GetLoginsRequest* request);
46 virtual void GetBlacklistLoginsImpl(GetLoginsRequest* request);
47 virtual bool FillAutofillableLogins(
48 std::vector<webkit_glue::PasswordForm*>* forms);
49 virtual bool FillBlacklistLogins(
50 std::vector<webkit_glue::PasswordForm*>* forms);
51
52 // Initialization. 44 // Initialization.
53 bool StartKWalletd(); 45 bool StartKWalletd();
54 bool InitWallet(); 46 bool InitWallet();
55 47
56 // Reads a list of PasswordForms from the wallet that match the signon_realm. 48 // Reads PasswordForms from the wallet that match the given signon_realm.
57 void GetLoginsList(PasswordFormList* forms, 49 bool GetLoginsList(PasswordFormList* forms,
58 const std::string& signon_realm, 50 const std::string& signon_realm,
59 int wallet_handle); 51 int wallet_handle);
60 52
53 // Reads PasswordForms from the wallet with the given autofillability state.
54 bool GetLoginsList(PasswordFormList* forms,
55 bool autofillable,
56 int wallet_handle);
57
58 // Reads PasswordForms from the wallet created in the given time range.
59 bool GetLoginsList(PasswordFormList* forms,
60 const base::Time& begin,
61 const base::Time& end,
62 int wallet_handle);
63
64 // Helper for some of the above GetLoginsList() methods.
65 bool GetAllLogins(PasswordFormList* forms, int wallet_handle);
66
61 // Writes a list of PasswordForms to the wallet with the given signon_realm. 67 // Writes a list of PasswordForms to the wallet with the given signon_realm.
62 // Overwrites any existing list for this signon_realm. Removes the entry if 68 // Overwrites any existing list for this signon_realm. Removes the entry if
63 // |forms| is empty. 69 // |forms| is empty. Returns true on success.
64 void SetLoginsList(const PasswordFormList& forms, 70 bool SetLoginsList(const PasswordFormList& forms,
65 const std::string& signon_realm, 71 const std::string& signon_realm,
66 int wallet_handle); 72 int wallet_handle);
67 73
68 // Helper for FillAutofillableLogins() and FillBlacklistLogins().
69 bool FillSomeLogins(bool autofillable, PasswordFormList* forms);
70
71 // Checks if the last DBus call returned an error. If it did, logs the error 74 // Checks if the last DBus call returned an error. If it did, logs the error
72 // message, frees it and returns true. 75 // message, frees it and returns true.
73 // This must be called after every DBus call. 76 // This must be called after every DBus call.
74 bool CheckError(); 77 bool CheckError();
75 78
76 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. 79 // Opens the wallet and ensures that the "Chrome Form Data" folder exists.
77 // Returns kInvalidWalletHandle on error. 80 // Returns kInvalidWalletHandle on error.
78 int WalletHandle(); 81 int WalletHandle();
79 82
80 // Compares two PasswordForms and returns true if they are the same. 83 // Compares two PasswordForms and returns true if they are the same.
(...skipping 29 matching lines...) Expand all
110 static const char* kKWalletServiceName; 113 static const char* kKWalletServiceName;
111 static const char* kKWalletPath; 114 static const char* kKWalletPath;
112 static const char* kKWalletInterface; 115 static const char* kKWalletInterface;
113 static const char* kKLauncherServiceName; 116 static const char* kKLauncherServiceName;
114 static const char* kKLauncherPath; 117 static const char* kKLauncherPath;
115 static const char* kKLauncherInterface; 118 static const char* kKLauncherInterface;
116 119
117 // Invalid handle returned by WalletHandle(). 120 // Invalid handle returned by WalletHandle().
118 static const int kInvalidKWalletHandle = -1; 121 static const int kInvalidKWalletHandle = -1;
119 122
120 // Controls all access to kwallet DBus calls.
121 Lock kwallet_lock_;
122
123 // Error from the last DBus call. NULL when there's no error. Freed and 123 // Error from the last DBus call. NULL when there's no error. Freed and
124 // cleared by CheckError(). 124 // cleared by CheckError().
125 GError* error_; 125 GError* error_;
126 // Connection to the DBus session bus. 126 // Connection to the DBus session bus.
127 DBusGConnection* connection_; 127 DBusGConnection* connection_;
128 // Proxy to the kwallet DBus service. 128 // Proxy to the kwallet DBus service.
129 DBusGProxy* proxy_; 129 DBusGProxy* proxy_;
130 130
131 // The name of the wallet we've opened. Set during Init(). 131 // The name of the wallet we've opened. Set during Init().
132 std::string wallet_name_; 132 std::string wallet_name_;
133 133
134 DISALLOW_COPY_AND_ASSIGN(PasswordStoreKWallet); 134 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet);
135 }; 135 };
136 136
137 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_ 137 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/native_backend_gnome_x.cc ('k') | chrome/browser/password_manager/native_backend_kwallet_x.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698