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

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

Issue 79113002: kiosk: Network connectivity test during launch. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase, add policy and only show network error screen once Created 7 years 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 | Annotate | Revision Log
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/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"
11 #include "chromeos/network/network_state_handler.h"
9 #include "grit/browser_resources.h" 12 #include "grit/browser_resources.h"
10 #include "grit/chrome_unscaled_resources.h" 13 #include "grit/chrome_unscaled_resources.h"
11 #include "grit/chromium_strings.h" 14 #include "grit/chromium_strings.h"
12 #include "grit/generated_resources.h" 15 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h" 16 #include "ui/base/l10n/l10n_util.h"
14 #include "ui/base/resource/resource_bundle.h" 17 #include "ui/base/resource/resource_bundle.h"
15 #include "ui/base/webui/web_ui_util.h" 18 #include "ui/base/webui/web_ui_util.h"
16 19
17 namespace { 20 namespace {
18 21
19 const char kJsScreenPath[] = "login.AppLaunchSplashScreen"; 22 const char kJsScreenPath[] = "login.AppLaunchSplashScreen";
20 23
24 // Returns network name by service path.
25 std::string GetNetworkName(const std::string& service_path) {
26 const chromeos::NetworkState* network =
27 chromeos::NetworkHandler::Get()->network_state_handler()->GetNetworkState(
28 service_path);
29 if (!network)
30 return std::string();
31 return network->name();
32 }
33
21 } // namespace 34 } // namespace
22 35
23 namespace chromeos { 36 namespace chromeos {
24 37
25 AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler() 38 AppLaunchSplashScreenHandler::AppLaunchSplashScreenHandler(
39 const scoped_refptr<NetworkStateInformer>& network_state_informer,
40 ErrorScreenActor* error_screen_actor)
26 : BaseScreenHandler(kJsScreenPath), 41 : BaseScreenHandler(kJsScreenPath),
27 delegate_(NULL), 42 delegate_(NULL),
28 show_on_init_(false), 43 show_on_init_(false),
29 state_(APP_LAUNCH_STATE_LOADING_AUTH_FILE) { 44 state_(APP_LAUNCH_STATE_LOADING_AUTH_FILE),
45 network_state_informer_(network_state_informer),
46 error_screen_actor_(error_screen_actor) {
47 network_state_informer_->AddObserver(this);
30 } 48 }
31 49
32 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() { 50 AppLaunchSplashScreenHandler::~AppLaunchSplashScreenHandler() {
51 network_state_informer_->RemoveObserver(this);
33 } 52 }
34 53
35 void AppLaunchSplashScreenHandler::DeclareLocalizedValues( 54 void AppLaunchSplashScreenHandler::DeclareLocalizedValues(
36 LocalizedValuesBuilder* builder) { 55 LocalizedValuesBuilder* builder) {
37 56
38 builder->Add("appStartMessage", IDS_APP_START_NETWORK_WAIT_MESSAGE); 57 builder->Add("appStartMessage", IDS_APP_START_NETWORK_WAIT_MESSAGE);
39 builder->Add("configureNetwork", IDS_APP_START_CONFIGURE_NETWORK); 58 builder->Add("configureNetwork", IDS_APP_START_CONFIGURE_NETWORK);
40 59
41 const string16 product_os_name = 60 const string16 product_os_name =
42 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME); 61 l10n_util::GetStringUTF16(IDS_SHORT_PRODUCT_OS_NAME);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 115
97 void AppLaunchSplashScreenHandler::UpdateAppLaunchState(AppLaunchState state) { 116 void AppLaunchSplashScreenHandler::UpdateAppLaunchState(AppLaunchState state) {
98 if (state == state_) 117 if (state == state_)
99 return; 118 return;
100 119
101 state_ = state; 120 state_ = state;
102 if (page_is_ready()) { 121 if (page_is_ready()) {
103 SetLaunchText( 122 SetLaunchText(
104 l10n_util::GetStringUTF8(GetProgressMessageFromState(state_))); 123 l10n_util::GetStringUTF8(GetProgressMessageFromState(state_)));
105 } 124 }
125 UpdateState(ErrorScreenActor::ERROR_REASON_UPDATE);
106 } 126 }
107 127
108 void AppLaunchSplashScreenHandler::SetDelegate( 128 void AppLaunchSplashScreenHandler::SetDelegate(
109 AppLaunchSplashScreenHandler::Delegate* delegate) { 129 AppLaunchSplashScreenHandler::Delegate* delegate) {
110 delegate_ = delegate; 130 delegate_ = delegate;
111 } 131 }
112 132
133 void AppLaunchSplashScreenHandler::ShowNetworkConfigureUI() {
134 NetworkStateInformer::State state = network_state_informer_->state();
135 if (state == NetworkStateInformer::ONLINE) {
136 delegate_->OnNetworkStateChanged(true);
137 return;
138 }
139
140 const std::string network_path = network_state_informer_->network_path();
141 const std::string network_name = GetNetworkName(network_path);
142
143 error_screen_actor_->SetUIState(ErrorScreen::UI_STATE_KIOSK_MODE);
144 error_screen_actor_->AllowGuestSignin(false);
145 error_screen_actor_->AllowOfflineLogin(false);
146
147 switch (state) {
148 case NetworkStateInformer::CAPTIVE_PORTAL: {
149 error_screen_actor_->SetErrorState(
150 ErrorScreen::ERROR_STATE_PORTAL, network_name);
151 error_screen_actor_->FixCaptivePortal();
152
153 break;
154 }
155 case NetworkStateInformer::PROXY_AUTH_REQUIRED: {
156 error_screen_actor_->SetErrorState(
157 ErrorScreen::ERROR_STATE_PROXY, network_name);
158 break;
159 }
160 case NetworkStateInformer::OFFLINE: {
161 error_screen_actor_->SetErrorState(
162 ErrorScreen::ERROR_STATE_OFFLINE, network_name);
163 break;
164 }
165 default:
166 error_screen_actor_->SetErrorState(
167 ErrorScreen::ERROR_STATE_OFFLINE, network_name);
168 NOTREACHED();
169 break;
170 };
171
172 OobeUI::Screen screen = OobeUI::SCREEN_UNKNOWN;
173 OobeUI* oobe_ui = static_cast<OobeUI*>(web_ui()->GetController());
174 if (oobe_ui)
175 screen = oobe_ui->current_screen();
176
177 if (screen != OobeUI::SCREEN_ERROR_MESSAGE)
178 error_screen_actor_->Show(OobeDisplay::SCREEN_APP_LAUNCH_SPLASH, NULL);
179 }
180
181 void AppLaunchSplashScreenHandler::OnNetworkReady() {
182 // Purposely leave blank because the online case is handled in UpdateState
183 // call below.
184 }
185
186 void AppLaunchSplashScreenHandler::UpdateState(
187 ErrorScreenActor::ErrorReason reason) {
188 if (!delegate_ ||
189 (state_ != APP_LAUNCH_STATE_PREPARING_NETWORK &&
190 state_ != APP_LAUNCH_STATE_NETWORK_WAIT_TIMEOUT)) {
191 return;
192 }
193
194 NetworkStateInformer::State state = network_state_informer_->state();
195 delegate_->OnNetworkStateChanged(state == NetworkStateInformer::ONLINE);
196 }
197
113 void AppLaunchSplashScreenHandler::PopulateAppInfo( 198 void AppLaunchSplashScreenHandler::PopulateAppInfo(
114 base::DictionaryValue* out_info) { 199 base::DictionaryValue* out_info) {
115 KioskAppManager::App app; 200 KioskAppManager::App app;
116 KioskAppManager::Get()->GetApp(app_id_, &app); 201 KioskAppManager::Get()->GetApp(app_id_, &app);
117 202
118 if (app.name.empty()) 203 if (app.name.empty())
119 app.name = l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME); 204 app.name = l10n_util::GetStringUTF8(IDS_SHORT_PRODUCT_NAME);
120 205
121 if (app.icon.isNull()) { 206 if (app.icon.isNull()) {
122 app.icon = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed( 207 app.icon = *ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 } 243 }
159 244
160 void AppLaunchSplashScreenHandler::HandleCancelAppLaunch() { 245 void AppLaunchSplashScreenHandler::HandleCancelAppLaunch() {
161 if (delegate_) 246 if (delegate_)
162 delegate_->OnCancelAppLaunch(); 247 delegate_->OnCancelAppLaunch();
163 else 248 else
164 LOG(WARNING) << "No delegate set to handle cancel app launch"; 249 LOG(WARNING) << "No delegate set to handle cancel app launch";
165 } 250 }
166 251
167 } // namespace chromeos 252 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698