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(); | 204 !base::SysInfo::IsRunningOnChromeOS(); |
205 | 205 |
| 206 is_auto_launch_enabled_ = |
| 207 status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED; |
| 208 |
206 if (is_kiosk_enabled_) { | 209 if (is_kiosk_enabled_) { |
207 base::FundamentalValue enabled(is_kiosk_enabled_); | 210 base::DictionaryValue kiosk_params; |
| 211 kiosk_params.SetBoolean("kioskEnabled", is_kiosk_enabled_); |
| 212 kiosk_params.SetBoolean("autoLaunchEnabled", is_auto_launch_enabled_); |
208 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.enableKiosk", | 213 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.enableKiosk", |
209 enabled); | 214 kiosk_params); |
210 } | 215 } |
211 } | 216 } |
212 | 217 |
213 | 218 |
214 void KioskAppsHandler::OnKioskAppsSettingsChanged() { | 219 void KioskAppsHandler::OnKioskAppsSettingsChanged() { |
215 SendKioskAppSettings(); | 220 SendKioskAppSettings(); |
216 } | 221 } |
217 | 222 |
218 void KioskAppsHandler::SendKioskAppSettings() { | 223 void KioskAppsHandler::SendKioskAppSettings() { |
219 if (!initialized_ || !is_kiosk_enabled_) | 224 if (!initialized_ || !is_kiosk_enabled_) |
(...skipping 21 matching lines...) Expand all Loading... |
241 apps_list->Append(app_info.release()); | 246 apps_list->Append(app_info.release()); |
242 } | 247 } |
243 settings.SetWithoutPathExpansion("apps", apps_list.release()); | 248 settings.SetWithoutPathExpansion("apps", apps_list.release()); |
244 | 249 |
245 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.setSettings", | 250 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.setSettings", |
246 settings); | 251 settings); |
247 } | 252 } |
248 | 253 |
249 void KioskAppsHandler::HandleInitializeKioskAppSettings( | 254 void KioskAppsHandler::HandleInitializeKioskAppSettings( |
250 const base::ListValue* args) { | 255 const base::ListValue* args) { |
251 KioskAppManager::Get()->GetConsumerKioskModeStatus( | 256 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( |
252 base::Bind(&KioskAppsHandler::OnGetConsumerKioskModeStatus, | 257 base::Bind(&KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus, |
253 weak_ptr_factory_.GetWeakPtr())); | 258 weak_ptr_factory_.GetWeakPtr())); |
254 } | 259 } |
255 | 260 |
256 void KioskAppsHandler::HandleGetKioskAppSettings(const base::ListValue* args) { | 261 void KioskAppsHandler::HandleGetKioskAppSettings(const base::ListValue* args) { |
257 SendKioskAppSettings(); | 262 SendKioskAppSettings(); |
258 } | 263 } |
259 | 264 |
260 | 265 |
261 void KioskAppsHandler::HandleAddKioskApp(const base::ListValue* args) { | 266 void KioskAppsHandler::HandleAddKioskApp(const base::ListValue* args) { |
262 if (!initialized_ || !is_kiosk_enabled_) | 267 if (!initialized_ || !is_kiosk_enabled_) |
(...skipping 16 matching lines...) Expand all Loading... |
279 return; | 284 return; |
280 | 285 |
281 std::string app_id; | 286 std::string app_id; |
282 CHECK(args->GetString(0, &app_id)); | 287 CHECK(args->GetString(0, &app_id)); |
283 | 288 |
284 kiosk_app_manager_->RemoveApp(app_id); | 289 kiosk_app_manager_->RemoveApp(app_id); |
285 } | 290 } |
286 | 291 |
287 void KioskAppsHandler::HandleEnableKioskAutoLaunch( | 292 void KioskAppsHandler::HandleEnableKioskAutoLaunch( |
288 const base::ListValue* args) { | 293 const base::ListValue* args) { |
289 if (!initialized_ || !is_kiosk_enabled_) | 294 if (!initialized_ || !is_kiosk_enabled_ || !is_auto_launch_enabled_) |
290 return; | 295 return; |
291 | 296 |
292 std::string app_id; | 297 std::string app_id; |
293 CHECK(args->GetString(0, &app_id)); | 298 CHECK(args->GetString(0, &app_id)); |
294 | 299 |
295 kiosk_app_manager_->SetAutoLaunchApp(app_id); | 300 kiosk_app_manager_->SetAutoLaunchApp(app_id); |
296 } | 301 } |
297 | 302 |
298 void KioskAppsHandler::HandleDisableKioskAutoLaunch( | 303 void KioskAppsHandler::HandleDisableKioskAutoLaunch( |
299 const base::ListValue* args) { | 304 const base::ListValue* args) { |
300 if (!initialized_ || !is_kiosk_enabled_) | 305 if (!initialized_ || !is_kiosk_enabled_ || !is_auto_launch_enabled_) |
301 return; | 306 return; |
302 | 307 |
303 std::string app_id; | 308 std::string app_id; |
304 CHECK(args->GetString(0, &app_id)); | 309 CHECK(args->GetString(0, &app_id)); |
305 | 310 |
306 std::string startup_app_id = kiosk_app_manager_->GetAutoLaunchApp(); | 311 std::string startup_app_id = kiosk_app_manager_->GetAutoLaunchApp(); |
307 if (startup_app_id != app_id) | 312 if (startup_app_id != app_id) |
308 return; | 313 return; |
309 | 314 |
310 kiosk_app_manager_->SetAutoLaunchApp(""); | 315 kiosk_app_manager_->SetAutoLaunchApp(""); |
311 } | 316 } |
312 | 317 |
313 void KioskAppsHandler::HandleSetDisableBailoutShortcut( | 318 void KioskAppsHandler::HandleSetDisableBailoutShortcut( |
314 const base::ListValue* args) { | 319 const base::ListValue* args) { |
315 if (!initialized_ || !is_kiosk_enabled_) | 320 if (!initialized_ || !is_kiosk_enabled_) |
316 return; | 321 return; |
317 | 322 |
318 bool disable_bailout_shortcut; | 323 bool disable_bailout_shortcut; |
319 CHECK(args->GetBoolean(0, &disable_bailout_shortcut)); | 324 CHECK(args->GetBoolean(0, &disable_bailout_shortcut)); |
320 | 325 |
321 CrosSettings::Get()->SetBoolean( | 326 CrosSettings::Get()->SetBoolean( |
322 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, | 327 kAccountsPrefDeviceLocalAccountAutoLoginBailoutEnabled, |
323 !disable_bailout_shortcut); | 328 !disable_bailout_shortcut); |
324 } | 329 } |
325 | 330 |
326 } // namespace chromeos | 331 } // namespace chromeos |
OLD | NEW |