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 {
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
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;
bool ValidateLocalAuthCredentials(const Profile* profile,
const std::string& password) {
- DCHECK(profile);
-
- 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.
- return false;
- }
- return ValidateLocalAuthCredentials(info_index, password);
+ return ValidateLocalAuthCredentials(GetProfileInfoIndexOfProfile(profile),
+ password);
}
} // namespace chrome