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

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

Issue 2407001: Linux: bring GNOME Keyring and KWallet integration back into a compilable state. (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) 2006-2009 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_PASSWORD_STORE_KWALLET_H_
6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_ 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_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> 12 #include <vector>
13 13
14 #include "base/lock.h" 14 #include "base/lock.h"
15 #include "base/thread.h" 15 #include "chrome/browser/password_manager/login_database.h"
16 #include "chrome/browser/password_manager/password_store.h" 16 #include "chrome/browser/password_manager/password_store.h"
17 #include "chrome/browser/webdata/web_data_service.h"
17 #include "webkit/glue/password_form.h" 18 #include "webkit/glue/password_form.h"
18 19
19 class Pickle; 20 class Pickle;
20 class Profile; 21 class Profile;
21 class Task; 22 class Task;
22 23
23 class PasswordStoreKWallet : public PasswordStore { 24 class PasswordStoreKWallet : public PasswordStore {
24 public: 25 public:
25 PasswordStoreKWallet(); 26 PasswordStoreKWallet(LoginDatabase* login_db,
27 Profile* profile,
28 WebDataService* web_data_service);
26 29
27 bool Init(); 30 bool Init();
28 31
29 private: 32 private:
30 typedef std::vector<PasswordForm*> PasswordFormList; 33 typedef std::vector<webkit_glue::PasswordForm*> PasswordFormList;
31 34
32 virtual ~PasswordStoreKWallet(); 35 virtual ~PasswordStoreKWallet();
33 36
34 // Implements PasswordStore interface. 37 // Implements PasswordStore interface.
35 void AddLoginImpl(const PasswordForm& form); 38 virtual void AddLoginImpl(const webkit_glue::PasswordForm& form);
36 void UpdateLoginImpl(const PasswordForm& form); 39 virtual void UpdateLoginImpl(const webkit_glue::PasswordForm& form);
37 void RemoveLoginImpl(const PasswordForm& form); 40 virtual void RemoveLoginImpl(const webkit_glue::PasswordForm& form);
38 void GetLoginsImpl(GetLoginsRequest* request); 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);
39 51
40 // Initialisation. 52 // Initialization.
41 bool StartKWalletd(); 53 bool StartKWalletd();
42 bool InitWallet(); 54 bool InitWallet();
43 55
44 // Reads a list of PasswordForms from the wallet that match the signon_realm 56 // Reads a list of PasswordForms from the wallet that match the signon_realm.
45 // of key. 57 void GetLoginsList(PasswordFormList* forms,
46 void GetLoginsList(PasswordFormList* forms, const PasswordForm& key, 58 const std::string& signon_realm,
47 int wallet_handle); 59 int wallet_handle);
48 60
49 // Writes a list of PasswordForms to the wallet with the signon_realm from 61 // Writes a list of PasswordForms to the wallet with the given signon_realm.
50 // key. Overwrites any existing list for this key. 62 // Overwrites any existing list for this signon_realm. Removes the entry if
51 void SetLoginsList(const PasswordFormList& forms, const PasswordForm& key, 63 // |forms| is empty.
64 void SetLoginsList(const PasswordFormList& forms,
65 const std::string& signon_realm,
52 int wallet_handle); 66 int wallet_handle);
53 67
54 // Checks if the last dbus call returned an error. If it did, logs the error 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
55 // message, frees it and returns true. 72 // message, frees it and returns true.
56 // This must be called after every dbus call. 73 // This must be called after every DBus call.
57 bool CheckError(); 74 bool CheckError();
58 75
59 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. 76 // Opens the wallet and ensures that the "Chrome Form Data" folder exists.
60 // Returns kInvalidWalletHandle on error. 77 // Returns kInvalidWalletHandle on error.
61 int WalletHandle(); 78 int WalletHandle();
62 79
63 // Compares two PasswordForms and returns true if they are the same. 80 // Compares two PasswordForms and returns true if they are the same.
64 // Checks only the fields that we persist in KWallet, and ignores 81 // If |update_check| is false, we only check the fields that are checked by
65 // password_value. 82 // LoginDatabase::UpdateLogin() when updating logins; otherwise, we check the
66 static bool CompareForms(const PasswordForm& a, const PasswordForm& b); 83 // fields that are checked by LoginDatabase::RemoveLogin() for removing them.
84 static bool CompareForms(const webkit_glue::PasswordForm& a,
85 const webkit_glue::PasswordForm& b,
86 bool update_check);
67 87
68 // Serializes a list of PasswordForms to be stored in the wallet. 88 // Serializes a list of PasswordForms to be stored in the wallet.
69 static void SerializeValue(const PasswordFormList& forms, Pickle* pickle); 89 static void SerializeValue(const PasswordFormList& forms, Pickle* pickle);
70 90
71 // Deserializes a list of PasswordForms from the wallet. 91 // Deserializes a list of PasswordForms from the wallet.
72 static void DeserializeValue(const PasswordForm& key, const Pickle& pickle, 92 static void DeserializeValue(const std::string& signon_realm,
93 const Pickle& pickle,
73 PasswordFormList* forms); 94 PasswordFormList* forms);
74 95
75 // Convenience function to read a GURL from a Pickle. Assumes the URL has 96 // Convenience function to read a GURL from a Pickle. Assumes the URL has
76 // been written as a std::string. 97 // been written as a std::string.
77 static void ReadGURL(const Pickle& pickle, void** iter, GURL* url); 98 static void ReadGURL(const Pickle& pickle, void** iter, GURL* url);
78 99
100 // In case the fields in the pickle ever change, version them so we can try to
101 // read old pickles. (Note: do not eat old pickles past the expiration date.)
102 static const int kPickleVersion = 0;
103
79 // Name of the application - will appear in kwallet's dialogs. 104 // Name of the application - will appear in kwallet's dialogs.
80 static const char* kAppId; 105 static const char* kAppId;
81 // Name of the folder to store passwords in. 106 // Name of the folder to store passwords in.
82 static const char* kKWalletFolder; 107 static const char* kKWalletFolder;
83 108
84 // DBUS stuff. 109 // DBus stuff.
85 static const char* kKWalletServiceName; 110 static const char* kKWalletServiceName;
86 static const char* kKWalletPath; 111 static const char* kKWalletPath;
87 static const char* kKWalletInterface; 112 static const char* kKWalletInterface;
88 static const char* kKLauncherServiceName; 113 static const char* kKLauncherServiceName;
89 static const char* kKLauncherPath; 114 static const char* kKLauncherPath;
90 static const char* kKLauncherInterface; 115 static const char* kKLauncherInterface;
91 116
92 // Invalid handle returned by WalletHandle(). 117 // Invalid handle returned by WalletHandle().
93 static const int kInvalidKWalletHandle = -1; 118 static const int kInvalidKWalletHandle = -1;
94 119
95 // Controls all access to kwallet dbus calls. 120 // Controls all access to kwallet DBus calls.
96 Lock kwallet_lock_; 121 Lock kwallet_lock_;
97 122
98 // 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
99 // cleared by CheckError(). 124 // cleared by CheckError().
100 GError* error_; 125 GError* error_;
101 // Connection to the dbus session bus. 126 // Connection to the DBus session bus.
102 DBusGConnection* connection_; 127 DBusGConnection* connection_;
103 // Proxy to the kwallet dbus service. 128 // Proxy to the kwallet DBus service.
104 DBusGProxy* proxy_; 129 DBusGProxy* proxy_;
105 130
106 // The name of the wallet we've opened. Set during Init(). 131 // The name of the wallet we've opened. Set during Init().
107 std::string wallet_name_; 132 std::string wallet_name_;
108 133
109 DISALLOW_COPY_AND_ASSIGN(PasswordStoreKWallet); 134 DISALLOW_COPY_AND_ASSIGN(PasswordStoreKWallet);
110 }; 135 };
111 136
112 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_ 137 #endif // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_store_gnome.cc ('k') | chrome/browser/password_manager/password_store_kwallet.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698