Chromium Code Reviews| Index: chrome/browser/chromeos/login/enrollment/enrollment_screen.cc |
| diff --git a/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc b/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc |
| index 27ba9d452dc876a75972cfa3b1fb2b10ef97c47e..8096060e73bbf717b25d4862e7e60f28502c1cb4 100644 |
| --- a/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc |
| +++ b/chrome/browser/chromeos/login/enrollment/enrollment_screen.cc |
| @@ -24,10 +24,13 @@ |
| #include "chromeos/dbus/dbus_method_call_status.h" |
| #include "chromeos/dbus/dbus_thread_manager.h" |
| #include "chromeos/dbus/session_manager_client.h" |
| +#include "components/pairing/controller_pairing_controller.h" |
| #include "google_apis/gaia/gaia_auth_util.h" |
| #include "google_apis/gaia/google_service_auth_error.h" |
| #include "policy/proto/device_management_backend.pb.h" |
| +using namespace pairing_chromeos; |
| + |
| namespace chromeos { |
| // static |
| @@ -40,6 +43,8 @@ EnrollmentScreen::EnrollmentScreen( |
| ScreenObserver* observer, |
| EnrollmentScreenActor* actor) |
| : WizardScreen(observer), |
| + shark_controller_(NULL), |
| + remora_controller_(NULL), |
| actor_(actor), |
| enrollment_mode_(EnrollmentScreenActor::ENROLLMENT_MODE_MANUAL), |
| enrollment_failed_once_(false), |
| @@ -52,16 +57,28 @@ EnrollmentScreen::EnrollmentScreen( |
| EmptyVoidDBusMethodCallback()); |
| } |
| -EnrollmentScreen::~EnrollmentScreen() {} |
| +EnrollmentScreen::~EnrollmentScreen() { |
| + if (remora_controller_) { |
| + remora_controller_->RemoveObserver(this); |
| + } |
| +} |
| void EnrollmentScreen::SetParameters( |
| EnrollmentScreenActor::EnrollmentMode enrollment_mode, |
| const std::string& management_domain, |
| const std::string& user, |
| - const std::string& auth_token) { |
| + const std::string& auth_token, |
| + pairing_chromeos::ControllerPairingController* shark_controller, |
| + pairing_chromeos::HostPairingController* remora_controller) { |
| enrollment_mode_ = enrollment_mode; |
| user_ = user.empty() ? user : gaia::CanonicalizeEmail(user); |
| auth_token_ = auth_token; |
| + shark_controller_ = shark_controller; |
| + DCHECK(!remora_controller_); |
| + remora_controller_ = remora_controller; |
| + if (remora_controller_) { |
| + remora_controller_->AddObserver(this); |
| + } |
| actor_->SetParameters(this, enrollment_mode_, management_domain); |
| } |
| @@ -95,6 +112,47 @@ std::string EnrollmentScreen::GetName() const { |
| return WizardController::kEnrollmentScreenName; |
| } |
| +void EnrollmentScreen::PairingStageChanged(Stage new_stage) { |
| + switch (new_stage) { |
| + case HostPairingController::STAGE_NONE: |
| + case HostPairingController::STAGE_INITIALIZATION_ERROR: |
| + case HostPairingController::STAGE_WAITING_FOR_CONTROLLER: |
| + case HostPairingController::STAGE_WAITING_FOR_CONTROLLER_AFTER_UPDATE: |
| + case HostPairingController::STAGE_WAITING_FOR_CODE_CONFIRMATION: |
| + case HostPairingController::STAGE_UPDATING: |
| + case HostPairingController::STAGE_WAITING_FOR_CREDENTIALS: |
| + case HostPairingController::STAGE_ENROLLING: |
|
dzhioev (left Google)
2014/09/09 01:58:09
nit: you can replace all these cases with a single
Zachary Kuznia
2014/09/09 02:17:51
When switching on enums, I leave off the default c
|
| + NOTREACHED(); |
| + break; |
| + |
| + case HostPairingController::STAGE_ENROLLMENT_ERROR: |
| + case HostPairingController::STAGE_PAIRING_DONE: |
| + break; |
| + |
| + case HostPairingController::STAGE_FINISHED: { |
| + remora_controller_->RemoveObserver(this); |
| + remora_controller_ = NULL; |
| + get_screen_observer()->OnExit( |
| + WizardController::ENTERPRISE_AUTO_MAGIC_ENROLLMENT_COMPLETED); |
|
dzhioev (left Google)
2014/09/09 01:35:40
a) Why do you use ENTERPRISE_AUTO_MAGIC_ENROLLMENT
Zachary Kuznia
2014/09/09 02:17:51
a: I reused the exit code from elsewhere in this f
dzhioev (left Google)
2014/09/09 02:46:50
What do you see on host's screen after enrollment
Zachary Kuznia
2014/09/09 23:53:58
After enrollment, the host launches Hangouts.
ach
achuithb
2014/09/10 08:04:20
We can do this, or use ENTERPRISE_ENROLLMENT_COMPL
Zachary Kuznia
2014/09/10 15:57:25
Ok, I'll leave this as is for now. I've filed a b
|
| + break; |
| + } |
| + } |
| +} |
| + |
| +void EnrollmentScreen::ConfigureHost(bool accepted_eula, |
| + const std::string& lang, |
| + const std::string& timezone, |
| + bool send_reports, |
| + const std::string& keyboard_layout) { |
| + // Host configuration should already be complete. |
| + NOTREACHED(); |
| +} |
| + |
| +void EnrollmentScreen::EnrollHost(const std::string& auth_token) { |
| + // Enrollment should already be complete. |
| + NOTREACHED(); |
| +} |
| + |
| void EnrollmentScreen::OnLoginDone(const std::string& user) { |
| user_ = gaia::CanonicalizeEmail(user); |
| @@ -239,7 +297,9 @@ void EnrollmentScreen::RegisterForDevicePolicy(const std::string& token) { |
| } |
| void EnrollmentScreen::SendEnrollmentAuthToken(const std::string& token) { |
| - // TODO(achuith, zork): Send token via Bluetooth to remote device. |
| + // TODO(achuith, zork): Extract and send domain. |
| + if (shark_controller_) |
| + shark_controller_->OnAuthenticationDone("", token); |
| } |
| void EnrollmentScreen::ShowEnrollmentStatusOnSuccess( |
| @@ -257,6 +317,7 @@ void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { |
| status)); |
| UMA(is_auto_enrollment() ? policy::kMetricEnrollmentAutoOK |
| : policy::kMetricEnrollmentOK); |
| + remora_controller_->SetEnrollmentComplete(true); |
|
dzhioev (left Google)
2014/09/09 01:35:40
Why do you assume everywhere that |remora_controll
Zachary Kuznia
2014/09/09 02:17:50
That is a bad assumption on my part. Fixed.
|
| return; |
| case policy::EnrollmentStatus::STATUS_REGISTRATION_FAILED: |
| case policy::EnrollmentStatus::STATUS_POLICY_FETCH_FAILED: |
| @@ -331,6 +392,7 @@ void EnrollmentScreen::ReportEnrollmentStatus(policy::EnrollmentStatus status) { |
| break; |
| } |
| + remora_controller_->SetEnrollmentComplete(false); |
| enrollment_failed_once_ = true; |
| actor_->ShowEnrollmentStatus(status); |
| } |