OLD | NEW |
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> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 #include <wincred.h> | 10 #include <wincred.h> |
11 | 11 |
12 #include <memory> | 12 #include <memory> |
13 | 13 |
14 // SECURITY_WIN32 must be defined in order to get | 14 // SECURITY_WIN32 must be defined in order to get |
15 // EXTENDED_NAME_FORMAT enumeration. | 15 // EXTENDED_NAME_FORMAT enumeration. |
16 #define SECURITY_WIN32 1 | 16 #define SECURITY_WIN32 1 |
17 #include <security.h> | 17 #include <security.h> |
18 #undef SECURITY_WIN32 | 18 #undef SECURITY_WIN32 |
19 | 19 |
20 #include "chrome/browser/password_manager/password_manager_util_win.h" | 20 #include "chrome/browser/password_manager/password_manager_util_win.h" |
21 | 21 |
22 #include "base/bind.h" | 22 #include "base/bind.h" |
23 #include "base/bind_helpers.h" | 23 #include "base/bind_helpers.h" |
24 #include "base/metrics/histogram_macros.h" | 24 #include "base/metrics/histogram_macros.h" |
25 #include "base/strings/utf_string_conversions.h" | 25 #include "base/strings/utf_string_conversions.h" |
26 #include "base/task_scheduler/post_task.h" | 26 #include "base/task_scheduler/post_task.h" |
27 #include "base/time/time.h" | 27 #include "base/time/time.h" |
28 #include "base/win/windows_version.h" | |
29 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
30 #include "chrome/grit/chromium_strings.h" | 29 #include "chrome/grit/chromium_strings.h" |
31 #include "components/password_manager/core/browser/password_manager.h" | 30 #include "components/password_manager/core/browser/password_manager.h" |
32 #include "components/password_manager/core/common/password_manager_pref_names.h" | 31 #include "components/password_manager/core/common/password_manager_pref_names.h" |
33 #include "components/prefs/pref_service.h" | 32 #include "components/prefs/pref_service.h" |
34 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
35 #include "content/public/browser/render_view_host.h" | 34 #include "content/public/browser/render_view_host.h" |
36 #include "content/public/browser/render_widget_host_view.h" | 35 #include "content/public/browser/render_widget_host_view.h" |
37 #include "ui/aura/window.h" | 36 #include "ui/aura/window.h" |
38 #include "ui/aura/window_tree_host.h" | 37 #include "ui/aura/window_tree_host.h" |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 WCHAR username[CREDUI_MAX_USERNAME_LENGTH+1] = {}; | 170 WCHAR username[CREDUI_MAX_USERNAME_LENGTH+1] = {}; |
172 *status = PASSWORD_STATUS_UNKNOWN; | 171 *status = PASSWORD_STATUS_UNKNOWN; |
173 | 172 |
174 if (GetUserNameEx(NameUserPrincipal, username, &username_length)) { | 173 if (GetUserNameEx(NameUserPrincipal, username, &username_length)) { |
175 // If we are on a domain, it is almost certain that the password is not | 174 // If we are on a domain, it is almost certain that the password is not |
176 // blank, but we do not actively check any further than this to avoid any | 175 // blank, but we do not actively check any further than this to avoid any |
177 // failed login attempts hitting the domain controller. | 176 // failed login attempts hitting the domain controller. |
178 *status = PASSWORD_STATUS_WIN_DOMAIN; | 177 *status = PASSWORD_STATUS_WIN_DOMAIN; |
179 } else { | 178 } else { |
180 username_length = CREDUI_MAX_USERNAME_LENGTH; | 179 username_length = CREDUI_MAX_USERNAME_LENGTH; |
181 // CheckBlankPasswordWithPrefs() isn't safe to call on before Windows 7. | 180 if (GetUserName(username, &username_length)) { |
182 // http://crbug.com/345916 | |
183 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && | |
184 GetUserName(username, &username_length)) { | |
185 *status = CheckBlankPasswordWithPrefs(username, prefs) ? | 181 *status = CheckBlankPasswordWithPrefs(username, prefs) ? |
186 PASSWORD_STATUS_BLANK : | 182 PASSWORD_STATUS_BLANK : |
187 PASSWORD_STATUS_NONBLANK; | 183 PASSWORD_STATUS_NONBLANK; |
188 } | 184 } |
189 } | 185 } |
190 } | 186 } |
191 | 187 |
192 void ReplyOsPasswordStatus(std::unique_ptr<PasswordCheckPrefs> prefs, | 188 void ReplyOsPasswordStatus(std::unique_ptr<PasswordCheckPrefs> prefs, |
193 std::unique_ptr<OsPasswordStatus> status) { | 189 std::unique_ptr<OsPasswordStatus> status) { |
194 PrefService* local_state = g_browser_process->local_state(); | 190 PrefService* local_state = g_browser_process->local_state(); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
310 } | 306 } |
311 } | 307 } |
312 SecureZeroMemory(password, sizeof(password)); | 308 SecureZeroMemory(password, sizeof(password)); |
313 } | 309 } |
314 } while (credErr == NO_ERROR && | 310 } while (credErr == NO_ERROR && |
315 (retval == false && tries < kMaxPasswordRetries)); | 311 (retval == false && tries < kMaxPasswordRetries)); |
316 return retval; | 312 return retval; |
317 } | 313 } |
318 | 314 |
319 } // namespace password_manager_util_win | 315 } // namespace password_manager_util_win |
OLD | NEW |