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

Side by Side Diff: chrome/browser/password_manager/native_backend_gnome_x.cc

Issue 316243002: Add date_synced to PasswordForm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: +comment Created 6 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
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_gnome_x_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "chrome/browser/password_manager/native_backend_gnome_x.h" 5 #include "chrome/browser/password_manager/native_backend_gnome_x.h"
6 6
7 #include <dlfcn.h> 7 #include <dlfcn.h>
8 #include <gnome-keyring.h> 8 #include <gnome-keyring.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 form->preferred = uint_attr_map["preferred"]; 130 form->preferred = uint_attr_map["preferred"];
131 int64 date_created = 0; 131 int64 date_created = 0;
132 bool date_ok = base::StringToInt64(string_attr_map["date_created"], 132 bool date_ok = base::StringToInt64(string_attr_map["date_created"],
133 &date_created); 133 &date_created);
134 DCHECK(date_ok); 134 DCHECK(date_ok);
135 form->date_created = base::Time::FromTimeT(date_created); 135 form->date_created = base::Time::FromTimeT(date_created);
136 form->blacklisted_by_user = uint_attr_map["blacklisted_by_user"]; 136 form->blacklisted_by_user = uint_attr_map["blacklisted_by_user"];
137 form->type = static_cast<PasswordForm::Type>(uint_attr_map["type"]); 137 form->type = static_cast<PasswordForm::Type>(uint_attr_map["type"]);
138 form->times_used = uint_attr_map["times_used"]; 138 form->times_used = uint_attr_map["times_used"];
139 form->scheme = static_cast<PasswordForm::Scheme>(uint_attr_map["scheme"]); 139 form->scheme = static_cast<PasswordForm::Scheme>(uint_attr_map["scheme"]);
140 int64 date_synced = 0;
141 base::StringToInt64(string_attr_map["date_synced"], &date_synced);
142 form->date_synced = base::Time::FromInternalValue(date_synced);
140 143
141 return form.Pass(); 144 return form.Pass();
142 } 145 }
143 146
144 // Parse all the results from the given GList into a PasswordFormList, and free 147 // Parse all the results from the given GList into a PasswordFormList, and free
145 // the GList. PasswordForms are allocated on the heap, and should be deleted by 148 // the GList. PasswordForms are allocated on the heap, and should be deleted by
146 // the consumer. If not NULL, |lookup_form| is used to filter out results -- 149 // the consumer. If not NULL, |lookup_form| is used to filter out results --
147 // only credentials with signon realms passing the PSL matching (done by 150 // only credentials with signon realms passing the PSL matching (done by
148 // |helper|) against |lookup_form->signon_realm| will be kept. PSL matched 151 // |helper|) against |lookup_form->signon_realm| will be kept. PSL matched
149 // results get their signon_realm, origin, and action rewritten to those of 152 // results get their signon_realm, origin, and action rewritten to those of
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 { "password_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 214 { "password_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
212 { "submit_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 215 { "submit_element", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
213 { "signon_realm", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 216 { "signon_realm", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
214 { "ssl_valid", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, 217 { "ssl_valid", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
215 { "preferred", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, 218 { "preferred", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
216 { "date_created", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 219 { "date_created", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
217 { "blacklisted_by_user", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, 220 { "blacklisted_by_user", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
218 { "scheme", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, 221 { "scheme", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
219 { "type", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, 222 { "type", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
220 { "times_used", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 }, 223 { "times_used", GNOME_KEYRING_ATTRIBUTE_TYPE_UINT32 },
224 { "date_synced", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
221 // This field is always "chrome" so that we can search for it. 225 // This field is always "chrome" so that we can search for it.
222 { "application", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING }, 226 { "application", GNOME_KEYRING_ATTRIBUTE_TYPE_STRING },
223 { NULL } 227 { NULL }
224 } 228 }
225 }; 229 };
226 230
227 // Sadly, PasswordStore goes to great lengths to switch from the originally 231 // Sadly, PasswordStore goes to great lengths to switch from the originally
228 // calling thread to the DB thread, and to provide an asynchronous API to 232 // calling thread to the DB thread, and to provide an asynchronous API to
229 // callers while using a synchronous (virtual) API provided by subclasses like 233 // callers while using a synchronous (virtual) API provided by subclasses like
230 // PasswordStoreX -- but GNOME Keyring really wants to be on the GLib main 234 // PasswordStoreX -- but GNOME Keyring really wants to be on the GLib main
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 const PSLMatchingHelper helper_; 309 const PSLMatchingHelper helper_;
306 }; 310 };
307 311
308 void GKRMethod::AddLogin(const PasswordForm& form, const char* app_string) { 312 void GKRMethod::AddLogin(const PasswordForm& form, const char* app_string) {
309 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 313 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
310 time_t date_created = form.date_created.ToTimeT(); 314 time_t date_created = form.date_created.ToTimeT();
311 // If we are asked to save a password with 0 date, use the current time. 315 // If we are asked to save a password with 0 date, use the current time.
312 // We don't want to actually save passwords as though on January 1, 1970. 316 // We don't want to actually save passwords as though on January 1, 1970.
313 if (!date_created) 317 if (!date_created)
314 date_created = time(NULL); 318 date_created = time(NULL);
319 int64 date_synced = form.date_synced.ToInternalValue();
315 gnome_keyring_store_password( 320 gnome_keyring_store_password(
316 &kGnomeSchema, 321 &kGnomeSchema,
317 NULL, // Default keyring. 322 NULL, // Default keyring.
318 form.origin.spec().c_str(), // Display name. 323 form.origin.spec().c_str(), // Display name.
319 UTF16ToUTF8(form.password_value).c_str(), 324 UTF16ToUTF8(form.password_value).c_str(),
320 OnOperationDone, 325 OnOperationDone,
321 this, // data 326 this, // data
322 NULL, // destroy_data 327 NULL, // destroy_data
323 "origin_url", form.origin.spec().c_str(), 328 "origin_url", form.origin.spec().c_str(),
324 "action_url", form.action.spec().c_str(), 329 "action_url", form.action.spec().c_str(),
325 "username_element", UTF16ToUTF8(form.username_element).c_str(), 330 "username_element", UTF16ToUTF8(form.username_element).c_str(),
326 "username_value", UTF16ToUTF8(form.username_value).c_str(), 331 "username_value", UTF16ToUTF8(form.username_value).c_str(),
327 "password_element", UTF16ToUTF8(form.password_element).c_str(), 332 "password_element", UTF16ToUTF8(form.password_element).c_str(),
328 "submit_element", UTF16ToUTF8(form.submit_element).c_str(), 333 "submit_element", UTF16ToUTF8(form.submit_element).c_str(),
329 "signon_realm", form.signon_realm.c_str(), 334 "signon_realm", form.signon_realm.c_str(),
330 "ssl_valid", form.ssl_valid, 335 "ssl_valid", form.ssl_valid,
331 "preferred", form.preferred, 336 "preferred", form.preferred,
332 "date_created", base::Int64ToString(date_created).c_str(), 337 "date_created", base::Int64ToString(date_created).c_str(),
333 "blacklisted_by_user", form.blacklisted_by_user, 338 "blacklisted_by_user", form.blacklisted_by_user,
334 "type", form.type, 339 "type", form.type,
335 "times_used", form.times_used, 340 "times_used", form.times_used,
336 "scheme", form.scheme, 341 "scheme", form.scheme,
342 "date_synced", base::Int64ToString(date_synced).c_str(),
337 "application", app_string, 343 "application", app_string,
338 NULL); 344 NULL);
339 } 345 }
340 346
341 void GKRMethod::AddLoginSearch(const PasswordForm& form, 347 void GKRMethod::AddLoginSearch(const PasswordForm& form,
342 const char* app_string) { 348 const char* app_string) {
343 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 349 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
344 lookup_form_.reset(NULL); 350 lookup_form_.reset(NULL);
345 // Search GNOME Keyring for matching passwords to update. 351 // Search GNOME Keyring for matching passwords to update.
346 ScopedAttributeList attrs(gnome_keyring_attribute_list_new()); 352 ScopedAttributeList attrs(gnome_keyring_attribute_list_new());
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 } 752 }
747 return true; 753 return true;
748 } 754 }
749 755
750 std::string NativeBackendGnome::GetProfileSpecificAppString() const { 756 std::string NativeBackendGnome::GetProfileSpecificAppString() const {
751 // Originally, the application string was always just "chrome" and used only 757 // Originally, the application string was always just "chrome" and used only
752 // so that we had *something* to search for since GNOME Keyring won't search 758 // so that we had *something* to search for since GNOME Keyring won't search
753 // for nothing. Now we use it to distinguish passwords for different profiles. 759 // for nothing. Now we use it to distinguish passwords for different profiles.
754 return base::StringPrintf("%s-%d", kGnomeKeyringAppString, profile_id_); 760 return base::StringPrintf("%s-%d", kGnomeKeyringAppString, profile_id_);
755 } 761 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_gnome_x_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698