| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/ui/webui/chromeos/login/app_launch_splash_screen_handle
r.h" | 5 #include "chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handle
r.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 7 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 8 #include "chrome/browser/chromeos/login/screens/error_screen_actor.h" | 8 #include "chrome/browser/chromeos/login/screens/network_error.h" |
| 9 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" | 9 #include "chrome/browser/ui/webui/chromeos/login/oobe_ui.h" |
| 10 #include "chrome/grit/chromium_strings.h" | 10 #include "chrome/grit/chromium_strings.h" |
| 11 #include "chrome/grit/generated_resources.h" | 11 #include "chrome/grit/generated_resources.h" |
| 12 #include "chromeos/network/network_state.h" | 12 #include "chromeos/network/network_state.h" |
| 13 #include "chromeos/network/network_state_handler.h" | 13 #include "chromeos/network/network_state_handler.h" |
| 14 #include "grit/chrome_unscaled_resources.h" | 14 #include "grit/chrome_unscaled_resources.h" |
| 15 #include "ui/base/l10n/l10n_util.h" | 15 #include "ui/base/l10n/l10n_util.h" |
| 16 #include "ui/base/resource/resource_bundle.h" | 16 #include "ui/base/resource/resource_bundle.h" |
| 17 #include "ui/base/webui/web_ui_util.h" | 17 #include "ui/base/webui/web_ui_util.h" |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 const char kJsScreenPath[] = "login.AppLaunchSplashScreen"; | 21 const char kJsScreenPath[] = "login.AppLaunchSplashScreen"; |
| 22 | 22 |
| 23 // Returns network name by service path. | 23 // Returns network name by service path. |
| 24 std::string GetNetworkName(const std::string& service_path) { | 24 std::string GetNetworkName(const std::string& service_path) { |
| 25 const chromeos::NetworkState* network = | 25 const chromeos::NetworkState* network = |
| 26 chromeos::NetworkHandler::Get()->network_state_handler()->GetNetworkState( | 26 chromeos::NetworkHandler::Get()->network_state_handler()->GetNetworkState( |
| 27 service_path); | 27 service_path); |
| 28 if (!network) | 28 if (!network) |
| 29 return std::string(); | 29 return std::string(); |
| 30 return network->name(); | 30 return network->name(); |
| 31 } | 31 } |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 namespace chromeos { | 35 namespace chromeos { |
| 36 | 36 |
| 37 AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler( | 37 AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler( |
| 38 const scoped_refptr<NetworkStateInformer>& network_state_informer, | 38 const scoped_refptr<NetworkStateInformer>& network_state_informer, |
| 39 ErrorScreenActor* error_screen_actor) | 39 NetworkErrorModel* network_error_model) |
| 40 : BaseScreenHandler(kJsScreenPath), | 40 : BaseScreenHandler(kJsScreenPath), |
| 41 delegate_(NULL), | 41 delegate_(NULL), |
| 42 show_on_init_(false), | 42 show_on_init_(false), |
| 43 state_(APP_LAUNCH_STATE_LOADING_AUTH_FILE), | 43 state_(APP_LAUNCH_STATE_LOADING_AUTH_FILE), |
| 44 network_state_informer_(network_state_informer), | 44 network_state_informer_(network_state_informer), |
| 45 error_screen_actor_(error_screen_actor), | 45 network_error_model_(network_error_model), |
| 46 online_state_(false), | 46 online_state_(false), |
| 47 network_config_done_(false), | 47 network_config_done_(false), |
| 48 network_config_requested_(false) { | 48 network_config_requested_(false) { |
| 49 network_state_informer_->AddObserver(this); | 49 network_state_informer_->AddObserver(this); |
| 50 } | 50 } |
| 51 | 51 |
| 52 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() { | 52 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() { |
| 53 network_state_informer_->RemoveObserver(this); | 53 network_state_informer_->RemoveObserver(this); |
| 54 } | 54 } |
| 55 | 55 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 | 121 |
| 122 void AppLaunchSplashScreenHandler::UpdateAppLaunchState(AppLaunchState state) { | 122 void AppLaunchSplashScreenHandler::UpdateAppLaunchState(AppLaunchState state) { |
| 123 if (state == state_) | 123 if (state == state_) |
| 124 return; | 124 return; |
| 125 | 125 |
| 126 state_ = state; | 126 state_ = state; |
| 127 if (page_is_ready()) { | 127 if (page_is_ready()) { |
| 128 SetLaunchText( | 128 SetLaunchText( |
| 129 l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); | 129 l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); |
| 130 } | 130 } |
| 131 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE); | 131 UpdateState(NetworkError::ERROR_REASON_UPDATE); |
| 132 } | 132 } |
| 133 | 133 |
| 134 void AppLaunchSplashScreenHandler::SetDelegate( | 134 void AppLaunchSplashScreenHandler::SetDelegate( |
| 135 AppLaunchSplashScreenHandler::Delegate* delegate) { | 135 AppLaunchSplashScreenHandler::Delegate* delegate) { |
| 136 delegate_ = delegate; | 136 delegate_ = delegate; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() { | 139 void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() { |
| 140 NetworkStateInformer::State state = network_state_informer_->state(); | 140 NetworkStateInformer::State state = network_state_informer_->state(); |
| 141 if (state == NetworkStateInformer::ONLINE) { | 141 if (state == NetworkStateInformer::ONLINE) { |
| 142 online_state_ = true; | 142 online_state_ = true; |
| 143 if (!network_config_requested_) { | 143 if (!network_config_requested_) { |
| 144 delegate_->OnNetworkStateChanged(true); | 144 delegate_->OnNetworkStateChanged(true); |
| 145 return; | 145 return; |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| 149 const std::string network_path = network_state_informer_->network_path(); | 149 const std::string network_path = network_state_informer_->network_path(); |
| 150 const std::string network_name = GetNetworkName(network_path); | 150 const std::string network_name = GetNetworkName(network_path); |
| 151 | 151 |
| 152 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_KIOSK_MODE); | 152 network_error_model_->SetUIState(NetworkError::UI_STATE_KIOSK_MODE); |
| 153 error_screen_actor_->AllowGuestSignin(false); | 153 network_error_model_->AllowGuestSignin(false); |
| 154 error_screen_actor_->AllowOfflineLogin(false); | 154 network_error_model_->AllowOfflineLogin(false); |
| 155 | 155 |
| 156 switch (state) { | 156 switch (state) { |
| 157 case NetworkStateInformer::CAPTIVE_PORTAL: { | 157 case NetworkStateInformer::CAPTIVE_PORTAL: { |
| 158 error_screen_actor_->SetErrorState( | 158 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_PORTAL, |
| 159 ErrorScreen::ERROR_STATE_PORTAL, network_name); | 159 network_name); |
| 160 error_screen_actor_->FixCaptivePortal(); | 160 network_error_model_->FixCaptivePortal(); |
| 161 | 161 |
| 162 break; | 162 break; |
| 163 } | 163 } |
| 164 case NetworkStateInformer::PROXY_AUTH_REQUIRED: { | 164 case NetworkStateInformer::PROXY_AUTH_REQUIRED: { |
| 165 error_screen_actor_->SetErrorState( | 165 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_PROXY, |
| 166 ErrorScreen::ERROR_STATE_PROXY, network_name); | 166 network_name); |
| 167 break; | 167 break; |
| 168 } | 168 } |
| 169 case NetworkStateInformer::OFFLINE: { | 169 case NetworkStateInformer::OFFLINE: { |
| 170 error_screen_actor_->SetErrorState( | 170 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_OFFLINE, |
| 171 ErrorScreen::ERROR_STATE_OFFLINE, network_name); | 171 network_name); |
| 172 break; | 172 break; |
| 173 } | 173 } |
| 174 case NetworkStateInformer::ONLINE: { | 174 case NetworkStateInformer::ONLINE: { |
| 175 error_screen_actor_->SetErrorState( | 175 network_error_model_->SetErrorState( |
| 176 ErrorScreen::ERROR_STATE_KIOSK_ONLINE, network_name); | 176 NetworkError::ERROR_STATE_KIOSK_ONLINE, network_name); |
| 177 break; | 177 break; |
| 178 } | 178 } |
| 179 default: | 179 default: |
| 180 error_screen_actor_->SetErrorState( | 180 network_error_model_->SetErrorState(NetworkError::ERROR_STATE_OFFLINE, |
| 181 ErrorScreen::ERROR_STATE_OFFLINE, network_name); | 181 network_name); |
| 182 NOTREACHED(); | 182 NOTREACHED(); |
| 183 break; | 183 break; |
| 184 } | 184 } |
| 185 | 185 |
| 186 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; | 186 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; |
| 187 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); | 187 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); |
| 188 if (oobe_ui) | 188 if (oobe_ui) |
| 189 screen = oobe_ui->current_screen(); | 189 screen = oobe_ui->current_screen(); |
| 190 | 190 |
| 191 if (screen != OobeUI::SCREEN_ERROR_MESSAGE) | 191 if (screen != OobeUI::SCREEN_ERROR_MESSAGE) |
| 192 error_screen_actor_->Show(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH, NULL); | 192 network_error_model_->SetParentScreen(OobeUI::SCREEN_APP_LAUNCH_SPLASH); |
| 193 network_error_model_->Show(); |
| 193 } | 194 } |
| 194 | 195 |
| 195 bool AppLaunchSplashScreenHandler::IsNetworkReady() { | 196 bool AppLaunchSplashScreenHandler::IsNetworkReady() { |
| 196 return network_state_informer_->state() == NetworkStateInformer::ONLINE; | 197 return network_state_informer_->state() == NetworkStateInformer::ONLINE; |
| 197 } | 198 } |
| 198 | 199 |
| 199 void AppLaunchSplashScreenHandler::OnNetworkReady() { | 200 void AppLaunchSplashScreenHandler::OnNetworkReady() { |
| 200 // Purposely leave blank because the online case is handled in UpdateState | 201 // Purposely leave blank because the online case is handled in UpdateState |
| 201 // call below. | 202 // call below. |
| 202 } | 203 } |
| 203 | 204 |
| 204 void AppLaunchSplashScreenHandler::UpdateState( | 205 void AppLaunchSplashScreenHandler::UpdateState( |
| 205 ErrorScreenActor::ErrorReason reason) { | 206 NetworkError::ErrorReason reason) { |
| 206 if (!delegate_ || | 207 if (!delegate_ || |
| 207 (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK && | 208 (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK && |
| 208 state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) { | 209 state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) { |
| 209 return; | 210 return; |
| 210 } | 211 } |
| 211 | 212 |
| 212 bool new_online_state = | 213 bool new_online_state = |
| 213 network_state_informer_->state() == NetworkStateInformer::ONLINE; | 214 network_state_informer_->state() == NetworkStateInformer::ONLINE; |
| 214 delegate_->OnNetworkStateChanged(new_online_state); | 215 delegate_->OnNetworkStateChanged(new_online_state); |
| 215 | 216 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 DCHECK(online_state_); | 283 DCHECK(online_state_); |
| 283 if (delegate_ && online_state_) { | 284 if (delegate_ && online_state_) { |
| 284 network_config_requested_ = false; | 285 network_config_requested_ = false; |
| 285 network_config_done_ = true; | 286 network_config_done_ = true; |
| 286 delegate_->OnNetworkConfigRequested(false); | 287 delegate_->OnNetworkConfigRequested(false); |
| 287 Show(app_id_); | 288 Show(app_id_); |
| 288 } | 289 } |
| 289 } | 290 } |
| 290 | 291 |
| 291 } // namespace chromeos | 292 } // namespace chromeos |
| OLD | NEW |