| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_sc
reen.h" | 5 #include "chrome/browser/chromeos/login/managed/locally_managed_user_creation_sc
reen.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/login/error_screen.h" |
| 7 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 8 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 8 #include "chrome/browser/chromeos/login/managed/locally_managed_user_controller.
h" | 9 #include "chrome/browser/chromeos/login/managed/locally_managed_user_controller.
h" |
| 9 #include "chrome/browser/chromeos/login/screen_observer.h" | 10 #include "chrome/browser/chromeos/login/screen_observer.h" |
| 10 #include "chrome/browser/chromeos/login/wizard_controller.h" | 11 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 11 #include "grit/generated_resources.h" | 12 #include "grit/generated_resources.h" |
| 12 #include "ui/base/l10n/l10n_util.h" | 13 #include "ui/base/l10n/l10n_util.h" |
| 13 | 14 |
| 14 namespace chromeos { | 15 namespace chromeos { |
| 15 | 16 |
| 17 namespace { |
| 18 |
| 19 void ConfigureErrorScreen(ErrorScreen* screen, |
| 20 const Network* network, |
| 21 const NetworkPortalDetector::CaptivePortalStatus status) { |
| 22 switch (status) { |
| 23 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_UNKNOWN: |
| 24 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE: |
| 25 NOTREACHED(); |
| 26 break; |
| 27 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_OFFLINE: |
| 28 screen->SetErrorState(ErrorScreen::ERROR_STATE_OFFLINE, |
| 29 std::string()); |
| 30 break; |
| 31 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PORTAL: |
| 32 screen->SetErrorState(ErrorScreen::ERROR_STATE_PORTAL, |
| 33 network->name()); |
| 34 screen->FixCaptivePortal(); |
| 35 break; |
| 36 case NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_PROXY_AUTH_REQUIRED: |
| 37 screen->SetErrorState(ErrorScreen::ERROR_STATE_PROXY, |
| 38 std::string()); |
| 39 break; |
| 40 default: |
| 41 NOTREACHED(); |
| 42 break; |
| 43 } |
| 44 } |
| 45 |
| 46 } // namespace |
| 47 |
| 16 LocallyManagedUserCreationScreen::LocallyManagedUserCreationScreen( | 48 LocallyManagedUserCreationScreen::LocallyManagedUserCreationScreen( |
| 17 ScreenObserver* observer, | 49 ScreenObserver* observer, |
| 18 LocallyManagedUserCreationScreenHandler* actor) | 50 LocallyManagedUserCreationScreenHandler* actor) |
| 19 : WizardScreen(observer), actor_(actor) { | 51 : WizardScreen(observer), |
| 52 actor_(actor), |
| 53 on_error_screen_(false) { |
| 20 DCHECK(actor_); | 54 DCHECK(actor_); |
| 21 if (actor_) | 55 if (actor_) |
| 22 actor_->SetDelegate(this); | 56 actor_->SetDelegate(this); |
| 23 } | 57 } |
| 24 | 58 |
| 25 LocallyManagedUserCreationScreen::~LocallyManagedUserCreationScreen() { | 59 LocallyManagedUserCreationScreen::~LocallyManagedUserCreationScreen() { |
| 26 if (actor_) | 60 if (actor_) |
| 27 actor_->SetDelegate(NULL); | 61 actor_->SetDelegate(NULL); |
| 28 } | 62 } |
| 29 | 63 |
| 30 void LocallyManagedUserCreationScreen::PrepareToShow() { | 64 void LocallyManagedUserCreationScreen::PrepareToShow() { |
| 31 if (actor_) | 65 if (actor_) |
| 32 actor_->PrepareToShow(); | 66 actor_->PrepareToShow(); |
| 33 } | 67 } |
| 34 | 68 |
| 35 void LocallyManagedUserCreationScreen::Show() { | 69 void LocallyManagedUserCreationScreen::Show() { |
| 36 if (actor_) { | 70 if (actor_) { |
| 37 actor_->Show(); | 71 actor_->Show(); |
| 38 actor_->ShowInitialScreen(); | 72 actor_->ShowInitialScreen(); |
| 39 } | 73 } |
| 74 |
| 75 NetworkPortalDetector* detector = NetworkPortalDetector::GetInstance(); |
| 76 if (detector && !on_error_screen_) { |
| 77 detector->AddObserver(this); |
| 78 detector->ForcePortalDetection(); |
| 79 } |
| 80 on_error_screen_ = false; |
| 81 } |
| 82 |
| 83 void LocallyManagedUserCreationScreen::OnPortalDetectionCompleted( |
| 84 const Network* network, |
| 85 const NetworkPortalDetector::CaptivePortalState& state) { |
| 86 if (state.status == NetworkPortalDetector::CAPTIVE_PORTAL_STATUS_ONLINE) { |
| 87 get_screen_observer()->HideErrorScreen(this); |
| 88 } else { |
| 89 on_error_screen_ = true; |
| 90 ErrorScreen* screen = get_screen_observer()->GetErrorScreen(); |
| 91 ConfigureErrorScreen(screen, network, state.status); |
| 92 screen->SetUIState(ErrorScreen::UI_STATE_LOCALLY_MANAGED); |
| 93 get_screen_observer()->ShowErrorScreen(); |
| 94 } |
| 40 } | 95 } |
| 41 | 96 |
| 42 void LocallyManagedUserCreationScreen:: | 97 void LocallyManagedUserCreationScreen:: |
| 43 ShowManagerInconsistentStateErrorScreen() { | 98 ShowManagerInconsistentStateErrorScreen() { |
| 44 if (!actor_) | 99 if (!actor_) |
| 45 return; | 100 return; |
| 46 actor_->ShowErrorMessage( | 101 actor_->ShowErrorMessage( |
| 47 l10n_util::GetStringUTF16( | 102 l10n_util::GetStringUTF16( |
| 48 IDS_CREATE_LOCALLY_MANAGED_USER_MANAGER_INCONSISTENT_STATE), | 103 IDS_CREATE_LOCALLY_MANAGED_USER_MANAGER_INCONSISTENT_STATE), |
| 49 false); | 104 false); |
| 50 } | 105 } |
| 51 | 106 |
| 52 void LocallyManagedUserCreationScreen::ShowInitialScreen() { | 107 void LocallyManagedUserCreationScreen::ShowInitialScreen() { |
| 53 if (actor_) | 108 if (actor_) |
| 54 actor_->ShowInitialScreen(); | 109 actor_->ShowInitialScreen(); |
| 55 } | 110 } |
| 56 | 111 |
| 57 | |
| 58 void LocallyManagedUserCreationScreen::Hide() { | 112 void LocallyManagedUserCreationScreen::Hide() { |
| 59 if (actor_) | 113 if (actor_) |
| 60 actor_->Hide(); | 114 actor_->Hide(); |
| 115 NetworkPortalDetector* detector = NetworkPortalDetector::GetInstance(); |
| 116 if (detector && !on_error_screen_) |
| 117 detector->RemoveObserver(this); |
| 61 } | 118 } |
| 62 | 119 |
| 63 std::string LocallyManagedUserCreationScreen::GetName() const { | 120 std::string LocallyManagedUserCreationScreen::GetName() const { |
| 64 return WizardController::kLocallyManagedUserCreationScreenName; | 121 return WizardController::kLocallyManagedUserCreationScreenName; |
| 65 } | 122 } |
| 66 | 123 |
| 67 void LocallyManagedUserCreationScreen::AbortFlow() { | 124 void LocallyManagedUserCreationScreen::AbortFlow() { |
| 68 controller_->FinishCreation(); | 125 controller_->FinishCreation(); |
| 69 } | 126 } |
| 70 | 127 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (actor_) | 200 if (actor_) |
| 144 actor_->ShowErrorMessage(message, recoverable); | 201 actor_->ShowErrorMessage(message, recoverable); |
| 145 } | 202 } |
| 146 | 203 |
| 147 void LocallyManagedUserCreationScreen::OnCreationSuccess() { | 204 void LocallyManagedUserCreationScreen::OnCreationSuccess() { |
| 148 if (actor_) | 205 if (actor_) |
| 149 actor_->ShowSuccessMessage(); | 206 actor_->ShowSuccessMessage(); |
| 150 } | 207 } |
| 151 | 208 |
| 152 } // namespace chromeos | 209 } // namespace chromeos |
| OLD | NEW |