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

Unified Diff: chrome/browser/chromeos/ownership/owner_settings_service.cc

Issue 317613004: Remove usage of singleton software_slot_ in nss on ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 5 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
Index: chrome/browser/chromeos/ownership/owner_settings_service.cc
diff --git a/chrome/browser/chromeos/ownership/owner_settings_service.cc b/chrome/browser/chromeos/ownership/owner_settings_service.cc
index cf08b95a1d39f0b2c8d165874f4c3e87216ac83b..81724dfb887ed1dcf76482b5f17df6cd3b9f366d 100644
--- a/chrome/browser/chromeos/ownership/owner_settings_service.cc
+++ b/chrome/browser/chromeos/ownership/owner_settings_service.cc
@@ -7,6 +7,7 @@
#include <string>
#include "base/bind.h"
+#include "base/bind_helpers.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/chromeos/login/users/user.h"
#include "chrome/browser/chromeos/login/users/user_manager.h"
@@ -102,7 +103,7 @@ void LoadPrivateKey(
}
}
-bool IsPrivateKeyExistAsyncHelper(
+bool DoesPrivateKeyExistAsyncHelper(
const scoped_refptr<OwnerKeyUtil>& owner_key_util) {
std::vector<uint8> public_key;
if (!owner_key_util->ImportPublicKey(&public_key))
@@ -113,6 +114,26 @@ bool IsPrivateKeyExistAsyncHelper(
return is_owner;
}
+// Checks whether NSS slots with private key are mounted or
+// not. Responds via |callback|.
+void DoesPrivateKeyExistAsync(
+ const OwnerSettingsService::IsOwnerCallback& callback) {
+ scoped_refptr<OwnerKeyUtil> owner_key_util;
+ if (g_owner_key_util_for_testing)
+ owner_key_util = *g_owner_key_util_for_testing;
+ else
+ owner_key_util = OwnerKeyUtil::Create();
+ scoped_refptr<base::TaskRunner> task_runner =
+ content::BrowserThread::GetBlockingPool()
+ ->GetTaskRunnerWithShutdownBehavior(
+ base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
+ base::PostTaskAndReplyWithResult(
+ task_runner.get(),
+ FROM_HERE,
+ base::Bind(&DoesPrivateKeyExistAsyncHelper, owner_key_util),
+ callback);
+}
+
} // namespace
OwnerSettingsService::OwnerSettingsService(Profile* profile)
@@ -197,22 +218,22 @@ void OwnerSettingsService::OnTPMTokenReady() {
}
// static
-void OwnerSettingsService::IsPrivateKeyExistAsync(
+void OwnerSettingsService::IsOwnerForSafeModeAsync(
+ const std::string& user_id,
+ const std::string& user_hash,
const IsOwnerCallback& callback) {
- scoped_refptr<OwnerKeyUtil> owner_key_util;
- if (g_owner_key_util_for_testing)
- owner_key_util = *g_owner_key_util_for_testing;
- else
- owner_key_util = OwnerKeyUtil::Create();
- scoped_refptr<base::TaskRunner> task_runner =
- content::BrowserThread::GetBlockingPool()
- ->GetTaskRunnerWithShutdownBehavior(
- base::SequencedWorkerPool::SKIP_ON_SHUTDOWN);
- base::PostTaskAndReplyWithResult(
- task_runner.get(),
+ CHECK(chromeos::LoginState::Get()->IsInSafeMode());
+
+ // Make sure NSS is initialized and NSS DB is loaded for the user before
+ // searching for the owner key.
+ BrowserThread::PostTaskAndReply(
+ BrowserThread::IO,
FROM_HERE,
- base::Bind(&IsPrivateKeyExistAsyncHelper, owner_key_util),
- callback);
+ base::Bind(base::IgnoreResult(&crypto::InitializeNSSForChromeOSUser),
+ user_id,
+ user_hash,
+ ProfileHelper::GetProfilePathByUserIdHash(user_hash)),
+ base::Bind(&DoesPrivateKeyExistAsync, callback));
}
// static
« no previous file with comments | « chrome/browser/chromeos/ownership/owner_settings_service.h ('k') | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698