Chromium Code Reviews| 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" | |
| 8 #include "base/bind_helpers.h" | |
| 7 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/logging.h" | |
| 11 #include "chrome/browser/chrome_notification_types.h" | |
| 12 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h" | |
| 13 #include "chrome/browser/chromeos/app_mode/certificate_manager_dialog.h" | |
| 8 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h" | 14 #include "chrome/browser/chromeos/login/auth/chrome_login_performer.h" |
| 9 #include "chrome/browser/chromeos/login/chrome_restart_request.h" | 15 #include "chrome/browser/chromeos/login/chrome_restart_request.h" |
| 10 #include "chrome/browser/chromeos/login/screens/error_screen_actor.h" | 16 #include "chrome/browser/chromeos/login/screens/network_error_view.h" |
| 11 #include "chrome/browser/chromeos/login/startup_utils.h" | 17 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 18 #include "chrome/browser/chromeos/login/ui/captive_portal_window_proxy.h" | |
| 19 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | |
| 20 #include "chrome/browser/chromeos/login/ui/webui_login_view.h" | |
| 12 #include "chrome/browser/chromeos/login/wizard_controller.h" | 21 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 13 #include "chrome/browser/chromeos/settings/cros_settings.h" | 22 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 23 #include "chrome/browser/chromeos/settings/device_settings_service.h" | |
| 24 #include "chrome/browser/extensions/component_loader.h" | |
| 25 #include "chrome/browser/extensions/extension_service.h" | |
| 26 #include "chrome/browser/profiles/profile_manager.h" | |
| 27 #include "chrome/browser/ui/extensions/app_launch_params.h" | |
| 28 #include "chrome/browser/ui/extensions/application_launch.h" | |
| 29 #include "chrome/common/extensions/extension_constants.h" | |
| 30 #include "chromeos/dbus/dbus_thread_manager.h" | |
| 31 #include "chromeos/dbus/power_manager_client.h" | |
| 32 #include "chromeos/dbus/session_manager_client.h" | |
| 33 #include "chromeos/network/portal_detector/network_portal_detector.h" | |
| 34 #include "chromeos/network/portal_detector/network_portal_detector_strategy.h" | |
| 35 #include "components/user_manager/user_manager.h" | |
| 36 #include "content/public/browser/notification_service.h" | |
| 37 #include "extensions/browser/extension_system.h" | |
| 38 #include "extensions/common/constants.h" | |
| 39 #include "grit/browser_resources.h" | |
| 40 #include "ui/gfx/native_widget_types.h" | |
| 14 | 41 |
| 15 namespace chromeos { | 42 namespace chromeos { |
| 16 | 43 |
| 17 ErrorScreen::ErrorScreen(BaseScreenDelegate* base_screen_delegate, | 44 ErrorScreen::ErrorScreen(BaseScreenDelegate* base_screen_delegate, |
| 18 ErrorScreenActor* actor) | 45 NetworkErrorView* view) |
| 19 : BaseScreen(base_screen_delegate), | 46 : NetworkErrorModel(base_screen_delegate), |
| 20 actor_(actor), | 47 view_(view), |
| 21 parent_screen_(OobeDisplay::SCREEN_UNKNOWN), | |
| 22 weak_factory_(this) { | 48 weak_factory_(this) { |
| 23 CHECK(actor_); | 49 network_state_informer_ = new NetworkStateInformer(); |
| 24 actor_->SetDelegate(this); | 50 network_state_informer_->Init(); |
| 51 if (view_) | |
| 52 view_->Bind(*this); | |
| 25 } | 53 } |
| 26 | 54 |
| 27 ErrorScreen::~ErrorScreen() { | 55 ErrorScreen::~ErrorScreen() { |
| 28 if (actor_) | 56 if (view_) |
| 29 actor_->SetDelegate(NULL); | 57 view_->Unbind(); |
| 30 } | 58 } |
| 31 | 59 |
| 32 void ErrorScreen::PrepareToShow() { | 60 void ErrorScreen::PrepareToShow() { |
| 61 if (view_) | |
| 62 view_->PrepareToShow(); | |
| 33 } | 63 } |
| 34 | 64 |
| 35 void ErrorScreen::Show() { | 65 void ErrorScreen::Show() { |
| 36 if (actor_) | 66 if (!on_hide_callback()) { |
| 37 actor_->Show(parent_screen(), NULL); | 67 SetHideCallback(base::Bind(&ErrorScreen::DefaultHideCallback, |
| 68 weak_factory_.GetWeakPtr())); | |
| 69 } | |
| 70 if (view_) | |
| 71 view_->Show(); | |
| 38 } | 72 } |
| 39 | 73 |
| 40 void ErrorScreen::Hide() { | 74 void ErrorScreen::Hide() { |
| 41 if (actor_) | 75 if (view_) |
| 42 actor_->Hide(); | 76 view_->Hide(); |
| 43 } | 77 } |
| 44 | 78 |
| 45 std::string ErrorScreen::GetName() const { | 79 void ErrorScreen::OnShow() { |
| 46 return WizardController::kErrorScreenName; | 80 LOG(WARNING) << "Network error screen message is shown"; |
|
Denis Kuznetsov (DE-MUC)
2015/02/10 17:03:26
Is that a good logging level?
Nikita (slow)
2015/02/11 12:18:57
Just leaving as is. INFO level will be filtrated.
| |
| 81 content::NotificationService::current()->Notify( | |
| 82 chrome::NOTIFICATION_LOGIN_NETWORK_ERROR_SHOWN, | |
| 83 content::NotificationService::AllSources(), | |
| 84 content::NotificationService::NoDetails()); | |
| 85 NetworkPortalDetector::Get()->SetStrategy( | |
| 86 PortalDetectorStrategy::STRATEGY_ID_ERROR_SCREEN); | |
| 47 } | 87 } |
| 48 | 88 |
| 49 void ErrorScreen::OnErrorShow() {} | 89 void ErrorScreen::OnHide() { |
| 50 | 90 LOG(WARNING) << "Network error screen message is hidden"; |
| 51 void ErrorScreen::OnErrorHide() {} | 91 NetworkErrorModel::OnHide(); |
| 52 | 92 NetworkPortalDetector::Get()->SetStrategy( |
| 53 void ErrorScreen::OnLaunchOobeGuestSession() { | 93 PortalDetectorStrategy::STRATEGY_ID_LOGIN_SCREEN); |
|
Denis Kuznetsov (DE-MUC)
2015/02/10 17:03:26
Is it always a "Login Screen" strategy?
Nikita (slow)
2015/02/11 12:18:57
Yes, that's name may be a bit too specific but bas
| |
| 54 DeviceSettingsService::Get()->GetOwnershipStatusAsync( | |
| 55 base::Bind(&ErrorScreen::StartGuestSessionAfterOwnershipCheck, | |
| 56 weak_factory_.GetWeakPtr())); | |
| 57 } | 94 } |
| 58 | 95 |
| 59 void ErrorScreen::OnActorDestroyed() { | 96 void ErrorScreen::OnUserAction(const std::string& action_id) { |
| 60 actor_ = nullptr; | 97 if (action_id == kUserActionShowCaptivePortalClicked) |
| 98 ShowCaptivePortal(); | |
| 99 else if (action_id == kUserActionConfigureCertsButtonClicked) | |
| 100 HandleConfigureCerts(); | |
|
Denis Kuznetsov (DE-MUC)
2015/02/10 17:03:26
Let's agree on a naming scheme here.
I'd prefer On
Nikita (slow)
2015/02/11 12:18:57
Done.
| |
| 101 else if (action_id == kUserActionDiagnoseButtonClicked) | |
| 102 HandleDiagnoseButtonClicked(); | |
| 103 else if (action_id == kUserActionLaunchOobeGuestSessionClicked) | |
| 104 HandleLaunchOobeGuestSession(); | |
| 105 else if (action_id == kUserActionLocalStateErrorPowerwashButtonClicked) | |
| 106 HandleLocalStateErrorPowerwashButtonClicked(); | |
| 107 else if (action_id == kUserActionRebootButtonClicked) | |
| 108 HandleRebootButtonClicked(); | |
| 109 } | |
| 110 | |
| 111 void ErrorScreen::OnContextKeyUpdated( | |
| 112 const ::login::ScreenContext::KeyType& key) { | |
| 113 NetworkErrorModel::OnContextKeyUpdated(key); | |
|
Denis Kuznetsov (DE-MUC)
2015/02/10 17:03:26
Why do we have fallback here and don't have simila
Nikita (slow)
2015/02/11 12:18:57
Done.
Denis Kuznetsov (DE-MUC)
2015/02/11 16:16:25
nit: use BaseSceen::OnContextKeyUpdated()
Nikita (slow)
2015/02/12 13:23:31
Done.
| |
| 114 } | |
| 115 | |
| 116 void ErrorScreen::FixCaptivePortal() { | |
| 117 if (!captive_portal_window_proxy_.get()) { | |
| 118 content::WebContents* web_contents = LoginDisplayHostImpl::default_host() | |
| 119 ->GetWebUILoginView() | |
| 120 ->GetWebContents(); | |
| 121 captive_portal_window_proxy_.reset(new CaptivePortalWindowProxy( | |
| 122 network_state_informer_.get(), web_contents)); | |
| 123 } | |
| 124 captive_portal_window_proxy_->ShowIfRedirected(); | |
| 125 } | |
| 126 | |
| 127 void ErrorScreen::HideCaptivePortal() { | |
| 128 if (captive_portal_window_proxy_.get()) | |
| 129 captive_portal_window_proxy_->Close(); | |
| 130 } | |
| 131 | |
| 132 void ErrorScreen::OnViewDestroyed(NetworkErrorView* view) { | |
| 133 if (view_ == view) | |
| 134 view_ = nullptr; | |
| 135 } | |
| 136 | |
| 137 void ErrorScreen::ShowCaptivePortal() { | |
| 138 // This call is an explicit user action | |
| 139 // i.e. clicking on link so force dialog show. | |
| 140 FixCaptivePortal(); | |
| 141 captive_portal_window_proxy_->Show(); | |
| 61 } | 142 } |
| 62 | 143 |
| 63 void ErrorScreen::OnAuthFailure(const AuthFailure& error) { | 144 void ErrorScreen::OnAuthFailure(const AuthFailure& error) { |
| 64 // The only condition leading here is guest mount failure, which should not | 145 // The only condition leading here is guest mount failure, which should not |
| 65 // happen in practice. For now, just log an error so this situation is visible | 146 // happen in practice. For now, just log an error so this situation is visible |
| 66 // in logs if it ever occurs. | 147 // in logs if it ever occurs. |
| 67 NOTREACHED() << "Guest login failed."; | 148 NOTREACHED() << "Guest login failed."; |
| 68 guest_login_performer_.reset(); | 149 guest_login_performer_.reset(); |
| 69 } | 150 } |
| 70 | 151 |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 95 } | 176 } |
| 96 | 177 |
| 97 void ErrorScreen::PolicyLoadFailed() { | 178 void ErrorScreen::PolicyLoadFailed() { |
| 98 LOG(FATAL); | 179 LOG(FATAL); |
| 99 } | 180 } |
| 100 | 181 |
| 101 void ErrorScreen::OnOnlineChecked(const std::string& username, bool success) { | 182 void ErrorScreen::OnOnlineChecked(const std::string& username, bool success) { |
| 102 LOG(FATAL); | 183 LOG(FATAL); |
| 103 } | 184 } |
| 104 | 185 |
| 105 void ErrorScreen::FixCaptivePortal() { | 186 void ErrorScreen::DefaultHideCallback() { |
| 106 if (actor_) | 187 if (view_) |
| 107 actor_->FixCaptivePortal(); | 188 view_->ShowScreen(parent_screen()); |
| 189 SetParentScreen(OobeUI::SCREEN_UNKNOWN); | |
| 108 } | 190 } |
| 109 | 191 |
| 110 void ErrorScreen::ShowCaptivePortal() { | 192 void ErrorScreen::HandleConfigureCerts() { |
| 111 if (actor_) | 193 gfx::NativeWindow native_window = |
| 112 actor_->ShowCaptivePortal(); | 194 LoginDisplayHostImpl::default_host()->GetNativeWindow(); |
| 195 CertificateManagerDialog* dialog = new CertificateManagerDialog( | |
| 196 ProfileManager::GetActiveUserProfile(), NULL, native_window); | |
|
Denis Kuznetsov (DE-MUC)
2015/02/10 17:03:26
Why the "Active user"?
Nikita (slow)
2015/02/11 12:18:57
In this case ActiveUserProfile() will always retur
| |
| 197 dialog->Show(); | |
| 113 } | 198 } |
| 114 | 199 |
| 115 void ErrorScreen::HideCaptivePortal() { | 200 void ErrorScreen::HandleDiagnoseButtonClicked() { |
| 116 if (actor_) | 201 Profile* profile = ProfileManager::GetActiveUserProfile(); |
| 117 actor_->HideCaptivePortal(); | 202 ExtensionService* extension_service = |
| 203 extensions::ExtensionSystem::Get(profile)->extension_service(); | |
| 204 | |
| 205 std::string extension_id = extension_service->component_loader()->Add( | |
| 206 IDR_CONNECTIVITY_DIAGNOSTICS_MANIFEST, | |
| 207 base::FilePath(extension_misc::kConnectivityDiagnosticsKioskPath)); | |
| 208 | |
| 209 const extensions::Extension* extension = | |
| 210 extension_service->GetExtensionById(extension_id, true); | |
| 211 OpenApplication( | |
| 212 AppLaunchParams(profile, extension, extensions::LAUNCH_CONTAINER_WINDOW, | |
| 213 NEW_WINDOW, extensions::SOURCE_CHROME_INTERNAL)); | |
| 214 InitAppSession(profile, extension_id); | |
| 215 | |
| 216 user_manager::UserManager::Get()->SessionStarted(); | |
| 217 | |
| 218 LoginDisplayHostImpl::default_host()->Finalize(); | |
|
Denis Kuznetsov (DE-MUC)
2015/02/10 17:03:26
What if this will happen inside user session (some
Nikita (slow)
2015/02/11 12:18:57
There're no plans to support this use case since i
| |
| 118 } | 219 } |
| 119 | 220 |
| 120 void ErrorScreen::SetUIState(UIState ui_state) { | 221 void ErrorScreen::HandleLaunchOobeGuestSession() { |
| 121 if (actor_) | 222 DeviceSettingsService::Get()->GetOwnershipStatusAsync( |
| 122 actor_->SetUIState(ui_state); | 223 base::Bind(&ErrorScreen::StartGuestSessionAfterOwnershipCheck, |
|
Denis Kuznetsov (DE-MUC)
2015/02/10 17:03:26
Same question here.
Nikita (slow)
2015/02/11 12:18:58
Not possible since this is very specific case (ref
| |
| 224 weak_factory_.GetWeakPtr())); | |
| 123 } | 225 } |
| 124 | 226 |
| 125 ErrorScreen::UIState ErrorScreen::GetUIState() const { | 227 void ErrorScreen::HandleLocalStateErrorPowerwashButtonClicked() { |
| 126 return actor_ ? actor_->ui_state() : UI_STATE_UNKNOWN; | 228 chromeos::DBusThreadManager::Get() |
| 229 ->GetSessionManagerClient() | |
| 230 ->StartDeviceWipe(); | |
| 127 } | 231 } |
| 128 | 232 |
| 129 void ErrorScreen::SetErrorState(ErrorState error_state, | 233 void ErrorScreen::HandleRebootButtonClicked() { |
| 130 const std::string& network) { | 234 chromeos::DBusThreadManager::Get()->GetPowerManagerClient()->RequestRestart(); |
| 131 if (actor_) | |
| 132 actor_->SetErrorState(error_state, network); | |
| 133 } | |
| 134 | |
| 135 ErrorScreen::ErrorState ErrorScreen::GetErrorState() const { | |
| 136 DCHECK(actor_); | |
| 137 return actor_->error_state(); | |
| 138 } | |
| 139 | |
| 140 void ErrorScreen::AllowGuestSignin(bool allow) { | |
| 141 if (actor_) | |
| 142 actor_->AllowGuestSignin(allow); | |
| 143 } | |
| 144 | |
| 145 void ErrorScreen::ShowConnectingIndicator(bool show) { | |
| 146 if (actor_) | |
| 147 actor_->ShowConnectingIndicator(show); | |
| 148 } | 235 } |
| 149 | 236 |
| 150 void ErrorScreen::StartGuestSessionAfterOwnershipCheck( | 237 void ErrorScreen::StartGuestSessionAfterOwnershipCheck( |
| 151 DeviceSettingsService::OwnershipStatus ownership_status) { | 238 DeviceSettingsService::OwnershipStatus ownership_status) { |
| 152 | 239 |
| 153 // Make sure to disallow guest login if it's explicitly disabled. | 240 // Make sure to disallow guest login if it's explicitly disabled. |
| 154 CrosSettingsProvider::TrustedStatus trust_status = | 241 CrosSettingsProvider::TrustedStatus trust_status = |
| 155 CrosSettings::Get()->PrepareTrustedValues( | 242 CrosSettings::Get()->PrepareTrustedValues( |
| 156 base::Bind(&ErrorScreen::StartGuestSessionAfterOwnershipCheck, | 243 base::Bind(&ErrorScreen::StartGuestSessionAfterOwnershipCheck, |
| 157 weak_factory_.GetWeakPtr(), | 244 weak_factory_.GetWeakPtr(), |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 176 } | 263 } |
| 177 | 264 |
| 178 if (guest_login_performer_) | 265 if (guest_login_performer_) |
| 179 return; | 266 return; |
| 180 | 267 |
| 181 guest_login_performer_.reset(new ChromeLoginPerformer(this)); | 268 guest_login_performer_.reset(new ChromeLoginPerformer(this)); |
| 182 guest_login_performer_->LoginOffTheRecord(); | 269 guest_login_performer_->LoginOffTheRecord(); |
| 183 } | 270 } |
| 184 | 271 |
| 185 } // namespace chromeos | 272 } // namespace chromeos |
| OLD | NEW |