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

Unified Diff: chrome/browser/signin/local_auth.cc

Issue 497783002: Disable lock if no credentials are present (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Return [false] if profile_index = ::npos Created 6 years, 4 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 | « chrome/browser/signin/local_auth.h ('k') | chrome/browser/signin/local_auth_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « chrome/browser/signin/local_auth.h ('k') | chrome/browser/signin/local_auth_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698