| OLD | NEW | 
|---|
|  | (Empty) | 
| 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 |  | 
| 3 // found in the LICENSE file. |  | 
| 4 |  | 
| 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_ |  | 
| 6 #define CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_ |  | 
| 7 |  | 
| 8 #include <dbus/dbus-glib.h> |  | 
| 9 #include <glib.h> |  | 
| 10 |  | 
| 11 #include <string> |  | 
| 12 #include <vector> |  | 
| 13 |  | 
| 14 #include "base/lock.h" |  | 
| 15 #include "chrome/browser/password_manager/login_database.h" |  | 
| 16 #include "chrome/browser/password_manager/password_store.h" |  | 
| 17 #include "chrome/browser/webdata/web_data_service.h" |  | 
| 18 #include "webkit/glue/password_form.h" |  | 
| 19 |  | 
| 20 class Pickle; |  | 
| 21 class Profile; |  | 
| 22 class Task; |  | 
| 23 |  | 
| 24 class PasswordStoreKWallet : public PasswordStore { |  | 
| 25  public: |  | 
| 26   PasswordStoreKWallet(LoginDatabase* login_db, |  | 
| 27                        Profile* profile, |  | 
| 28                        WebDataService* web_data_service); |  | 
| 29 |  | 
| 30   bool Init(); |  | 
| 31 |  | 
| 32  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. |  | 
| 53   bool StartKWalletd(); |  | 
| 54   bool InitWallet(); |  | 
| 55 |  | 
| 56   // Reads a list of PasswordForms from the wallet that match the signon_realm. |  | 
| 57   void GetLoginsList(PasswordFormList* forms, |  | 
| 58                      const std::string& signon_realm, |  | 
| 59                      int wallet_handle); |  | 
| 60 |  | 
| 61   // 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 |  | 
| 63   // |forms| is empty. |  | 
| 64   void SetLoginsList(const PasswordFormList& forms, |  | 
| 65                      const std::string& signon_realm, |  | 
| 66                      int wallet_handle); |  | 
| 67 |  | 
| 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 |  | 
| 72   // message, frees it and returns true. |  | 
| 73   // This must be called after every DBus call. |  | 
| 74   bool CheckError(); |  | 
| 75 |  | 
| 76   // Opens the wallet and ensures that the "Chrome Form Data" folder exists. |  | 
| 77   // Returns kInvalidWalletHandle on error. |  | 
| 78   int WalletHandle(); |  | 
| 79 |  | 
| 80   // Compares two PasswordForms and returns true if they are the same. |  | 
| 81   // If |update_check| is false, we only check the fields that are checked by |  | 
| 82   // LoginDatabase::UpdateLogin() when updating logins; otherwise, we check the |  | 
| 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); |  | 
| 87 |  | 
| 88   // Serializes a list of PasswordForms to be stored in the wallet. |  | 
| 89   static void SerializeValue(const PasswordFormList& forms, Pickle* pickle); |  | 
| 90 |  | 
| 91   // Deserializes a list of PasswordForms from the wallet. |  | 
| 92   static void DeserializeValue(const std::string& signon_realm, |  | 
| 93                                const Pickle& pickle, |  | 
| 94                                PasswordFormList* forms); |  | 
| 95 |  | 
| 96   // Convenience function to read a GURL from a Pickle. Assumes the URL has |  | 
| 97   // been written as a std::string. |  | 
| 98   static void ReadGURL(const Pickle& pickle, void** iter, GURL* url); |  | 
| 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 |  | 
| 104   // Name of the application - will appear in kwallet's dialogs. |  | 
| 105   static const char* kAppId; |  | 
| 106   // Name of the folder to store passwords in. |  | 
| 107   static const char* kKWalletFolder; |  | 
| 108 |  | 
| 109   // DBus stuff. |  | 
| 110   static const char* kKWalletServiceName; |  | 
| 111   static const char* kKWalletPath; |  | 
| 112   static const char* kKWalletInterface; |  | 
| 113   static const char* kKLauncherServiceName; |  | 
| 114   static const char* kKLauncherPath; |  | 
| 115   static const char* kKLauncherInterface; |  | 
| 116 |  | 
| 117   // Invalid handle returned by WalletHandle(). |  | 
| 118   static const int kInvalidKWalletHandle = -1; |  | 
| 119 |  | 
| 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 |  | 
| 124   // cleared by CheckError(). |  | 
| 125   GError* error_; |  | 
| 126   // Connection to the DBus session bus. |  | 
| 127   DBusGConnection* connection_; |  | 
| 128   // Proxy to the kwallet DBus service. |  | 
| 129   DBusGProxy* proxy_; |  | 
| 130 |  | 
| 131   // The name of the wallet we've opened. Set during Init(). |  | 
| 132   std::string wallet_name_; |  | 
| 133 |  | 
| 134   DISALLOW_COPY_AND_ASSIGN(PasswordStoreKWallet); |  | 
| 135 }; |  | 
| 136 |  | 
| 137 #endif  // CHROME_BROWSER_PASSWORD_MANAGER_PASSWORD_STORE_KWALLET_H_ |  | 
| OLD | NEW | 
|---|