| Index: chrome/browser/signin/local_auth.cc
|
| diff --git a/chrome/browser/signin/local_auth.cc b/chrome/browser/signin/local_auth.cc
|
| index 55b955e25fd7a467bac1959d3637ea8ddec4ad32..14bf511dbca8937c73328ad6f8bc115992ce4911 100644
|
| --- a/chrome/browser/signin/local_auth.cc
|
| +++ b/chrome/browser/signin/local_auth.cc
|
| @@ -94,6 +94,14 @@ bool DecodePasswordHashRecord(const std::string& encoded,
|
| return OSCrypt::DecryptString(unbase64, decoded);
|
| }
|
|
|
| +size_t GetProfileInfoIndexOfProfile(const Profile* profile) {
|
| + DCHECK(profile);
|
| +
|
| + ProfileInfoCache& info =
|
| + g_browser_process->profile_manager()->GetProfileInfoCache();
|
| + return info.GetIndexOfProfileWithPath(profile->GetPath());
|
| +}
|
| +
|
| } // namespace
|
|
|
| namespace chrome {
|
| @@ -107,6 +115,10 @@ void RegisterLocalAuthPrefs(user_prefs::PrefRegistrySyncable* registry) {
|
|
|
| void SetLocalAuthCredentials(size_t info_index,
|
| const std::string& password) {
|
| + if (info_index == std::string::npos) {
|
| + NOTREACHED();
|
| + return;
|
| + }
|
| DCHECK(password.length());
|
|
|
| // Salt should be random data, as long as the hash length, and different with
|
| @@ -134,20 +146,16 @@ void SetLocalAuthCredentials(size_t info_index,
|
|
|
| void SetLocalAuthCredentials(const Profile* profile,
|
| const std::string& password) {
|
| - DCHECK(profile);
|
| + SetLocalAuthCredentials(GetProfileInfoIndexOfProfile(profile), password);
|
| +}
|
|
|
| - ProfileInfoCache& info =
|
| - g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - size_t info_index = info.GetIndexOfProfileWithPath(profile->GetPath());
|
| +bool ValidateLocalAuthCredentials(size_t info_index,
|
| + const std::string& password) {
|
| if (info_index == std::string::npos) {
|
| NOTREACHED();
|
| - return;
|
| + return false;
|
| }
|
| - SetLocalAuthCredentials(info_index, password);
|
| -}
|
|
|
| -bool ValidateLocalAuthCredentials(size_t info_index,
|
| - const std::string& password) {
|
| std::string record;
|
| char encoding;
|
|
|
| @@ -186,16 +194,27 @@ bool ValidateLocalAuthCredentials(size_t info_index,
|
|
|
| bool ValidateLocalAuthCredentials(const Profile* profile,
|
| const std::string& password) {
|
| - DCHECK(profile);
|
| + return ValidateLocalAuthCredentials(GetProfileInfoIndexOfProfile(profile),
|
| + password);
|
| +}
|
|
|
| - ProfileInfoCache& info =
|
| - g_browser_process->profile_manager()->GetProfileInfoCache();
|
| - size_t info_index = info.GetIndexOfProfileWithPath(profile->GetPath());
|
| - if (info_index == std::string::npos) {
|
| - NOTREACHED(); // This should never happen but fail safely if it does.
|
| +bool LocalAuthCredentialsExist(size_t profile_info_index) {
|
| + if (profile_info_index == std::string::npos) {
|
| + NOTREACHED();
|
| return false;
|
| }
|
| - return ValidateLocalAuthCredentials(info_index, password);
|
| +
|
| + ProfileInfoCache& info =
|
| + g_browser_process->profile_manager()->GetProfileInfoCache();
|
| +
|
| + std::string encodedhash =
|
| + info.GetLocalAuthCredentialsOfProfileAtIndex(profile_info_index);
|
| +
|
| + return !encodedhash.empty();
|
| +}
|
| +
|
| +bool LocalAuthCredentialsExist(const Profile* profile) {
|
| + return LocalAuthCredentialsExist(GetProfileInfoIndexOfProfile(profile));
|
| }
|
|
|
| } // namespace chrome
|
|
|