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

Unified Diff: chrome/browser/chromeos/policy/enterprise_install_attributes.cc

Issue 24869003: cryptohome: Move stateless wrapper functions out of CryptohomeLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address comments Created 7 years, 3 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/policy/enterprise_install_attributes.cc
diff --git a/chrome/browser/chromeos/policy/enterprise_install_attributes.cc b/chrome/browser/chromeos/policy/enterprise_install_attributes.cc
index 72318d32d9bf2ccc541bde96bcec6860e46d98cc..429d60f30b5e283784fedfec2294e857a7cb082c 100644
--- a/chrome/browser/chromeos/policy/enterprise_install_attributes.cc
+++ b/chrome/browser/chromeos/policy/enterprise_install_attributes.cc
@@ -18,6 +18,8 @@
namespace policy {
+namespace cryptohome_util = chromeos::cryptohome_util;
+
namespace {
// Translates DeviceMode constants to strings used in the lockbox.
@@ -88,11 +90,9 @@ const char EnterpriseInstallAttributes::kAttrConsumerKioskEnabled[] =
"consumer.app_kiosk_enabled";
EnterpriseInstallAttributes::EnterpriseInstallAttributes(
- chromeos::CryptohomeLibrary* cryptohome,
chromeos::CryptohomeClient* cryptohome_client)
: device_locked_(false),
registration_mode_(DEVICE_MODE_PENDING),
- cryptohome_(cryptohome),
cryptohome_client_(cryptohome_client),
weak_ptr_factory_(this) {}
@@ -152,8 +152,8 @@ void EnterpriseInstallAttributes::ReadAttributesIfReady(
bool result) {
if (call_status == chromeos::DBUS_METHOD_CALL_SUCCESS && result) {
registration_mode_ = DEVICE_MODE_NOT_SET;
- if (!cryptohome_->InstallAttributesIsInvalid() &&
- !cryptohome_->InstallAttributesIsFirstInstall()) {
+ if (!cryptohome_util::InstallAttributesIsInvalid() &&
+ !cryptohome_util::InstallAttributesIsFirstInstall()) {
device_locked_ = true;
static const char* kEnterpriseAttributes[] = {
@@ -167,7 +167,8 @@ void EnterpriseInstallAttributes::ReadAttributesIfReady(
std::map<std::string, std::string> attr_map;
for (size_t i = 0; i < arraysize(kEnterpriseAttributes); ++i) {
std::string value;
- if (cryptohome_->InstallAttributesGet(kEnterpriseAttributes[i], &value))
+ if (cryptohome_util::InstallAttributesGet(kEnterpriseAttributes[i],
+ &value))
attr_map[kEnterpriseAttributes[i]] = value;
}
@@ -222,20 +223,20 @@ void EnterpriseInstallAttributes::LockDeviceIfAttributesIsReady(
}
// Clearing the TPM password seems to be always a good deal.
- if (cryptohome_->TpmIsEnabled() &&
- !cryptohome_->TpmIsBeingOwned() &&
- cryptohome_->TpmIsOwned()) {
+ if (cryptohome_util::TpmIsEnabled() &&
+ !cryptohome_util::TpmIsBeingOwned() &&
+ cryptohome_util::TpmIsOwned()) {
cryptohome_client_->CallTpmClearStoredPasswordAndBlock();
}
// Make sure we really have a working InstallAttrs.
- if (cryptohome_->InstallAttributesIsInvalid()) {
+ if (cryptohome_util::InstallAttributesIsInvalid()) {
LOG(ERROR) << "Install attributes invalid.";
callback.Run(LOCK_BACKEND_ERROR);
return;
}
- if (!cryptohome_->InstallAttributesIsFirstInstall()) {
+ if (!cryptohome_util::InstallAttributesIsFirstInstall()) {
callback.Run(LOCK_WRONG_USER);
return;
}
@@ -247,7 +248,8 @@ void EnterpriseInstallAttributes::LockDeviceIfAttributesIsReady(
if (device_mode == DEVICE_MODE_CONSUMER_KIOSK) {
// Set values in the InstallAttrs and lock it.
- if (!cryptohome_->InstallAttributesSet(kAttrConsumerKioskEnabled, "true")) {
+ if (!cryptohome_util::InstallAttributesSet(kAttrConsumerKioskEnabled,
+ "true")) {
LOG(ERROR) << "Failed writing attributes";
callback.Run(LOCK_BACKEND_ERROR);
return;
@@ -255,21 +257,22 @@ void EnterpriseInstallAttributes::LockDeviceIfAttributesIsReady(
} else {
std::string domain = gaia::ExtractDomainName(registration_user);
// Set values in the InstallAttrs and lock it.
- if (!cryptohome_->InstallAttributesSet(kAttrEnterpriseOwned, "true") ||
- !cryptohome_->InstallAttributesSet(kAttrEnterpriseUser,
- registration_user) ||
- !cryptohome_->InstallAttributesSet(kAttrEnterpriseDomain, domain) ||
- !cryptohome_->InstallAttributesSet(kAttrEnterpriseMode, mode) ||
- !cryptohome_->InstallAttributesSet(kAttrEnterpriseDeviceId,
- device_id)) {
+ if (!cryptohome_util::InstallAttributesSet(kAttrEnterpriseOwned, "true") ||
+ !cryptohome_util::InstallAttributesSet(kAttrEnterpriseUser,
+ registration_user) ||
+ !cryptohome_util::InstallAttributesSet(kAttrEnterpriseDomain,
+ domain) ||
+ !cryptohome_util::InstallAttributesSet(kAttrEnterpriseMode, mode) ||
+ !cryptohome_util::InstallAttributesSet(kAttrEnterpriseDeviceId,
+ device_id)) {
LOG(ERROR) << "Failed writing attributes";
callback.Run(LOCK_BACKEND_ERROR);
return;
}
}
- if (!cryptohome_->InstallAttributesFinalize() ||
- cryptohome_->InstallAttributesIsFirstInstall()) {
+ if (!cryptohome_util::InstallAttributesFinalize() ||
+ cryptohome_util::InstallAttributesIsFirstInstall()) {
LOG(ERROR) << "Failed locking.";
callback.Run(LOCK_BACKEND_ERROR);
return;

Powered by Google App Engine
This is Rietveld 408576698