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_requested_(false) { | |
47 network_state_informer_->AddObserver(this); | 49 network_state_informer_->AddObserver(this); |
48 } | 50 } |
49 | 51 |
50 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() { | 52 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() { |
51 network_state_informer_->RemoveObserver(this); | 53 network_state_informer_->RemoveObserver(this); |
52 } | 54 } |
53 | 55 |
54 void AppLaunchSplashScreenHandler::DeclareLocalizedValues( | 56 void AppLaunchSplashScreenHandler::DeclareLocalizedValues( |
55 LocalizedValuesBuilder* builder) { | 57 LocalizedValuesBuilder* builder) { |
56 | 58 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
94 | 96 |
95 SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); | 97 SetLaunchText(l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); |
96 ShowScreen(OobeUI::kScreenAppLaunchSplash, &data); | 98 ShowScreen(OobeUI::kScreenAppLaunchSplash, &data); |
97 } | 99 } |
98 | 100 |
99 void AppLaunchSplashScreenHandler::RegisterMessages() { | 101 void AppLaunchSplashScreenHandler::RegisterMessages() { |
100 AddCallback("configureNetwork", | 102 AddCallback("configureNetwork", |
101 &AppLaunchSplashScreenHandler::HandleConfigureNetwork); | 103 &AppLaunchSplashScreenHandler::HandleConfigureNetwork); |
102 AddCallback("cancelAppLaunch", | 104 AddCallback("cancelAppLaunch", |
103 &AppLaunchSplashScreenHandler::HandleCancelAppLaunch); | 105 &AppLaunchSplashScreenHandler::HandleCancelAppLaunch); |
106 AddCallback("continueAppLaunch", | |
107 &AppLaunchSplashScreenHandler::HandleContinueAppLaunch); | |
108 AddCallback("networkConfigRequest", | |
109 &AppLaunchSplashScreenHandler::HandleNetworkConfigRequested); | |
104 } | 110 } |
105 | 111 |
106 void AppLaunchSplashScreenHandler::PrepareToShow() { | 112 void AppLaunchSplashScreenHandler::PrepareToShow() { |
107 } | 113 } |
108 | 114 |
109 void AppLaunchSplashScreenHandler::Hide() { | 115 void AppLaunchSplashScreenHandler::Hide() { |
110 } | 116 } |
111 | 117 |
112 void AppLaunchSplashScreenHandler::ToggleNetworkConfig(bool visible) { | 118 void AppLaunchSplashScreenHandler::ToggleNetworkConfig(bool visible) { |
113 CallJS("toggleNetworkConfig", visible); | 119 CallJS("toggleNetworkConfig", visible); |
(...skipping 12 matching lines...) Expand all Loading... | |
126 } | 132 } |
127 | 133 |
128 void AppLaunchSplashScreenHandler::SetDelegate( | 134 void AppLaunchSplashScreenHandler::SetDelegate( |
129 AppLaunchSplashScreenHandler::Delegate* delegate) { | 135 AppLaunchSplashScreenHandler::Delegate* delegate) { |
130 delegate_ = delegate; | 136 delegate_ = delegate; |
131 } | 137 } |
132 | 138 |
133 void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() { | 139 void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() { |
134 NetworkStateInformer::State state = network_state_informer_->state(); | 140 NetworkStateInformer::State state = network_state_informer_->state(); |
135 if (state == NetworkStateInformer::ONLINE) { | 141 if (state == NetworkStateInformer::ONLINE) { |
136 delegate_->OnNetworkStateChanged(true); | 142 online_state_ = true; |
137 return; | 143 if (!network_config_requested_) { |
144 delegate_->OnNetworkStateChanged(true); | |
145 return; | |
146 } | |
138 } | 147 } |
139 | 148 |
140 const std::string network_path = network_state_informer_->network_path(); | 149 const std::string network_path = network_state_informer_->network_path(); |
141 const std::string network_name = GetNetworkName(network_path); | 150 const std::string network_name = GetNetworkName(network_path); |
142 | 151 |
143 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_KIOSK_MODE); | 152 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_KIOSK_MODE); |
144 error_screen_actor_->AllowGuestSignin(false); | 153 error_screen_actor_->AllowGuestSignin(false); |
145 error_screen_actor_->AllowOfflineLogin(false); | 154 error_screen_actor_->AllowOfflineLogin(false); |
146 | 155 |
147 switch (state) { | 156 switch (state) { |
148 case NetworkStateInformer::CAPTIVE_PORTAL: { | 157 case NetworkStateInformer::CAPTIVE_PORTAL: { |
149 error_screen_actor_->SetErrorState( | 158 error_screen_actor_->SetErrorState( |
150 ErrorScreen::ERROR_STATE_PORTAL, network_name); | 159 ErrorScreen::ERROR_STATE_PORTAL, network_name); |
151 error_screen_actor_->FixCaptivePortal(); | 160 error_screen_actor_->FixCaptivePortal(); |
152 | 161 |
153 break; | 162 break; |
154 } | 163 } |
155 case NetworkStateInformer::PROXY_AUTH_REQUIRED: { | 164 case NetworkStateInformer::PROXY_AUTH_REQUIRED: { |
156 error_screen_actor_->SetErrorState( | 165 error_screen_actor_->SetErrorState( |
157 ErrorScreen::ERROR_STATE_PROXY, network_name); | 166 ErrorScreen::ERROR_STATE_PROXY, network_name); |
158 break; | 167 break; |
159 } | 168 } |
160 case NetworkStateInformer::OFFLINE: { | 169 case NetworkStateInformer::OFFLINE: { |
161 error_screen_actor_->SetErrorState( | 170 error_screen_actor_->SetErrorState( |
162 ErrorScreen::ERROR_STATE_OFFLINE, network_name); | 171 ErrorScreen::ERROR_STATE_OFFLINE, network_name); |
163 break; | 172 break; |
164 } | 173 } |
174 case NetworkStateInformer::ONLINE: { | |
175 error_screen_actor_->SetErrorState( | |
176 ErrorScreen::ERROR_STATE_KIOSK_ONLINE, network_name); | |
177 break; | |
178 } | |
165 default: | 179 default: |
166 error_screen_actor_->SetErrorState( | 180 error_screen_actor_->SetErrorState( |
167 ErrorScreen::ERROR_STATE_OFFLINE, network_name); | 181 ErrorScreen::ERROR_STATE_OFFLINE, network_name); |
168 NOTREACHED(); | 182 NOTREACHED(); |
169 break; | 183 break; |
170 }; | 184 }; |
171 | 185 |
172 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; | 186 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN; |
173 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); | 187 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController()); |
174 if (oobe_ui) | 188 if (oobe_ui) |
(...skipping 13 matching lines...) Expand all Loading... | |
188 } | 202 } |
189 | 203 |
190 void AppLaunchSplashScreenHandler::UpdateState( | 204 void AppLaunchSplashScreenHandler::UpdateState( |
191 ErrorScreenActor::ErrorReason reason) { | 205 ErrorScreenActor::ErrorReason reason) { |
192 if (!delegate_ || | 206 if (!delegate_ || |
193 (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK && | 207 (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK && |
194 state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) { | 208 state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) { |
195 return; | 209 return; |
196 } | 210 } |
197 | 211 |
198 NetworkStateInformer::State state = network_state_informer_->state(); | 212 bool new_online_state = |
199 delegate_->OnNetworkStateChanged(state == NetworkStateInformer::ONLINE); | 213 network_state_informer_->state() == NetworkStateInformer::ONLINE; |
214 if (new_online_state != online_state_) | |
215 ShowNetworkConfigureUI(); | |
xiyuan
2014/03/25 05:21:19
This would by-pass the owner auth check or policy
zel
2014/03/25 22:26:32
Done.
| |
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_) { | |
276 network_config_requested_ = true; | |
277 delegate_->OnNetworkConfigRequested(true); | |
278 } else { | |
279 LOG(WARNING) << "No delegate set to handle cancel app launch"; | |
xiyuan
2014/03/25 05:21:19
The message needs to be updated.
| |
280 } | |
281 } | |
282 | |
283 void AppLaunchSplashScreenHandler::HandleContinueAppLaunch() { | |
284 DCHECK(online_state_); | |
285 if (delegate_ && online_state_) { | |
286 network_config_requested_ = false; | |
287 delegate_->OnNetworkConfigRequested(false); | |
288 delegate_->OnNetworkStateChanged(true); | |
289 } | |
290 } | |
291 | |
256 } // namespace chromeos | 292 } // namespace chromeos |
OLD | NEW |