| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/screens/error_screen.h" | 5 #include "chrome/browser/chromeos/login/screens/error_screen.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 #include "components/session_manager/core/session_manager.h" | 38 #include "components/session_manager/core/session_manager.h" |
| 39 #include "content/public/browser/notification_service.h" | 39 #include "content/public/browser/notification_service.h" |
| 40 #include "extensions/browser/extension_system.h" | 40 #include "extensions/browser/extension_system.h" |
| 41 #include "extensions/common/constants.h" | 41 #include "extensions/common/constants.h" |
| 42 #include "ui/gfx/native_widget_types.h" | 42 #include "ui/gfx/native_widget_types.h" |
| 43 | 43 |
| 44 namespace chromeos { | 44 namespace chromeos { |
| 45 | 45 |
| 46 namespace { | 46 namespace { |
| 47 | 47 |
| 48 constexpr const char kContextKeyErrorStateCode[] = "error-state-code"; |
| 49 constexpr const char kContextKeyErrorStateNetwork[] = "error-state-network"; |
| 50 constexpr const char kContextKeyGuestSigninAllowed[] = "guest-signin-allowed"; |
| 51 constexpr const char kContextKeyOfflineSigninAllowed[] = |
| 52 "offline-signin-allowed"; |
| 53 constexpr const char kContextKeyShowConnectingIndicator[] = |
| 54 "show-connecting-indicator"; |
| 55 constexpr const char kContextKeyUIState[] = "ui-state"; |
| 56 |
| 48 // Returns the current running kiosk app profile in a kiosk session. Otherwise, | 57 // Returns the current running kiosk app profile in a kiosk session. Otherwise, |
| 49 // returns nullptr. | 58 // returns nullptr. |
| 50 Profile* GetAppProfile() { | 59 Profile* GetAppProfile() { |
| 51 return chrome::IsRunningInForcedAppMode() | 60 return chrome::IsRunningInForcedAppMode() |
| 52 ? ProfileManager::GetActiveUserProfile() | 61 ? ProfileManager::GetActiveUserProfile() |
| 53 : nullptr; | 62 : nullptr; |
| 54 } | 63 } |
| 55 | 64 |
| 56 } // namespace | 65 } // namespace |
| 57 | 66 |
| 67 constexpr const char ErrorScreen::kUserActionConfigureCertsButtonClicked[] = |
| 68 "configure-certs"; |
| 69 constexpr const char ErrorScreen::kUserActionDiagnoseButtonClicked[] = |
| 70 "diagnose"; |
| 71 constexpr const char ErrorScreen::kUserActionLaunchOobeGuestSessionClicked[] = |
| 72 "launch-oobe-guest"; |
| 73 constexpr const char |
| 74 ErrorScreen::kUserActionLocalStateErrorPowerwashButtonClicked[] = |
| 75 "local-state-error-powerwash"; |
| 76 constexpr const char ErrorScreen::kUserActionRebootButtonClicked[] = "reboot"; |
| 77 constexpr const char ErrorScreen::kUserActionShowCaptivePortalClicked[] = |
| 78 "show-captive-portal"; |
| 79 constexpr const char ErrorScreen::kUserActionConnectRequested[] = |
| 80 "connect-requested"; |
| 81 |
| 58 ErrorScreen::ErrorScreen(BaseScreenDelegate* base_screen_delegate, | 82 ErrorScreen::ErrorScreen(BaseScreenDelegate* base_screen_delegate, |
| 59 NetworkErrorView* view) | 83 NetworkErrorView* view) |
| 60 : NetworkErrorModel(base_screen_delegate), | 84 : BaseScreen(base_screen_delegate, OobeScreen::SCREEN_ERROR_MESSAGE), |
| 61 view_(view), | 85 view_(view), |
| 62 weak_factory_(this) { | 86 weak_factory_(this) { |
| 63 network_state_informer_ = new NetworkStateInformer(); | 87 network_state_informer_ = new NetworkStateInformer(); |
| 64 network_state_informer_->Init(); | 88 network_state_informer_->Init(); |
| 65 if (view_) | 89 if (view_) |
| 66 view_->Bind(*this); | 90 view_->Bind(this); |
| 67 } | 91 } |
| 68 | 92 |
| 69 ErrorScreen::~ErrorScreen() { | 93 ErrorScreen::~ErrorScreen() { |
| 70 if (view_) | 94 if (view_) |
| 71 view_->Unbind(); | 95 view_->Unbind(); |
| 72 } | 96 } |
| 73 | 97 |
| 74 void ErrorScreen::Show() { | |
| 75 if (!on_hide_callback_) { | |
| 76 SetHideCallback(base::Bind(&ErrorScreen::DefaultHideCallback, | |
| 77 weak_factory_.GetWeakPtr())); | |
| 78 } | |
| 79 if (view_) | |
| 80 view_->Show(); | |
| 81 } | |
| 82 | |
| 83 void ErrorScreen::Hide() { | |
| 84 if (view_) | |
| 85 view_->Hide(); | |
| 86 } | |
| 87 | |
| 88 void ErrorScreen::OnShow() { | |
| 89 LOG(WARNING) << "Network error screen message is shown"; | |
| 90 content::NotificationService::current()->Notify( | |
| 91 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, | |
| 92 content::NotificationService::AllSources(), | |
| 93 content::NotificationService::NoDetails()); | |
| 94 network_portal_detector::GetInstance()->SetStrategy( | |
| 95 PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN); | |
| 96 } | |
| 97 | |
| 98 void ErrorScreen::OnHide() { | |
| 99 LOG(WARNING) << "Network error screen message is hidden"; | |
| 100 if (on_hide_callback_) { | |
| 101 on_hide_callback_->Run(); | |
| 102 on_hide_callback_.reset(); | |
| 103 } | |
| 104 network_portal_detector::GetInstance()->SetStrategy( | |
| 105 PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN); | |
| 106 } | |
| 107 | |
| 108 void ErrorScreen::OnUserAction(const std::string& action_id) { | |
| 109 if (action_id == kUserActionShowCaptivePortalClicked) | |
| 110 ShowCaptivePortal(); | |
| 111 else if (action_id == kUserActionConfigureCertsButtonClicked) | |
| 112 OnConfigureCerts(); | |
| 113 else if (action_id == kUserActionDiagnoseButtonClicked) | |
| 114 OnDiagnoseButtonClicked(); | |
| 115 else if (action_id == kUserActionLaunchOobeGuestSessionClicked) | |
| 116 OnLaunchOobeGuestSession(); | |
| 117 else if (action_id == kUserActionLocalStateErrorPowerwashButtonClicked) | |
| 118 OnLocalStateErrorPowerwashButtonClicked(); | |
| 119 else if (action_id == kUserActionRebootButtonClicked) | |
| 120 OnRebootButtonClicked(); | |
| 121 else if (action_id == kUserActionConnectRequested) | |
| 122 OnConnectRequested(); | |
| 123 else | |
| 124 BaseScreen::OnUserAction(action_id); | |
| 125 } | |
| 126 | |
| 127 void ErrorScreen::OnContextKeyUpdated( | |
| 128 const ::login::ScreenContext::KeyType& key) { | |
| 129 BaseScreen::OnContextKeyUpdated(key); | |
| 130 } | |
| 131 | |
| 132 void ErrorScreen::AllowGuestSignin(bool allowed) { | 98 void ErrorScreen::AllowGuestSignin(bool allowed) { |
| 133 GetContextEditor().SetBoolean(kContextKeyGuestSigninAllowed, allowed); | 99 GetContextEditor().SetBoolean(kContextKeyGuestSigninAllowed, allowed); |
| 134 } | 100 } |
| 135 | 101 |
| 136 void ErrorScreen::AllowOfflineLogin(bool allowed) { | 102 void ErrorScreen::AllowOfflineLogin(bool allowed) { |
| 137 GetContextEditor().SetBoolean(kContextKeyOfflineSigninAllowed, allowed); | 103 GetContextEditor().SetBoolean(kContextKeyOfflineSigninAllowed, allowed); |
| 138 } | 104 } |
| 139 | 105 |
| 140 void ErrorScreen::FixCaptivePortal() { | 106 void ErrorScreen::FixCaptivePortal() { |
| 141 if (!captive_portal_window_proxy_.get()) { | 107 if (!captive_portal_window_proxy_.get()) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 // This call is an explicit user action | 162 // This call is an explicit user action |
| 197 // i.e. clicking on link so force dialog show. | 163 // i.e. clicking on link so force dialog show. |
| 198 FixCaptivePortal(); | 164 FixCaptivePortal(); |
| 199 captive_portal_window_proxy_->Show(); | 165 captive_portal_window_proxy_->Show(); |
| 200 } | 166 } |
| 201 | 167 |
| 202 void ErrorScreen::ShowConnectingIndicator(bool show) { | 168 void ErrorScreen::ShowConnectingIndicator(bool show) { |
| 203 GetContextEditor().SetBoolean(kContextKeyShowConnectingIndicator, show); | 169 GetContextEditor().SetBoolean(kContextKeyShowConnectingIndicator, show); |
| 204 } | 170 } |
| 205 | 171 |
| 172 ErrorScreen::ConnectRequestCallbackSubscription |
| 173 ErrorScreen::RegisterConnectRequestCallback(const base::Closure& callback) { |
| 174 return connect_request_callbacks_.Add(callback); |
| 175 } |
| 176 |
| 177 void ErrorScreen::Show() { |
| 178 if (!on_hide_callback_) { |
| 179 SetHideCallback(base::Bind(&ErrorScreen::DefaultHideCallback, |
| 180 weak_factory_.GetWeakPtr())); |
| 181 } |
| 182 if (view_) |
| 183 view_->Show(); |
| 184 } |
| 185 |
| 186 void ErrorScreen::Hide() { |
| 187 if (view_) |
| 188 view_->Hide(); |
| 189 } |
| 190 |
| 191 void ErrorScreen::OnShow() { |
| 192 LOG(WARNING) << "Network error screen message is shown"; |
| 193 content::NotificationService::current()->Notify( |
| 194 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, |
| 195 content::NotificationService::AllSources(), |
| 196 content::NotificationService::NoDetails()); |
| 197 network_portal_detector::GetInstance()->SetStrategy( |
| 198 PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN); |
| 199 } |
| 200 |
| 201 void ErrorScreen::OnHide() { |
| 202 LOG(WARNING) << "Network error screen message is hidden"; |
| 203 if (on_hide_callback_) { |
| 204 on_hide_callback_->Run(); |
| 205 on_hide_callback_.reset(); |
| 206 } |
| 207 network_portal_detector::GetInstance()->SetStrategy( |
| 208 PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN); |
| 209 } |
| 210 |
| 211 void ErrorScreen::OnUserAction(const std::string& action_id) { |
| 212 if (action_id == kUserActionShowCaptivePortalClicked) |
| 213 ShowCaptivePortal(); |
| 214 else if (action_id == kUserActionConfigureCertsButtonClicked) |
| 215 OnConfigureCerts(); |
| 216 else if (action_id == kUserActionDiagnoseButtonClicked) |
| 217 OnDiagnoseButtonClicked(); |
| 218 else if (action_id == kUserActionLaunchOobeGuestSessionClicked) |
| 219 OnLaunchOobeGuestSession(); |
| 220 else if (action_id == kUserActionLocalStateErrorPowerwashButtonClicked) |
| 221 OnLocalStateErrorPowerwashButtonClicked(); |
| 222 else if (action_id == kUserActionRebootButtonClicked) |
| 223 OnRebootButtonClicked(); |
| 224 else if (action_id == kUserActionConnectRequested) |
| 225 OnConnectRequested(); |
| 226 else |
| 227 BaseScreen::OnUserAction(action_id); |
| 228 } |
| 229 |
| 206 void ErrorScreen::OnAuthFailure(const AuthFailure& error) { | 230 void ErrorScreen::OnAuthFailure(const AuthFailure& error) { |
| 207 // The only condition leading here is guest mount failure, which should not | 231 // The only condition leading here is guest mount failure, which should not |
| 208 // happen in practice. For now, just log an error so this situation is visible | 232 // happen in practice. For now, just log an error so this situation is visible |
| 209 // in logs if it ever occurs. | 233 // in logs if it ever occurs. |
| 210 NOTREACHED() << "Guest login failed."; | 234 NOTREACHED() << "Guest login failed."; |
| 211 guest_login_performer_.reset(); | 235 guest_login_performer_.reset(); |
| 212 } | 236 } |
| 213 | 237 |
| 214 void ErrorScreen::OnAuthSuccess(const UserContext& user_context) { | 238 void ErrorScreen::OnAuthSuccess(const UserContext& user_context) { |
| 215 LOG(FATAL); | 239 LOG(FATAL); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 234 } | 258 } |
| 235 | 259 |
| 236 void ErrorScreen::PolicyLoadFailed() { | 260 void ErrorScreen::PolicyLoadFailed() { |
| 237 LOG(FATAL); | 261 LOG(FATAL); |
| 238 } | 262 } |
| 239 | 263 |
| 240 void ErrorScreen::SetAuthFlowOffline(bool offline) { | 264 void ErrorScreen::SetAuthFlowOffline(bool offline) { |
| 241 LOG(FATAL); | 265 LOG(FATAL); |
| 242 } | 266 } |
| 243 | 267 |
| 244 ErrorScreen::ConnectRequestCallbackSubscription | |
| 245 ErrorScreen::RegisterConnectRequestCallback(const base::Closure& callback) { | |
| 246 return connect_request_callbacks_.Add(callback); | |
| 247 } | |
| 248 | |
| 249 void ErrorScreen::DefaultHideCallback() { | 268 void ErrorScreen::DefaultHideCallback() { |
| 250 if (parent_screen_ != OobeScreen::SCREEN_UNKNOWN && view_) | 269 if (parent_screen_ != OobeScreen::SCREEN_UNKNOWN && view_) |
| 251 view_->ShowOobeScreen(parent_screen_); | 270 view_->ShowOobeScreen(parent_screen_); |
| 252 | 271 |
| 253 // TODO(antrim): Due to potential race with GAIA reload and hiding network | 272 // TODO(antrim): Due to potential race with GAIA reload and hiding network |
| 254 // error UI we can't just reset parent screen to SCREEN_UNKNOWN here. | 273 // error UI we can't just reset parent screen to SCREEN_UNKNOWN here. |
| 255 } | 274 } |
| 256 | 275 |
| 257 void ErrorScreen::OnConfigureCerts() { | 276 void ErrorScreen::OnConfigureCerts() { |
| 258 gfx::NativeWindow native_window = | 277 gfx::NativeWindow native_window = |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 332 } | 351 } |
| 333 | 352 |
| 334 if (guest_login_performer_) | 353 if (guest_login_performer_) |
| 335 return; | 354 return; |
| 336 | 355 |
| 337 guest_login_performer_.reset(new ChromeLoginPerformer(this)); | 356 guest_login_performer_.reset(new ChromeLoginPerformer(this)); |
| 338 guest_login_performer_->LoginOffTheRecord(); | 357 guest_login_performer_->LoginOffTheRecord(); |
| 339 } | 358 } |
| 340 | 359 |
| 341 } // namespace chromeos | 360 } // namespace chromeos |
| OLD | NEW |