Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: chrome/browser/ui/webui/chromeos/login/app_launch_splash_screen_handler.cc

Issue 872633008: Migrate (Network)ErrorScreen to ScreenContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nit Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "components/login/localized_values_builder.h" 14 #include "components/login/localized_values_builder.h"
15 #include "grit/chrome_unscaled_resources.h" 15 #include "grit/chrome_unscaled_resources.h"
16 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
18 #include "ui/base/webui/web_ui_util.h" 18 #include "ui/base/webui/web_ui_util.h"
(...skipping 10 matching lines...) Expand all
29 if (!network) 29 if (!network)
30 return std::string(); 30 return std::string();
31 return network->name(); 31 return network->name();
32 } 32 }
33 33
34 } // namespace 34 } // namespace
35 35
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 NetworkErrorModel* network_error_model)
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 network_error_model_(network_error_model),
47 online_state_(false), 47 online_state_(false),
48 network_config_done_(false), 48 network_config_done_(false),
49 network_config_requested_(false) { 49 network_config_requested_(false) {
50 network_state_informer_->AddObserver(this); 50 network_state_informer_->AddObserver(this);
51 } 51 }
52 52
53 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() { 53 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() {
54 network_state_informer_->RemoveObserver(this); 54 network_state_informer_->RemoveObserver(this);
55 } 55 }
56 56
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698