| 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> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
| 14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
| 15 #include "base/sys_info.h" | 15 #include "base/sys_info.h" |
| 16 #include "base/values.h" | 16 #include "base/values.h" |
| 17 #include "chrome/browser/chromeos/login/users/user_manager.h" | |
| 18 #include "chrome/browser/chromeos/settings/cros_settings.h" | 17 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | 18 #include "chrome/common/extensions/extension_constants.h" |
| 20 #include "chromeos/chromeos_switches.h" | 19 #include "chromeos/chromeos_switches.h" |
| 21 #include "chromeos/settings/cros_settings_names.h" | 20 #include "chromeos/settings/cros_settings_names.h" |
| 21 #include "components/user_manager/user_manager.h" |
| 22 #include "content/public/browser/web_ui.h" | 22 #include "content/public/browser/web_ui.h" |
| 23 #include "content/public/browser/web_ui_data_source.h" | 23 #include "content/public/browser/web_ui_data_source.h" |
| 24 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
| 25 #include "grit/chromium_strings.h" | 25 #include "grit/chromium_strings.h" |
| 26 #include "grit/generated_resources.h" | 26 #include "grit/generated_resources.h" |
| 27 #include "ui/base/l10n/l10n_util.h" | 27 #include "ui/base/l10n/l10n_util.h" |
| 28 #include "ui/base/webui/web_ui_util.h" | 28 #include "ui/base/webui/web_ui_util.h" |
| 29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 30 | 30 |
| 31 namespace chromeos { | 31 namespace chromeos { |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 191 } |
| 192 | 192 |
| 193 void KioskAppsHandler::OnKioskExtensionDownloadFailed( | 193 void KioskAppsHandler::OnKioskExtensionDownloadFailed( |
| 194 const std::string& app_id) { | 194 const std::string& app_id) { |
| 195 ShowError(app_id); | 195 ShowError(app_id); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus( | 198 void KioskAppsHandler::OnGetConsumerKioskAutoLaunchStatus( |
| 199 chromeos::KioskAppManager::ConsumerKioskAutoLaunchStatus status) { | 199 chromeos::KioskAppManager::ConsumerKioskAutoLaunchStatus status) { |
| 200 initialized_ = true; | 200 initialized_ = true; |
| 201 is_kiosk_enabled_ = | 201 is_kiosk_enabled_ = user_manager::UserManager::Get()->IsCurrentUserOwner() || |
| 202 chromeos::UserManager::Get()->IsCurrentUserOwner() || | 202 !base::SysInfo::IsRunningOnChromeOS(); |
| 203 !base::SysInfo::IsRunningOnChromeOS(); | |
| 204 | 203 |
| 205 is_auto_launch_enabled_ = | 204 is_auto_launch_enabled_ = |
| 206 status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED || | 205 status == KioskAppManager::CONSUMER_KIOSK_AUTO_LAUNCH_ENABLED || |
| 207 !base::SysInfo::IsRunningOnChromeOS(); | 206 !base::SysInfo::IsRunningOnChromeOS(); |
| 208 | 207 |
| 209 if (is_kiosk_enabled_) { | 208 if (is_kiosk_enabled_) { |
| 210 base::DictionaryValue kiosk_params; | 209 base::DictionaryValue kiosk_params; |
| 211 kiosk_params.SetBoolean("kioskEnabled", is_kiosk_enabled_); | 210 kiosk_params.SetBoolean("kioskEnabled", is_kiosk_enabled_); |
| 212 kiosk_params.SetBoolean("autoLaunchEnabled", is_auto_launch_enabled_); | 211 kiosk_params.SetBoolean("autoLaunchEnabled", is_auto_launch_enabled_); |
| 213 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.enableKiosk", | 212 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.enableKiosk", |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 344 | 343 |
| 345 void KioskAppsHandler::ShowError(const std::string& app_id) { | 344 void KioskAppsHandler::ShowError(const std::string& app_id) { |
| 346 base::StringValue app_id_value(app_id); | 345 base::StringValue app_id_value(app_id); |
| 347 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.showError", | 346 web_ui()->CallJavascriptFunction("extensions.KioskAppsOverlay.showError", |
| 348 app_id_value); | 347 app_id_value); |
| 349 | 348 |
| 350 kiosk_app_manager_->RemoveApp(app_id); | 349 kiosk_app_manager_->RemoveApp(app_id); |
| 351 } | 350 } |
| 352 | 351 |
| 353 } // namespace chromeos | 352 } // namespace chromeos |
| OLD | NEW |