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

Unified Diff: chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc

Issue 729803002: Easy Sign-in: Use TPM RSA key to sign nonce in sign-in protocol (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: . Created 6 years 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/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc
diff --git a/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc
new file mode 100644
index 0000000000000000000000000000000000000000..999de10ea27acd388c0873b3de96ff4e653d5b2c
--- /dev/null
+++ b/chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.cc
@@ -0,0 +1,77 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager_factory.h"
+
+#include "base/memory/singleton.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/login/easy_unlock/easy_unlock_tpm_key_manager.h"
+#include "chrome/browser/chromeos/profiles/profile_helper.h"
+#include "chrome/browser/profiles/incognito_helpers.h"
+#include "chrome/browser/profiles/profile.h"
+#include "components/keyed_service/content/browser_context_dependency_manager.h"
+#include "components/user_manager/user.h"
+
+namespace {
+
+PrefService* GetLocalState() {
+ return g_browser_process ? g_browser_process->local_state() : NULL;
+}
+
+} // namespace
+
+// static
+EasyUnlockTpmKeyManagerFactory* EasyUnlockTpmKeyManagerFactory::GetInstance() {
+ return Singleton<EasyUnlockTpmKeyManagerFactory>::get();
+}
+
+// static
+EasyUnlockTpmKeyManager* EasyUnlockTpmKeyManagerFactory::Get(
+ content::BrowserContext* browser_context) {
+ return static_cast<EasyUnlockTpmKeyManager*>(
+ EasyUnlockTpmKeyManagerFactory::GetInstance()
+ ->GetServiceForBrowserContext(browser_context, true));
+}
+
+EasyUnlockTpmKeyManager* EasyUnlockTpmKeyManagerFactory::GetForUser(
+ const std::string& user_id) {
+ const user_manager::User* user =
+ user_manager::UserManager::Get()->FindUser(user_id);
+ if (!user)
+ return NULL;
+ Profile* profile = chromeos::ProfileHelper::Get()->GetProfileByUser(user);
+ if (!profile)
+ return NULL;
+ return EasyUnlockTpmKeyManagerFactory::Get(profile);
+}
+
+EasyUnlockTpmKeyManagerFactory::EasyUnlockTpmKeyManagerFactory()
+ : BrowserContextKeyedServiceFactory(
+ "EasyUnlockTpmKeyManager",
+ BrowserContextDependencyManager::GetInstance()) {
+}
+
+EasyUnlockTpmKeyManagerFactory::~EasyUnlockTpmKeyManagerFactory() {
+}
+
+KeyedService* EasyUnlockTpmKeyManagerFactory::BuildServiceInstanceFor(
+ content::BrowserContext* context) const {
+ Profile* profile = Profile::FromBrowserContext(context);
+ PrefService* user_prefs = NULL;
+ user_manager::User* user = NULL;
+ if (!chromeos::ProfileHelper::IsSigninProfile(profile)) {
+ user_prefs = profile->GetPrefs();
+ user = chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
+ }
+ return new EasyUnlockTpmKeyManager(
+ user ? user->email() : std::string(),
+ context,
+ user_prefs,
+ GetLocalState());
+}
+
+content::BrowserContext* EasyUnlockTpmKeyManagerFactory::GetBrowserContextToUse(
+ content::BrowserContext* context) const {
+ return chrome::GetBrowserContextRedirectedInIncognito(context);
+}

Powered by Google App Engine
This is Rietveld 408576698