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

Unified Diff: chrome/browser/chromeos/login/enterprise_enrollment_screen.cc

Issue 6821075: Chrome-side lockbox bindings (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: CL RC1. Created 9 years, 8 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/login/enterprise_enrollment_screen.cc
diff --git a/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc b/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc
index ec775dc7b4b8bfbb170becf21c8cabac17b4ec08..8df1dac1882490e189a084b9606c10068de08c65 100644
--- a/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc
+++ b/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc
@@ -6,15 +6,21 @@
#include "base/logging.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/cryptohome_library.h"
#include "chrome/browser/chromeos/login/screen_observer.h"
#include "chrome/browser/policy/browser_policy_connector.h"
#include "chrome/common/net/gaia/gaia_constants.h"
namespace chromeos {
+// Retry for lockbox initialization every 500ms.
+const int kLockboxRetryIntervalMs = 500;
+
EnterpriseEnrollmentScreen::EnterpriseEnrollmentScreen(
WizardScreenDelegate* delegate)
- : ViewScreen<EnterpriseEnrollmentView>(delegate) {}
+ : ViewScreen<EnterpriseEnrollmentView>(delegate),
+ ALLOW_THIS_IN_INITIALIZER_LIST(runnable_method_factory_(this)) {}
EnterpriseEnrollmentScreen::~EnterpriseEnrollmentScreen() {}
@@ -57,8 +63,7 @@ void EnterpriseEnrollmentScreen::CloseConfirmation() {
void EnterpriseEnrollmentScreen::OnClientLoginSuccess(
const ClientLoginResult& result) {
- auth_fetcher_->StartIssueAuthToken(result.sid, result.lsid,
- GaiaConstants::kDeviceManagementService);
+ WriteLockboxData(result);
}
void EnterpriseEnrollmentScreen::OnClientLoginFailure(
@@ -177,4 +182,43 @@ void EnterpriseEnrollmentScreen::HandleAuthError(
NOTREACHED() << error.state();
}
+void EnterpriseEnrollmentScreen::WriteLockboxData(
+ const ClientLoginResult& result) {
+ // Since this method is also called directly.
+ runnable_method_factory_.RevokeAll();
+
+ chromeos::CryptohomeLibrary* cryptohome =
+ chromeos::CrosLibrary::Get()->GetCryptohomeLibrary();
+ if (!cryptohome->InstallAttributesIsReady()) {
+ // Lockbox is not read yet, reschedule pulling.
+ LOG(WARNING) << "Lockbox is not ready yet will retry in "
+ << kLockboxRetryIntervalMs << "ms.";
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ runnable_method_factory_.NewRunnableMethod(
+ &EnterpriseEnrollmentScreen::WriteLockboxData, result),
+ kLockboxRetryIntervalMs);
+ } else {
+ // Set values in the lockbox and lock it.
+ if (!cryptohome->InstallAttributesIsFirstInstall()) {
+ LOG(ERROR) << "Enrollment can not proceed because the lockbox "
+ << "has been altered already!";
+ view()->ShowFatalEnrollmentError();
+ }
+ DCHECK(cryptohome->InstallAttributesIsFirstInstall());
+ cryptohome->InstallAttributesSet("enterprise.owned", "true");
+ cryptohome->InstallAttributesSet("enterprise.user", user_);
+ DCHECK(cryptohome->InstallAttributesCount() == 2);
+ cryptohome->InstallAttributesFinalize();
+ if (cryptohome->InstallAttributesIsFirstInstall()) {
+ LOG(ERROR) << "Enrollment can not proceed because the lockbox "
+ << "can not be sealed!";
+ view()->ShowFatalEnrollmentError();
+ } else {
+ auth_fetcher_->StartIssueAuthToken(
+ result.sid, result.lsid, GaiaConstants::kDeviceManagementService);
+ }
+ }
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698