OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_NATIVE_BACKEND_KWALLET_X_H_ | 5 #ifndef CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ | 6 #define CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 virtual bool Init() OVERRIDE; | 40 virtual bool Init() OVERRIDE; |
41 | 41 |
42 // Implements NativeBackend interface. | 42 // Implements NativeBackend interface. |
43 virtual password_manager::PasswordStoreChangeList AddLogin( | 43 virtual password_manager::PasswordStoreChangeList AddLogin( |
44 const autofill::PasswordForm& form) OVERRIDE; | 44 const autofill::PasswordForm& form) OVERRIDE; |
45 virtual bool UpdateLogin( | 45 virtual bool UpdateLogin( |
46 const autofill::PasswordForm& form, | 46 const autofill::PasswordForm& form, |
47 password_manager::PasswordStoreChangeList* changes) OVERRIDE; | 47 password_manager::PasswordStoreChangeList* changes) OVERRIDE; |
48 virtual bool RemoveLogin(const autofill::PasswordForm& form) OVERRIDE; | 48 virtual bool RemoveLogin(const autofill::PasswordForm& form) OVERRIDE; |
49 virtual bool RemoveLoginsCreatedBetween( | 49 virtual bool RemoveLoginsCreatedBetween(base::Time delete_begin, |
50 const base::Time& delete_begin, const base::Time& delete_end) OVERRIDE; | 50 base::Time delete_end) OVERRIDE; |
| 51 virtual bool RemoveLoginsSyncedBetween( |
| 52 base::Time delete_begin, |
| 53 base::Time delete_end, |
| 54 password_manager::PasswordStoreChangeList* changes) OVERRIDE; |
51 virtual bool GetLogins(const autofill::PasswordForm& form, | 55 virtual bool GetLogins(const autofill::PasswordForm& form, |
52 PasswordFormList* forms) OVERRIDE; | 56 PasswordFormList* forms) OVERRIDE; |
53 virtual bool GetLoginsCreatedBetween(const base::Time& get_begin, | 57 virtual bool GetLoginsCreatedBetween(base::Time get_begin, |
54 const base::Time& get_end, | 58 base::Time get_end, |
55 PasswordFormList* forms) OVERRIDE; | 59 PasswordFormList* forms) OVERRIDE; |
56 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE; | 60 virtual bool GetAutofillableLogins(PasswordFormList* forms) OVERRIDE; |
57 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE; | 61 virtual bool GetBlacklistLogins(PasswordFormList* forms) OVERRIDE; |
58 | 62 |
59 protected: | 63 protected: |
60 // Invalid handle returned by WalletHandle(). | 64 // Invalid handle returned by WalletHandle(). |
61 static const int kInvalidKWalletHandle = -1; | 65 static const int kInvalidKWalletHandle = -1; |
62 | 66 |
63 // Internally used by Init(), but also for testing to provide a mock bus. | 67 // Internally used by Init(), but also for testing to provide a mock bus. |
64 bool InitWithBus(scoped_refptr<dbus::Bus> optional_bus); | 68 bool InitWithBus(scoped_refptr<dbus::Bus> optional_bus); |
65 | 69 |
66 // Deserializes a list of PasswordForms from the wallet. | 70 // Deserializes a list of PasswordForms from the wallet. |
67 static void DeserializeValue(const std::string& signon_realm, | 71 static void DeserializeValue(const std::string& signon_realm, |
68 const Pickle& pickle, | 72 const Pickle& pickle, |
69 PasswordFormList* forms); | 73 PasswordFormList* forms); |
70 | 74 |
71 private: | 75 private: |
72 enum InitResult { | 76 enum InitResult { |
73 INIT_SUCCESS, // Init succeeded. | 77 INIT_SUCCESS, // Init succeeded. |
74 TEMPORARY_FAIL, // Init failed, but might succeed after StartKWalletd(). | 78 TEMPORARY_FAIL, // Init failed, but might succeed after StartKWalletd(). |
75 PERMANENT_FAIL // Init failed, and is not likely to work later either. | 79 PERMANENT_FAIL // Init failed, and is not likely to work later either. |
76 }; | 80 }; |
77 | 81 |
| 82 enum TimestampToCompare { |
| 83 CREATION_TIMESTAMP, |
| 84 SYNC_TIMESTAMP, |
| 85 }; |
| 86 |
78 // Initialization. | 87 // Initialization. |
79 bool StartKWalletd(); | 88 bool StartKWalletd(); |
80 InitResult InitWallet(); | 89 InitResult InitWallet(); |
81 void InitOnDBThread(scoped_refptr<dbus::Bus> optional_bus, | 90 void InitOnDBThread(scoped_refptr<dbus::Bus> optional_bus, |
82 base::WaitableEvent* event, | 91 base::WaitableEvent* event, |
83 bool* success); | 92 bool* success); |
84 | 93 |
85 // Reads PasswordForms from the wallet that match the given signon_realm. | 94 // Reads PasswordForms from the wallet that match the given signon_realm. |
86 bool GetLoginsList(PasswordFormList* forms, | 95 bool GetLoginsList(PasswordFormList* forms, |
87 const std::string& signon_realm, | 96 const std::string& signon_realm, |
88 int wallet_handle); | 97 int wallet_handle); |
89 | 98 |
90 // Reads PasswordForms from the wallet with the given autofillability state. | 99 // Reads PasswordForms from the wallet with the given autofillability state. |
91 bool GetLoginsList(PasswordFormList* forms, | 100 bool GetLoginsList(PasswordFormList* forms, |
92 bool autofillable, | 101 bool autofillable, |
93 int wallet_handle); | 102 int wallet_handle); |
94 | 103 |
95 // Reads PasswordForms from the wallet created in the given time range. | 104 // Reads PasswordForms from the wallet created/synced in the given time range. |
96 bool GetLoginsList(PasswordFormList* forms, | 105 bool GetLoginsList(PasswordFormList* forms, |
97 const base::Time& begin, | 106 const base::Time& begin, |
98 const base::Time& end, | 107 const base::Time& end, |
99 int wallet_handle); | 108 int wallet_handle, |
| 109 TimestampToCompare date_to_compare); |
100 | 110 |
101 // Helper for some of the above GetLoginsList() methods. | 111 // Helper for some of the above GetLoginsList() methods. |
102 bool GetAllLogins(PasswordFormList* forms, int wallet_handle); | 112 bool GetAllLogins(PasswordFormList* forms, int wallet_handle); |
103 | 113 |
104 // Writes a list of PasswordForms to the wallet with the given signon_realm. | 114 // Writes a list of PasswordForms to the wallet with the given signon_realm. |
105 // Overwrites any existing list for this signon_realm. Removes the entry if | 115 // Overwrites any existing list for this signon_realm. Removes the entry if |
106 // |forms| is empty. Returns true on success. | 116 // |forms| is empty. Returns true on success. |
107 bool SetLoginsList(const PasswordFormList& forms, | 117 bool SetLoginsList(const PasswordFormList& forms, |
108 const std::string& signon_realm, | 118 const std::string& signon_realm, |
109 int wallet_handle); | 119 int wallet_handle); |
110 | 120 |
| 121 // Removes password created/synced in the time interval. Returns |true| if the |
| 122 // operation succeeded. |changes| will contain the changes applied. |
| 123 bool RemoveLoginsBetween(base::Time delete_begin, |
| 124 base::Time delete_end, |
| 125 TimestampToCompare date_to_compare, |
| 126 password_manager::PasswordStoreChangeList* changes); |
| 127 |
111 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. | 128 // Opens the wallet and ensures that the "Chrome Form Data" folder exists. |
112 // Returns kInvalidWalletHandle on error. | 129 // Returns kInvalidWalletHandle on error. |
113 int WalletHandle(); | 130 int WalletHandle(); |
114 | 131 |
115 // Serializes a list of PasswordForms to be stored in the wallet. | 132 // Serializes a list of PasswordForms to be stored in the wallet. |
116 static void SerializeValue(const PasswordFormList& forms, Pickle* pickle); | 133 static void SerializeValue(const PasswordFormList& forms, Pickle* pickle); |
117 | 134 |
118 // Deserializes a list of PasswordForms from the wallet. | 135 // Deserializes a list of PasswordForms from the wallet. |
119 // |size_32| controls reading the size field within the pickle as 32 bits. | 136 // |size_32| controls reading the size field within the pickle as 32 bits. |
120 // We used to use Pickle::WriteSize() to write the number of password forms, | 137 // We used to use Pickle::WriteSize() to write the number of password forms, |
(...skipping 25 matching lines...) Expand all Loading... |
146 | 163 |
147 // The name of the wallet we've opened. Set during Init(). | 164 // The name of the wallet we've opened. Set during Init(). |
148 std::string wallet_name_; | 165 std::string wallet_name_; |
149 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. | 166 // The application name (e.g. "Chromium"), shown in KWallet auth dialogs. |
150 const std::string app_name_; | 167 const std::string app_name_; |
151 | 168 |
152 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); | 169 DISALLOW_COPY_AND_ASSIGN(NativeBackendKWallet); |
153 }; | 170 }; |
154 | 171 |
155 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ | 172 #endif // CHROME_BROWSER_PASSWORD_MANAGER_NATIVE_BACKEND_KWALLET_X_H_ |
OLD | NEW |