Chromium Code Reviews| Index: chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen.cc |
| diff --git a/chrome/browser/chromeos/login/enrollment/auto_enrollment_check_step.cc b/chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen.cc |
| similarity index 75% |
| rename from chrome/browser/chromeos/login/enrollment/auto_enrollment_check_step.cc |
| rename to chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen.cc |
| index 276e4053a420150a888ccbf50cc6ab49d778f6e9..4d94e52d50ec0b7762cd1a4ea7de05071399a850 100644 |
| --- a/chrome/browser/chromeos/login/enrollment/auto_enrollment_check_step.cc |
| +++ b/chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen.cc |
| @@ -2,33 +2,40 @@ |
| // 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/enrollment/auto_enrollment_check_step.h" |
| +#include "chrome/browser/chromeos/login/enrollment/auto_enrollment_check_screen.h" |
| #include "base/bind.h" |
| #include "base/bind_helpers.h" |
| #include "base/command_line.h" |
| #include "base/logging.h" |
| #include "chrome/browser/chromeos/login/screens/screen_observer.h" |
| +#include "chrome/browser/chromeos/login/wizard_controller.h" |
| #include "chromeos/chromeos_switches.h" |
| #include "chromeos/network/network_state.h" |
| #include "chromeos/network/network_state_handler.h" |
| namespace chromeos { |
| -AutoEnrollmentCheckStep::AutoEnrollmentCheckStep( |
| - ScreenObserver* screen_observer, |
| +AutoEnrollmentCheckScreen::AutoEnrollmentCheckScreen( |
| + ScreenObserver* observer, |
| + AutoEnrollmentCheckScreenActor* actor, |
| AutoEnrollmentController* auto_enrollment_controller) |
| - : screen_observer_(screen_observer), |
| + : WizardScreen(observer), |
| + actor_(actor), |
| auto_enrollment_controller_(auto_enrollment_controller), |
| captive_portal_status_( |
| NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN), |
| - auto_enrollment_state_(policy::AUTO_ENROLLMENT_STATE_IDLE) {} |
| + auto_enrollment_state_(policy::AUTO_ENROLLMENT_STATE_IDLE) { |
| + DCHECK(actor_); |
| + if (actor_) |
|
Mattias Nissler (ping if slow)
2014/05/19 19:25:51
indentation
pastarmovj
2014/05/20 13:50:08
Done.
|
| + actor_->SetDelegate(this); |
| +} |
| -AutoEnrollmentCheckStep::~AutoEnrollmentCheckStep() { |
| +AutoEnrollmentCheckScreen::~AutoEnrollmentCheckScreen() { |
| NetworkPortalDetector::Get()->RemoveObserver(this); |
| } |
| -void AutoEnrollmentCheckStep::Start() { |
| +void AutoEnrollmentCheckScreen::Start() { |
| if (AutoEnrollmentController::GetMode() != |
| AutoEnrollmentController::MODE_FORCED_RE_ENROLLMENT) { |
| SignalCompletion(); |
| @@ -40,8 +47,9 @@ void AutoEnrollmentCheckStep::Start() { |
| auto_enrollment_progress_subscription_ = |
| auto_enrollment_controller_->RegisterProgressCallback( |
| - base::Bind(&AutoEnrollmentCheckStep::OnAutoEnrollmentCheckProgressed, |
| - base::Unretained(this))); |
| + base::Bind( |
| + &AutoEnrollmentCheckScreen::OnAutoEnrollmentCheckProgressed, |
| + base::Unretained(this))); |
| auto_enrollment_state_ = auto_enrollment_controller_->state(); |
| // NB: AddAndFireObserver below call back into OnPortalDetectionCompleted. |
| @@ -51,18 +59,45 @@ void AutoEnrollmentCheckStep::Start() { |
| portal_detector->AddAndFireObserver(this); |
| } |
| -void AutoEnrollmentCheckStep::OnPortalDetectionCompleted( |
| +void AutoEnrollmentCheckScreen::PrepareToShow() { |
| +} |
| + |
| +void AutoEnrollmentCheckScreen::Show() { |
| + if (actor_) |
| + actor_->Show(); |
|
Mattias Nissler (ping if slow)
2014/05/19 19:25:51
I don't think we should even call actor_->Show() i
pastarmovj
2014/05/20 13:50:08
Done.
|
| + Start(); |
| +} |
| + |
| +void AutoEnrollmentCheckScreen::Hide() { |
| +} |
| + |
| +std::string AutoEnrollmentCheckScreen::GetName() const { |
| + return WizardController::kAutoEnrollmentCheckScreenName; |
| +} |
| + |
| +void AutoEnrollmentCheckScreen::OnExit() { |
| + get_screen_observer()->OnExit( |
| + ScreenObserver::ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED); |
| +} |
| + |
| +void AutoEnrollmentCheckScreen::OnActorDestroyed( |
| + AutoEnrollmentCheckScreenActor* actor) { |
| + if (actor_ == actor) |
| + actor_ = NULL; |
| +} |
| + |
| +void AutoEnrollmentCheckScreen::OnPortalDetectionCompleted( |
| const NetworkState* /* network */, |
| const NetworkPortalDetector::CaptivePortalState& state) { |
| UpdateState(state.status, auto_enrollment_state_); |
| } |
| -void AutoEnrollmentCheckStep::OnAutoEnrollmentCheckProgressed( |
| +void AutoEnrollmentCheckScreen::OnAutoEnrollmentCheckProgressed( |
| policy::AutoEnrollmentState state) { |
| UpdateState(captive_portal_status_, state); |
| } |
| -void AutoEnrollmentCheckStep::UpdateState( |
| +void AutoEnrollmentCheckScreen::UpdateState( |
| NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status, |
| policy::AutoEnrollmentState new_auto_enrollment_state) { |
| // Configure the error screen to show the approriate error message. |
| @@ -70,7 +105,7 @@ void AutoEnrollmentCheckStep::UpdateState( |
| UpdateAutoEnrollmentState(new_auto_enrollment_state); |
| // Update the connecting indicator. |
| - ErrorScreen* error_screen = screen_observer_->GetErrorScreen(); |
| + ErrorScreen* error_screen = get_screen_observer()->GetErrorScreen(); |
| error_screen->ShowConnectingIndicator( |
| new_auto_enrollment_state == policy::AUTO_ENROLLMENT_STATE_PENDING); |
| @@ -107,7 +142,7 @@ void AutoEnrollmentCheckStep::UpdateState( |
| auto_enrollment_controller_->Retry(); |
| } |
| -bool AutoEnrollmentCheckStep::UpdateCaptivePortalStatus( |
| +bool AutoEnrollmentCheckScreen::UpdateCaptivePortalStatus( |
| NetworkPortalDetector::CaptivePortalStatus new_captive_portal_status) { |
| switch (new_captive_portal_status) { |
| case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
| @@ -119,7 +154,7 @@ bool AutoEnrollmentCheckStep::UpdateCaptivePortalStatus( |
| case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: |
| ShowErrorScreen(ErrorScreen::ERROR_STATE_PORTAL); |
| if (captive_portal_status_ != new_captive_portal_status) |
| - screen_observer_->GetErrorScreen()->FixCaptivePortal(); |
| + get_screen_observer()->GetErrorScreen()->FixCaptivePortal(); |
| return true; |
| case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
| ShowErrorScreen(ErrorScreen::ERROR_STATE_PROXY); |
| @@ -133,7 +168,7 @@ bool AutoEnrollmentCheckStep::UpdateCaptivePortalStatus( |
| return false; |
| } |
| -bool AutoEnrollmentCheckStep::UpdateAutoEnrollmentState( |
| +bool AutoEnrollmentCheckScreen::UpdateAutoEnrollmentState( |
| policy::AutoEnrollmentState new_auto_enrollment_state) { |
| switch (new_auto_enrollment_state) { |
| case policy::AUTO_ENROLLMENT_STATE_IDLE: |
| @@ -154,22 +189,22 @@ bool AutoEnrollmentCheckStep::UpdateAutoEnrollmentState( |
| return false; |
| } |
| -void AutoEnrollmentCheckStep::ShowErrorScreen( |
| +void AutoEnrollmentCheckScreen::ShowErrorScreen( |
| ErrorScreen::ErrorState error_state) { |
| const NetworkState* network = |
| NetworkHandler::Get()->network_state_handler()->DefaultNetwork(); |
| - ErrorScreen* error_screen = screen_observer_->GetErrorScreen(); |
| + ErrorScreen* error_screen = get_screen_observer()->GetErrorScreen(); |
| error_screen->SetUIState(ErrorScreen::UI_STATE_AUTO_ENROLLMENT_ERROR); |
| error_screen->AllowGuestSignin(true); |
| error_screen->SetErrorState(error_state, |
| network ? network->name() : std::string()); |
| - screen_observer_->ShowErrorScreen(); |
| + get_screen_observer()->ShowErrorScreen(); |
| } |
| -void AutoEnrollmentCheckStep::SignalCompletion() { |
| +void AutoEnrollmentCheckScreen::SignalCompletion() { |
| NetworkPortalDetector::Get()->RemoveObserver(this); |
| auto_enrollment_progress_subscription_.reset(); |
| - screen_observer_->OnExit( |
| + get_screen_observer()->OnExit( |
| ScreenObserver::ENTERPRISE_AUTO_ENROLLMENT_CHECK_COMPLETED); |
| } |