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/error_screen_actor.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 "chromeos/network/network_state.h" | 10 #include "chromeos/network/network_state.h" |
(...skipping 25 matching lines...) Expand all Loading... |
36 namespace chromeos { | 36 namespace chromeos { |
37 | 37 |
38 AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler( | 38 AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler( |
39 const scoped_refptr<NetworkStateInformer>& network_state_informer, | 39 const scoped_refptr<NetworkStateInformer>& network_state_informer, |
40 ErrorScreenActor* error_screen_actor) | 40 ErrorScreenActor* error_screen_actor) |
41 : BaseScreenHandler(kJsScreenPath), | 41 : BaseScreenHandler(kJsScreenPath), |
42 delegate_(NULL), | 42 delegate_(NULL), |
43 show_on_init_(false), | 43 show_on_init_(false), |
44 state_(APP_LAUNCH_STATE_LOADING_AUTH_FILE), | 44 state_(APP_LAUNCH_STATE_LOADING_AUTH_FILE), |
45 network_state_informer_(network_state_informer), | 45 network_state_informer_(network_state_informer), |
46 error_screen_actor_(error_screen_actor) { | 46 error_screen_actor_(error_screen_actor), |
| 47 online_state_(false), |
| 48 network_config_done_(false), |
| 49 network_config_requested_(false) { |
47 network_state_informer_->AddObserver(this); | 50 network_state_informer_->AddObserver(this); |
48 } | 51 } |
49 | 52 |
50 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() { | 53 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() { |
51 network_state_informer_->RemoveObserver(this); | 54 network_state_informer_->RemoveObserver(this); |
52 } | 55 } |
53 | 56 |
54 void AppLaunchSplashScreenHandler::DeclareLocalizedValues( | 57 void AppLaunchSplashScreenHandler::DeclareLocalizedValues( |
55 LocalizedValuesBuilder* builder) { | 58 LocalizedValuesBuilder* builder) { |
56 | 59 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 | 97 |
95 SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); | 98 SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); |
96 ShowScreen(OobeUI::kScreenAppLaunchSplash, &data); | 99 ShowScreen(OobeUI::kScreenAppLaunchSplash, &data); |
97 } | 100 } |
98 | 101 |
99 void AppLaunchSplashScreenHandler::RegisterMessages() { | 102 void AppLaunchSplashScreenHandler::RegisterMessages() { |
100 AddCallback("configureNetwork", | 103 AddCallback("configureNetwork", |
101 &AppLaunchSplashScreenHandler::HandleConfigureNetwork); | 104 &AppLaunchSplashScreenHandler::HandleConfigureNetwork); |
102 AddCallback("cancelAppLaunch", | 105 AddCallback("cancelAppLaunch", |
103 &AppLaunchSplashScreenHandler::HandleCancelAppLaunch); | 106 &AppLaunchSplashScreenHandler::HandleCancelAppLaunch); |
| 107 AddCallback("continueAppLaunch", |
| 108 &AppLaunchSplashScreenHandler::HandleContinueAppLaunch); |
| 109 AddCallback("networkConfigRequest", |
| 110 &AppLaunchSplashScreenHandler::HandleNetworkConfigRequested); |
104 } | 111 } |
105 | 112 |
106 void AppLaunchSplashScreenHandler::PrepareToShow() { | 113 void AppLaunchSplashScreenHandler::PrepareToShow() { |
107 } | 114 } |
108 | 115 |
109 void AppLaunchSplashScreenHandler::Hide() { | 116 void AppLaunchSplashScreenHandler::Hide() { |
110 } | 117 } |
111 | 118 |
112 void AppLaunchSplashScreenHandler::ToggleNetworkConfig(bool visible) { | 119 void AppLaunchSplashScreenHandler::ToggleNetworkConfig(bool visible) { |
113 CallJS("toggleNetworkConfig", visible); | 120 CallJS("toggleNetworkConfig", visible); |
(...skipping 12 matching lines...) Expand all Loading... |
126 } | 133 } |
127 | 134 |
128 void AppLaunchSplashScreenHandler::SetDelegate( | 135 void AppLaunchSplashScreenHandler::SetDelegate( |
129 AppLaunchSplashScreenHandler::Delegate* delegate) { | 136 AppLaunchSplashScreenHandler::Delegate* delegate) { |
130 delegate_ = delegate; | 137 delegate_ = delegate; |
131 } | 138 } |
132 | 139 |
133 void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() { | 140 void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() { |
134 NetworkStateInformer::State state = network_state_informer_->state(); | 141 NetworkStateInformer::State state = network_state_informer_->state(); |
135 if (state == NetworkStateInformer::ONLINE) { | 142 if (state == NetworkStateInformer::ONLINE) { |
136 delegate_->OnNetworkStateChanged(true); | 143 online_state_ = true; |
137 return; | 144 if (!network_config_requested_) { |
| 145 delegate_->OnNetworkStateChanged(true); |
| 146 return; |
| 147 } |
138 } | 148 } |
139 | 149 |
140 const std::string network_path = network_state_informer_->network_path(); | 150 const std::string network_path = network_state_informer_->network_path(); |
141 const std::string network_name = GetNetworkName(network_path); | 151 const std::string network_name = GetNetworkName(network_path); |
142 | 152 |
143 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_KIOSK_MODE); | 153 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_KIOSK_MODE); |
144 error_screen_actor_->AllowGuestSignin(false); | 154 error_screen_actor_->AllowGuestSignin(false); |
145 error_screen_actor_->AllowOfflineLogin(false); | 155 error_screen_actor_->AllowOfflineLogin(false); |
146 | 156 |
147 switch (state) { | 157 switch (state) { |
148 case NetworkStateInformer::CAPTIVE_PORTAL: { | 158 case NetworkStateInformer::CAPTIVE_PORTAL: { |
149 error_screen_actor_->SetErrorState( | 159 error_screen_actor_->SetErrorState( |
150 ErrorScreen::ERROR_STATE_PORTAL, network_name); | 160 ErrorScreen::ERROR_STATE_PORTAL, network_name); |
151 error_screen_actor_->FixCaptivePortal(); | 161 error_screen_actor_->FixCaptivePortal(); |
152 | 162 |
153 break; | 163 break; |
154 } | 164 } |
155 case NetworkStateInformer::PROXY_AUTH_REQUIRED: { | 165 case NetworkStateInformer::PROXY_AUTH_REQUIRED: { |
156 error_screen_actor_->SetErrorState( | 166 error_screen_actor_->SetErrorState( |
157 ErrorScreen::ERROR_STATE_PROXY, network_name); | 167 ErrorScreen::ERROR_STATE_PROXY, network_name); |
158 break; | 168 break; |
159 } | 169 } |
160 case NetworkStateInformer::OFFLINE: { | 170 case NetworkStateInformer::OFFLINE: { |
161 error_screen_actor_->SetErrorState( | 171 error_screen_actor_->SetErrorState( |
162 ErrorScreen::ERROR_STATE_OFFLINE, network_name); | 172 ErrorScreen::ERROR_STATE_OFFLINE, network_name); |
163 break; | 173 break; |
164 } | 174 } |
| 175 case NetworkStateInformer::ONLINE: { |
| 176 error_screen_actor_->SetErrorState( |
| 177 ErrorScreen::ERROR_STATE_KIOSK_ONLINE, network_name); |
| 178 break; |
| 179 } |
165 default: | 180 default: |
166 error_screen_actor_->SetErrorState( | 181 error_screen_actor_->SetErrorState( |
167 ErrorScreen::ERROR_STATE_OFFLINE, network_name); | 182 ErrorScreen::ERROR_STATE_OFFLINE, network_name); |
168 NOTREACHED(); | 183 NOTREACHED(); |
169 break; | 184 break; |
170 }; | 185 }; |
171 | 186 |
172 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; | 187 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; |
173 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); | 188 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); |
174 if (oobe_ui) | 189 if (oobe_ui) |
(...skipping 13 matching lines...) Expand all Loading... |
188 } | 203 } |
189 | 204 |
190 void AppLaunchSplashScreenHandler::UpdateState( | 205 void AppLaunchSplashScreenHandler::UpdateState( |
191 ErrorScreenActor::ErrorReason reason) { | 206 ErrorScreenActor::ErrorReason reason) { |
192 if (!delegate_ || | 207 if (!delegate_ || |
193 (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK && | 208 (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK && |
194 state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) { | 209 state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) { |
195 return; | 210 return; |
196 } | 211 } |
197 | 212 |
198 NetworkStateInformer::State state = network_state_informer_->state(); | 213 bool new_online_state = |
199 delegate_->OnNetworkStateChanged(state == NetworkStateInformer::ONLINE); | 214 network_state_informer_->state() == NetworkStateInformer::ONLINE; |
| 215 delegate_->OnNetworkStateChanged(new_online_state); |
| 216 |
| 217 online_state_ = new_online_state; |
200 } | 218 } |
201 | 219 |
202 void AppLaunchSplashScreenHandler::PopulateAppInfo( | 220 void AppLaunchSplashScreenHandler::PopulateAppInfo( |
203 base::DictionaryValue* out_info) { | 221 base::DictionaryValue* out_info) { |
204 KioskAppManager::App app; | 222 KioskAppManager::App app; |
205 KioskAppManager::Get()->GetApp(app_id_, &app); | 223 KioskAppManager::Get()->GetApp(app_id_, &app); |
206 | 224 |
207 if (app.name.empty()) | 225 if (app.name.empty()) |
208 app.name = l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME); | 226 app.name = l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME); |
209 | 227 |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 LOG(WARNING) << "No delegate set to handle network configuration."; | 264 LOG(WARNING) << "No delegate set to handle network configuration."; |
247 } | 265 } |
248 | 266 |
249 void AppLaunchSplashScreenHandler::HandleCancelAppLaunch() { | 267 void AppLaunchSplashScreenHandler::HandleCancelAppLaunch() { |
250 if (delegate_) | 268 if (delegate_) |
251 delegate_->OnCancelAppLaunch(); | 269 delegate_->OnCancelAppLaunch(); |
252 else | 270 else |
253 LOG(WARNING) << "No delegate set to handle cancel app launch"; | 271 LOG(WARNING) << "No delegate set to handle cancel app launch"; |
254 } | 272 } |
255 | 273 |
| 274 void AppLaunchSplashScreenHandler::HandleNetworkConfigRequested() { |
| 275 if (!delegate_ || network_config_done_) |
| 276 return; |
| 277 |
| 278 network_config_requested_ = true; |
| 279 delegate_->OnNetworkConfigRequested(true); |
| 280 } |
| 281 |
| 282 void AppLaunchSplashScreenHandler::HandleContinueAppLaunch() { |
| 283 DCHECK(online_state_); |
| 284 if (delegate_ && online_state_) { |
| 285 network_config_requested_ = false; |
| 286 network_config_done_ = true; |
| 287 delegate_->OnNetworkConfigRequested(false); |
| 288 Show(app_id_); |
| 289 } |
| 290 } |
| 291 |
256 } // namespace chromeos | 292 } // namespace chromeos |
OLD | NEW |