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

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

Issue 1548133002: Switch to standard integer types in chrome/browser/, part 3 of 4. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 12 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // windows.h must be first otherwise Win8 SDK breaks. 5 // windows.h must be first otherwise Win8 SDK breaks.
6 #include <windows.h> 6 #include <windows.h>
7 #include <LM.h> 7 #include <LM.h>
8 #include <stddef.h>
9 #include <stdint.h>
8 #include <wincred.h> 10 #include <wincred.h>
9 11
10 // SECURITY_WIN32 must be defined in order to get 12 // SECURITY_WIN32 must be defined in order to get
11 // EXTENDED_NAME_FORMAT enumeration. 13 // EXTENDED_NAME_FORMAT enumeration.
12 #define SECURITY_WIN32 1 14 #define SECURITY_WIN32 1
13 #include <security.h> 15 #include <security.h>
14 #undef SECURITY_WIN32 16 #undef SECURITY_WIN32
15 17
16 #include "chrome/browser/password_manager/password_manager_util_win.h" 18 #include "chrome/browser/password_manager/password_manager_util_win.h"
17 19
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 CREDUI_FLAGS_KEEP_USERNAME | 60 CREDUI_FLAGS_KEEP_USERNAME |
59 CREDUI_FLAGS_ALWAYS_SHOW_UI | 61 CREDUI_FLAGS_ALWAYS_SHOW_UI |
60 CREDUI_FLAGS_DO_NOT_PERSIST; 62 CREDUI_FLAGS_DO_NOT_PERSIST;
61 63
62 struct PasswordCheckPrefs { 64 struct PasswordCheckPrefs {
63 PasswordCheckPrefs() : pref_last_changed_(0), blank_password_(false) {} 65 PasswordCheckPrefs() : pref_last_changed_(0), blank_password_(false) {}
64 66
65 void Read(PrefService* local_state); 67 void Read(PrefService* local_state);
66 void Write(PrefService* local_state); 68 void Write(PrefService* local_state);
67 69
68 int64 pref_last_changed_; 70 int64_t pref_last_changed_;
69 bool blank_password_; 71 bool blank_password_;
70 }; 72 };
71 73
72 void PasswordCheckPrefs::Read(PrefService* local_state) { 74 void PasswordCheckPrefs::Read(PrefService* local_state) {
73 blank_password_ = 75 blank_password_ =
74 local_state->GetBoolean(password_manager::prefs::kOsPasswordBlank); 76 local_state->GetBoolean(password_manager::prefs::kOsPasswordBlank);
75 pref_last_changed_ = 77 pref_last_changed_ =
76 local_state->GetInt64(password_manager::prefs::kOsPasswordLastChanged); 78 local_state->GetInt64(password_manager::prefs::kOsPasswordLastChanged);
77 } 79 }
78 80
79 void PasswordCheckPrefs::Write(PrefService* local_state) { 81 void PasswordCheckPrefs::Write(PrefService* local_state) {
80 local_state->SetBoolean(password_manager::prefs::kOsPasswordBlank, 82 local_state->SetBoolean(password_manager::prefs::kOsPasswordBlank,
81 blank_password_); 83 blank_password_);
82 local_state->SetInt64(password_manager::prefs::kOsPasswordLastChanged, 84 local_state->SetInt64(password_manager::prefs::kOsPasswordLastChanged,
83 pref_last_changed_); 85 pref_last_changed_);
84 } 86 }
85 87
86 int64 GetPasswordLastChanged(const WCHAR* username) { 88 int64_t GetPasswordLastChanged(const WCHAR* username) {
87 LPUSER_INFO_1 user_info = NULL; 89 LPUSER_INFO_1 user_info = NULL;
88 DWORD age = 0; 90 DWORD age = 0;
89 91
90 NET_API_STATUS ret = NetUserGetInfo(NULL, username, 1, (LPBYTE*) &user_info); 92 NET_API_STATUS ret = NetUserGetInfo(NULL, username, 1, (LPBYTE*) &user_info);
91 93
92 if (ret == NERR_Success) { 94 if (ret == NERR_Success) {
93 // Returns seconds since last password change. 95 // Returns seconds since last password change.
94 age = user_info->usri1_password_age; 96 age = user_info->usri1_password_age;
95 NetApiBufferFree(user_info); 97 NetApiBufferFree(user_info);
96 } else { 98 } else {
97 return -1; 99 return -1;
98 } 100 }
99 101
100 base::Time changed = base::Time::Now() - base::TimeDelta::FromSeconds(age); 102 base::Time changed = base::Time::Now() - base::TimeDelta::FromSeconds(age);
101 103
102 return changed.ToInternalValue(); 104 return changed.ToInternalValue();
103 } 105 }
104 106
105 bool CheckBlankPasswordWithPrefs(const WCHAR* username, 107 bool CheckBlankPasswordWithPrefs(const WCHAR* username,
106 PasswordCheckPrefs* prefs) { 108 PasswordCheckPrefs* prefs) {
107 int64 last_changed = GetPasswordLastChanged(username); 109 int64_t last_changed = GetPasswordLastChanged(username);
108 110
109 // If we cannot determine when the password was last changed 111 // If we cannot determine when the password was last changed
110 // then assume the password is not blank 112 // then assume the password is not blank
111 if (last_changed == -1) 113 if (last_changed == -1)
112 return false; 114 return false;
113 115
114 bool blank_password = prefs->blank_password_; 116 bool blank_password = prefs->blank_password_;
115 bool need_recheck = true; 117 bool need_recheck = true;
116 if (prefs->pref_last_changed_ > 0 && 118 if (prefs->pref_last_changed_ > 0 &&
117 last_changed <= prefs->pref_last_changed_) { 119 last_changed <= prefs->pref_last_changed_) {
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 } 319 }
318 } 320 }
319 SecureZeroMemory(password, sizeof(password)); 321 SecureZeroMemory(password, sizeof(password));
320 } 322 }
321 } while (credErr == NO_ERROR && 323 } while (credErr == NO_ERROR &&
322 (retval == false && tries < kMaxPasswordRetries)); 324 (retval == false && tries < kMaxPasswordRetries));
323 return retval; 325 return retval;
324 } 326 }
325 327
326 } // namespace password_manager_util_win 328 } // namespace password_manager_util_win
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/password_manager_util_mac.mm ('k') | chrome/browser/password_manager/password_store_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698