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/extensions/chromeos/kiosk_apps_handler.h" | 5 #include "chrome/browser/ui/webui/extensions/chromeos/kiosk_apps_handler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <set> | 8 #include <set> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 *app_id = candidate_id; | 87 *app_id = candidate_id; |
88 return true; | 88 return true; |
89 } | 89 } |
90 | 90 |
91 } // namespace | 91 } // namespace |
92 | 92 |
93 KioskAppsHandler::KioskAppsHandler() | 93 KioskAppsHandler::KioskAppsHandler() |
94 : kiosk_app_manager_(KioskAppManager::Get()), | 94 : kiosk_app_manager_(KioskAppManager::Get()), |
95 initialized_(false), | 95 initialized_(false), |
96 is_kiosk_enabled_(false), | 96 is_kiosk_enabled_(false), |
| 97 is_auto_launch_enabled_(false), |
97 weak_ptr_factory_(this) { | 98 weak_ptr_factory_(this) { |
98 kiosk_app_manager_->AddObserver(this); | 99 kiosk_app_manager_->AddObserver(this); |
99 } | 100 } |
100 | 101 |
101 KioskAppsHandler::~KioskAppsHandler() { | 102 KioskAppsHandler::~KioskAppsHandler() { |
102 kiosk_app_manager_->RemoveObserver(this); | 103 kiosk_app_manager_->RemoveObserver(this); |
103 } | 104 } |
104 | 105 |
105 void KioskAppsHandler::RegisterMessages() { | 106 void KioskAppsHandler::RegisterMessages() { |
106 web_ui()->RegisterMessageCallback("initializeKioskAppSettings", | 107 web_ui()->RegisterMessageCallback("initializeKioskAppSettings", |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 app_dict); | 189 app_dict); |
189 } | 190 } |
190 | 191 |
191 void KioskAppsHandler::OnKioskAppDataLoadFailure(const std::string& app_id) { | 192 void KioskAppsHandler::OnKioskAppDataLoadFailure(const std::string& app_id) { |
192 base::StringValue app_id_value(app_id); | 193 base::StringValue app_id_value(app_id); |
193 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.showError", | 194 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.showError", |
194 app_id_value); | 195 app_id_value); |
195 } | 196 } |
196 | 197 |
197 | 198 |
198 void KioskAppsHandler::OnGetConsumerKioskModeStatus( | 199 void KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus( |
199 chromeos::KioskAppManager::ConsumerKioskModeStatus status) { | 200 chromeos::KioskAppManager::ConsumerKioskAutoLaunchStatus status) { |
200 initialized_ = true; | 201 initialized_ = true; |
201 is_kiosk_enabled_ = | 202 is_kiosk_enabled_ = |
202 ((status == KioskAppManager::CONSUMER_KIOSK_MODE_ENABLED) && | 203 chromeos::UserManager::Get()->IsCurrentUserOwner() || |
203 chromeos::UserManager::Get()->IsCurrentUserOwner()) || | 204 !base::SysInfo::IsRunningOnChromeOS(); |
| 205 |
| 206 is_auto_launch_enabled_ = |
| 207 status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED || |
204 !base::SysInfo::IsRunningOnChromeOS(); | 208 !base::SysInfo::IsRunningOnChromeOS(); |
205 | 209 |
206 if (is_kiosk_enabled_) { | 210 if (is_kiosk_enabled_) { |
207 base::FundamentalValue enabled(is_kiosk_enabled_); | 211 base::DictionaryValue kiosk_params; |
| 212 kiosk_params.SetBoolean("kioskEnabled", is_kiosk_enabled_); |
| 213 kiosk_params.SetBoolean("autoLaunchEnabled", is_auto_launch_enabled_); |
208 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.enableKiosk", | 214 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.enableKiosk", |
209 enabled); | 215 kiosk_params); |
210 } | 216 } |
211 } | 217 } |
212 | 218 |
213 | 219 |
214 void KioskAppsHandler::OnKioskAppsSettingsChanged() { | 220 void KioskAppsHandler::OnKioskAppsSettingsChanged() { |
215 SendKioskAppSettings(); | 221 SendKioskAppSettings(); |
216 } | 222 } |
217 | 223 |
218 void KioskAppsHandler::SendKioskAppSettings() { | 224 void KioskAppsHandler::SendKioskAppSettings() { |
219 if (!initialized_ || !is_kiosk_enabled_) | 225 if (!initialized_ || !is_kiosk_enabled_) |
(...skipping 21 matching lines...) Expand all Loading... |
241 apps_list->Append(app_info.release()); | 247 apps_list->Append(app_info.release()); |
242 } | 248 } |
243 settings.SetWithoutPathExpansion("apps", apps_list.release()); | 249 settings.SetWithoutPathExpansion("apps", apps_list.release()); |
244 | 250 |
245 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.setSettings", | 251 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.setSettings", |
246 settings); | 252 settings); |
247 } | 253 } |
248 | 254 |
249 void KioskAppsHandler::HandleInitializeKioskAppSettings( | 255 void KioskAppsHandler::HandleInitializeKioskAppSettings( |
250 const base::ListValue* args) { | 256 const base::ListValue* args) { |
251 KioskAppManager::Get()->GetConsumerKioskModeStatus( | 257 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( |
252 base::Bind(&KioskAppsHandler::OnGetConsumerKioskModeStatus, | 258 base::Bind(&KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus, |
253 weak_ptr_factory_.GetWeakPtr())); | 259 weak_ptr_factory_.GetWeakPtr())); |
254 } | 260 } |
255 | 261 |
256 void KioskAppsHandler::HandleGetKioskAppSettings(const base::ListValue* args) { | 262 void KioskAppsHandler::HandleGetKioskAppSettings(const base::ListValue* args) { |
257 SendKioskAppSettings(); | 263 SendKioskAppSettings(); |
258 } | 264 } |
259 | 265 |
260 | 266 |
261 void KioskAppsHandler::HandleAddKioskApp(const base::ListValue* args) { | 267 void KioskAppsHandler::HandleAddKioskApp(const base::ListValue* args) { |
262 if (!initialized_ || !is_kiosk_enabled_) | 268 if (!initialized_ || !is_kiosk_enabled_) |
(...skipping 16 matching lines...) Expand all Loading... |
279 return; | 285 return; |
280 | 286 |
281 std::string app_id; | 287 std::string app_id; |
282 CHECK(args->GetString(0, &app_id)); | 288 CHECK(args->GetString(0, &app_id)); |
283 | 289 |
284 kiosk_app_manager_->RemoveApp(app_id); | 290 kiosk_app_manager_->RemoveApp(app_id); |
285 } | 291 } |
286 | 292 |
287 void KioskAppsHandler::HandleEnableKioskAutoLaunch( | 293 void KioskAppsHandler::HandleEnableKioskAutoLaunch( |
288 const base::ListValue* args) { | 294 const base::ListValue* args) { |
289 if (!initialized_ || !is_kiosk_enabled_) | 295 if (!initialized_ || !is_kiosk_enabled_ || !is_auto_launch_enabled_) |
290 return; | 296 return; |
291 | 297 |
292 std::string app_id; | 298 std::string app_id; |
293 CHECK(args->GetString(0, &app_id)); | 299 CHECK(args->GetString(0, &app_id)); |
294 | 300 |
295 kiosk_app_manager_->SetAutoLaunchApp(app_id); | 301 kiosk_app_manager_->SetAutoLaunchApp(app_id); |
296 } | 302 } |
297 | 303 |
298 void KioskAppsHandler::HandleDisableKioskAutoLaunch( | 304 void KioskAppsHandler::HandleDisableKioskAutoLaunch( |
299 const base::ListValue* args) { | 305 const base::ListValue* args) { |
300 if (!initialized_ || !is_kiosk_enabled_) | 306 if (!initialized_ || !is_kiosk_enabled_ || !is_auto_launch_enabled_) |
301 return; | 307 return; |
302 | 308 |
303 std::string app_id; | 309 std::string app_id; |
304 CHECK(args->GetString(0, &app_id)); | 310 CHECK(args->GetString(0, &app_id)); |
305 | 311 |
306 std::string startup_app_id = kiosk_app_manager_->GetAutoLaunchApp(); | 312 std::string startup_app_id = kiosk_app_manager_->GetAutoLaunchApp(); |
307 if (startup_app_id != app_id) | 313 if (startup_app_id != app_id) |
308 return; | 314 return; |
309 | 315 |
310 kiosk_app_manager_->SetAutoLaunchApp(""); | 316 kiosk_app_manager_->SetAutoLaunchApp(""); |
311 } | 317 } |
312 | 318 |
313 void KioskAppsHandler::HandleSetDisableBailoutShortcut( | 319 void KioskAppsHandler::HandleSetDisableBailoutShortcut( |
314 const base::ListValue* args) { | 320 const base::ListValue* args) { |
315 if (!initialized_ || !is_kiosk_enabled_) | 321 if (!initialized_ || !is_kiosk_enabled_) |
316 return; | 322 return; |
317 | 323 |
318 bool disable_bailout_shortcut; | 324 bool disable_bailout_shortcut; |
319 CHECK(args->GetBoolean(0, &disable_bailout_shortcut)); | 325 CHECK(args->GetBoolean(0, &disable_bailout_shortcut)); |
320 | 326 |
321 CrosSettings::Get()->SetBoolean( | 327 CrosSettings::Get()->SetBoolean( |
322 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, | 328 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, |
323 !disable_bailout_shortcut); | 329 !disable_bailout_shortcut); |
324 } | 330 } |
325 | 331 |
326 } // namespace chromeos | 332 } // namespace chromeos |
OLD | NEW |