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

Unified Diff: chrome/browser/password_manager/native_backend_libsecret.cc

Issue 895653002: Serialize date_created in PasswordStoreX properly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_libsecret_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/password_manager/native_backend_libsecret.cc
diff --git a/chrome/browser/password_manager/native_backend_libsecret.cc b/chrome/browser/password_manager/native_backend_libsecret.cc
index 7cc94af040e41ea046b524cb3a4758dfdc7e0aff..d5545c4a70a2072b656b288065ed6b94b708dd41 100644
--- a/chrome/browser/password_manager/native_backend_libsecret.cc
+++ b/chrome/browser/password_manager/native_backend_libsecret.cc
@@ -21,6 +21,7 @@ using base::UTF16ToUTF8;
namespace {
const char kEmptyString[] = "";
+const int kMaxPossibleTimeTValue = INT_MAX;
vabr (Chromium) 2015/02/02 17:01:18 What about std::numeric_limits<int>::max() ?
dvadym 2015/02/03 11:53:49 Done.
}
typeof(&::secret_password_store_sync)
@@ -164,7 +165,12 @@ scoped_ptr<PasswordForm> FormOutOfAttributes(GHashTable* attrs) {
bool date_ok = base::StringToInt64(
GetStringFromAttributes(attrs, "date_created"), &date_created);
DCHECK(date_ok);
- form->date_created = base::Time::FromTimeT(date_created);
+ // In past date_created was stored as time_t. We can distinguish between
+ // them by taking into consideration that INT_MAX correspond to
+ // 2038 year in time_t and internal values of base::Time are much bigger.
+ form->date_created = date_created < kMaxPossibleTimeTValue
+ ? base::Time::FromTimeT(date_created)
+ : base::Time::FromInternalValue(date_created);
form->blacklisted_by_user =
GetUintFromAttributes(attrs, "blacklisted_by_user");
form->type =
@@ -397,11 +403,11 @@ void NativeBackendLibsecret::AddUpdateLoginSearch(
}
bool NativeBackendLibsecret::RawAddLogin(const PasswordForm& form) {
- time_t date_created = form.date_created.ToTimeT();
+ int64 date_created = form.date_created.ToInternalValue();
// If we are asked to save a password with 0 date, use the current time.
- // We don't want to actually save passwords as though on January 1, 1970.
+ // We don't want to actually save passwords as though on January 1, 1601.
if (!date_created)
- date_created = time(nullptr);
+ date_created = base::Time::Now().ToInternalValue();
int64 date_synced = form.date_synced.ToInternalValue();
GError* error = nullptr;
secret_password_store_sync(
« no previous file with comments | « no previous file | chrome/browser/password_manager/native_backend_libsecret_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698