Chromium Code Reviews| 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 6d66eecaaacecd8af7818a571cc3d88bd8577108..f5a15fbf8a9fcc53dd196fbfbffb12388bf90735 100644 |
| --- a/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc |
| +++ b/chrome/browser/chromeos/login/enterprise_enrollment_screen.cc |
| @@ -4,11 +4,19 @@ |
| #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" |
| +#include "base/compiler_specific.h" |
| #include "base/logging.h" |
| #include "chrome/browser/browser_process.h" |
| +#include "chrome/browser/chromeos/cros/cros_library.h" |
| +#include "chrome/browser/chromeos/cros/system_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" |
| +// MachineInfo key names. |
| +const char kMachineInfoSystemHwqual[] = "hardware_class"; |
| +const char kMachineInfoSerialNumber[] = "serial_number"; |
| + |
| namespace chromeos { |
| EnterpriseEnrollmentScreen::EnterpriseEnrollmentScreen( |
| @@ -22,6 +30,7 @@ void EnterpriseEnrollmentScreen::Authenticate(const std::string& user, |
| const std::string& captcha, |
| const std::string& access_code) { |
| captcha_token_.clear(); |
| + user_ = user; |
| auth_fetcher_.reset( |
| new GaiaAuthFetcher(this, GaiaConstants::kChromeSource, |
| g_browser_process->system_request_context())); |
| @@ -51,10 +60,6 @@ void EnterpriseEnrollmentScreen::CloseConfirmation() { |
| observer->OnExit(ScreenObserver::ENTERPRISE_ENROLLMENT_COMPLETED); |
| } |
| -EnterpriseEnrollmentView* EnterpriseEnrollmentScreen::AllocateView() { |
| - return new EnterpriseEnrollmentView(this); |
| -} |
| - |
| void EnterpriseEnrollmentScreen::OnClientLoginSuccess( |
| const ClientLoginResult& result) { |
| auth_fetcher_->StartIssueAuthToken(result.sid, result.lsid, |
| @@ -74,12 +79,23 @@ void EnterpriseEnrollmentScreen::OnIssueAuthTokenSuccess( |
| return; |
| } |
| - auth_fetcher_.reset(); |
| + scoped_ptr<GaiaAuthFetcher> auth_fetcher(auth_fetcher_.release()); |
| - // TODO(mnissler): Trigger actual enrollment here! |
| + policy::BrowserPolicyConnector* connector = |
| + g_browser_process->browser_policy_connector(); |
| + if (!connector->cloud_policy_subsystem()) { |
| + NOTREACHED() << "Cloud policy subsystem not initialized."; |
| + if (view()) |
| + view()->ShowFatalEnrollmentError(); |
| + return; |
| + } |
| + |
| + registrar_.reset(new policy::CloudPolicySubsystem::ObserverRegistrar( |
| + connector->cloud_policy_subsystem(), this)); |
| - if (view()) |
| - view()->ShowConfirmationScreen(); |
| + // Push the credentials to the policy infrastructure. It'll start enrollment |
| + // and notify us of progress through CloudPolicySubsystem::Observer. |
| + connector->SetCredentials(user_, auth_token, GetMachineId()); |
|
Nikita (slow)
2011/04/12 12:46:22
Is this process somehow shown to user, like spinne
Mattias Nissler (ping if slow)
2011/04/12 14:07:15
It's just the login spinner on the GAIA login box,
|
| } |
| void EnterpriseEnrollmentScreen::OnIssueAuthTokenFailure( |
| @@ -93,6 +109,46 @@ void EnterpriseEnrollmentScreen::OnIssueAuthTokenFailure( |
| HandleAuthError(error); |
| } |
| +void EnterpriseEnrollmentScreen::OnPolicyStateChanged( |
| + policy::CloudPolicySubsystem::PolicySubsystemState state, |
| + policy::CloudPolicySubsystem::ErrorDetails error_details) { |
| + |
| + if (view()) { |
| + switch (state) { |
| + case policy::CloudPolicySubsystem::UNENROLLED: |
| + // Still working... |
| + return; |
| + case policy::CloudPolicySubsystem::BAD_GAIA_TOKEN: |
| + case policy::CloudPolicySubsystem::LOCAL_ERROR: |
| + view()->ShowFatalEnrollmentError(); |
| + break; |
| + case policy::CloudPolicySubsystem::UNMANAGED: |
| + view()->ShowAccountError(); |
| + break; |
| + case policy::CloudPolicySubsystem::NETWORK_ERROR: |
| + view()->ShowNetworkEnrollmentError(); |
| + break; |
| + case policy::CloudPolicySubsystem::SUCCESS: |
| + // Success! |
| + registrar_.reset(); |
| + view()->ShowConfirmationScreen(); |
| + return; |
| + } |
| + |
| + // We have an error. |
| + LOG(WARNING) << "Policy subsystem error during enrollment: " << state |
| + << " details: " << error_details; |
| + } |
| + |
| + // Stop the policy infrastructure. |
| + registrar_.reset(); |
| + g_browser_process->browser_policy_connector()->StopAutoRetry(); |
| +} |
| + |
| +EnterpriseEnrollmentView* EnterpriseEnrollmentScreen::AllocateView() { |
| + return new EnterpriseEnrollmentView(this); |
| +} |
| + |
| void EnterpriseEnrollmentScreen::HandleAuthError( |
| const GoogleServiceAuthError& error) { |
| scoped_ptr<GaiaAuthFetcher> scoped_killer(auth_fetcher_.release()); |
| @@ -126,4 +182,19 @@ void EnterpriseEnrollmentScreen::HandleAuthError( |
| NOTREACHED() << error.state(); |
| } |
| +std::string EnterpriseEnrollmentScreen::GetMachineId() { |
| + chromeos::SystemLibrary* sys_lib = |
| + chromeos::CrosLibrary::Get()->GetSystemLibrary(); |
| + |
| + std::string system_hwqual; |
| + std::string serial_number; |
| + if (!sys_lib->GetMachineStatistic(kMachineInfoSystemHwqual, &system_hwqual) || |
|
Nikita (slow)
2011/04/12 12:46:22
Just FYI, this information is only accessible duri
Mattias Nissler (ping if slow)
2011/04/12 14:07:15
That's fine, since we can only enroll if the devic
|
| + !sys_lib->GetMachineStatistic(kMachineInfoSerialNumber, &serial_number)) { |
| + LOG(ERROR) << "Failed to get machine information"; |
| + return ""; |
| + } |
| + |
| + return system_hwqual + " " + serial_number; |
| +} |
| + |
| } // namespace chromeos |