Chromium Code Reviews| Index: chrome/browser/password_manager/native_backend_gnome_x.cc |
| diff --git a/chrome/browser/password_manager/native_backend_gnome_x.cc b/chrome/browser/password_manager/native_backend_gnome_x.cc |
| index b3571d6b3384b2b690b2987418427bb155dae96d..38df7dd1c5aa39c10243366c112c13b73c774e99 100644 |
| --- a/chrome/browser/password_manager/native_backend_gnome_x.cc |
| +++ b/chrome/browser/password_manager/native_backend_gnome_x.cc |
| @@ -31,6 +31,10 @@ using base::UTF8ToUTF16; |
| using base::UTF16ToUTF8; |
| using content::BrowserThread; |
| +namespace { |
| +const int kMaxPossibleTimeTValue = std::numeric_limits<int>::max(); |
| +} |
| + |
| #define GNOME_KEYRING_DEFINE_POINTER(name) \ |
| typeof(&::gnome_keyring_##name) GnomeKeyringLoader::gnome_keyring_##name; |
| GNOME_KEYRING_FOR_EACH_FUNC(GNOME_KEYRING_DEFINE_POINTER) |
| @@ -131,7 +135,12 @@ scoped_ptr<PasswordForm> FormFromAttributes(GnomeKeyringAttributeList* attrs) { |
| bool date_ok = base::StringToInt64(string_attr_map["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 |
|
vabr (Chromium)
2015/02/03 16:06:42
nit: INT_MAX -> kMaxPossibleTimeTValue
(Also for l
dvadym
2015/02/04 10:40:25
Done.
|
| + // 2038 year in time_t and internal values of base::Time are much bigger. |
|
vabr (Chromium)
2015/02/03 16:06:42
Perhaps you could explain more clearly:
In the pas
dvadym
2015/02/04 10:40:25
Done.
|
| + form->date_created = date_created < kMaxPossibleTimeTValue |
|
vabr (Chromium)
2015/02/03 16:06:42
I suggest pulling this check and kMaxPossibleTimeT
dvadym
2015/02/04 10:40:25
Keyring backend will finally disappear, so after o
|
| + ? base::Time::FromTimeT(date_created) |
| + : base::Time::FromInternalValue(date_created); |
| form->blacklisted_by_user = uint_attr_map["blacklisted_by_user"]; |
| form->type = static_cast<PasswordForm::Type>(uint_attr_map["type"]); |
| form->times_used = uint_attr_map["times_used"]; |
| @@ -317,11 +326,11 @@ class GKRMethod : public GnomeKeyringLoader { |
| void GKRMethod::AddLogin(const PasswordForm& form, const char* app_string) { |
| DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| - 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(NULL); |
| + date_created = base::Time::Now().ToInternalValue(); |
| int64 date_synced = form.date_synced.ToInternalValue(); |
| gnome_keyring_store_password( |
| &kGnomeSchema, |