| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 !base::SysInfo::IsRunningOnChromeOS(); | 216 !base::SysInfo::IsRunningOnChromeOS(); |
| 217 | 217 |
| 218 is_auto_launch_enabled_ = | 218 is_auto_launch_enabled_ = |
| 219 status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED || | 219 status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED || |
| 220 !base::SysInfo::IsRunningOnChromeOS(); | 220 !base::SysInfo::IsRunningOnChromeOS(); |
| 221 | 221 |
| 222 if (is_kiosk_enabled_) { | 222 if (is_kiosk_enabled_) { |
| 223 base::DictionaryValue kiosk_params; | 223 base::DictionaryValue kiosk_params; |
| 224 kiosk_params.SetBoolean("kioskEnabled", is_kiosk_enabled_); | 224 kiosk_params.SetBoolean("kioskEnabled", is_kiosk_enabled_); |
| 225 kiosk_params.SetBoolean("autoLaunchEnabled", is_auto_launch_enabled_); | 225 kiosk_params.SetBoolean("autoLaunchEnabled", is_auto_launch_enabled_); |
| 226 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.enableKiosk", | 226 web_ui()->CallJavascriptFunctionUnsafe( |
| 227 kiosk_params); | 227 "extensions.KioskAppsOverlay.enableKiosk", kiosk_params); |
| 228 } | 228 } |
| 229 } | 229 } |
| 230 | 230 |
| 231 | 231 |
| 232 void KioskAppsHandler::OnKioskAppsSettingsChanged() { | 232 void KioskAppsHandler::OnKioskAppsSettingsChanged() { |
| 233 SendKioskAppSettings(); | 233 SendKioskAppSettings(); |
| 234 } | 234 } |
| 235 | 235 |
| 236 void KioskAppsHandler::SendKioskAppSettings() { | 236 void KioskAppsHandler::SendKioskAppSettings() { |
| 237 if (!initialized_ || !is_kiosk_enabled_) | 237 if (!initialized_ || !is_kiosk_enabled_) |
| (...skipping 17 matching lines...) Expand all Loading... |
| 255 std::unique_ptr<base::ListValue> apps_list(new base::ListValue); | 255 std::unique_ptr<base::ListValue> apps_list(new base::ListValue); |
| 256 for (size_t i = 0; i < apps.size(); ++i) { | 256 for (size_t i = 0; i < apps.size(); ++i) { |
| 257 const KioskAppManager::App& app_data = apps[i]; | 257 const KioskAppManager::App& app_data = apps[i]; |
| 258 | 258 |
| 259 std::unique_ptr<base::DictionaryValue> app_info(new base::DictionaryValue); | 259 std::unique_ptr<base::DictionaryValue> app_info(new base::DictionaryValue); |
| 260 PopulateAppDict(app_data, app_info.get()); | 260 PopulateAppDict(app_data, app_info.get()); |
| 261 apps_list->Append(app_info.release()); | 261 apps_list->Append(app_info.release()); |
| 262 } | 262 } |
| 263 settings.SetWithoutPathExpansion("apps", apps_list.release()); | 263 settings.SetWithoutPathExpansion("apps", apps_list.release()); |
| 264 | 264 |
| 265 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.setSettings", | 265 web_ui()->CallJavascriptFunctionUnsafe( |
| 266 settings); | 266 "extensions.KioskAppsOverlay.setSettings", settings); |
| 267 } | 267 } |
| 268 | 268 |
| 269 void KioskAppsHandler::HandleInitializeKioskAppSettings( | 269 void KioskAppsHandler::HandleInitializeKioskAppSettings( |
| 270 const base::ListValue* args) { | 270 const base::ListValue* args) { |
| 271 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( | 271 KioskAppManager::Get()->GetConsumerKioskAutoLaunchStatus( |
| 272 base::Bind(&KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus, | 272 base::Bind(&KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus, |
| 273 weak_ptr_factory_.GetWeakPtr())); | 273 weak_ptr_factory_.GetWeakPtr())); |
| 274 } | 274 } |
| 275 | 275 |
| 276 void KioskAppsHandler::HandleGetKioskAppSettings(const base::ListValue* args) { | 276 void KioskAppsHandler::HandleGetKioskAppSettings(const base::ListValue* args) { |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 } | 344 } |
| 345 | 345 |
| 346 void KioskAppsHandler::UpdateApp(const std::string& app_id) { | 346 void KioskAppsHandler::UpdateApp(const std::string& app_id) { |
| 347 KioskAppManager::App app_data; | 347 KioskAppManager::App app_data; |
| 348 if (!kiosk_app_manager_->GetApp(app_id, &app_data)) | 348 if (!kiosk_app_manager_->GetApp(app_id, &app_data)) |
| 349 return; | 349 return; |
| 350 | 350 |
| 351 base::DictionaryValue app_dict; | 351 base::DictionaryValue app_dict; |
| 352 PopulateAppDict(app_data, &app_dict); | 352 PopulateAppDict(app_data, &app_dict); |
| 353 | 353 |
| 354 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.updateApp", | 354 web_ui()->CallJavascriptFunctionUnsafe( |
| 355 app_dict); | 355 "extensions.KioskAppsOverlay.updateApp", app_dict); |
| 356 } | 356 } |
| 357 | 357 |
| 358 void KioskAppsHandler::ShowError(const std::string& app_id) { | 358 void KioskAppsHandler::ShowError(const std::string& app_id) { |
| 359 base::StringValue app_id_value(app_id); | 359 base::StringValue app_id_value(app_id); |
| 360 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.showError", | 360 web_ui()->CallJavascriptFunctionUnsafe( |
| 361 app_id_value); | 361 "extensions.KioskAppsOverlay.showError", app_id_value); |
| 362 | 362 |
| 363 kiosk_app_manager_->RemoveApp(app_id, owner_settings_service_); | 363 kiosk_app_manager_->RemoveApp(app_id, owner_settings_service_); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace chromeos | 366 } // namespace chromeos |
| OLD | NEW |