| 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/chromeos/app_mode/kiosk_app_manager.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/chromeos/policy/device_local_account.h" | 24 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 25 #include "chrome/browser/chromeos/settings/cros_settings.h" | 25 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 26 #include "chrome/browser/chromeos/settings/owner_key_util.h" | 26 #include "chrome/browser/chromeos/settings/owner_key_util.h" |
| 27 #include "chrome/browser/extensions/external_provider_impl.h" | 27 #include "chrome/browser/extensions/external_provider_impl.h" |
| 28 #include "chrome/common/chrome_paths.h" | 28 #include "chrome/common/chrome_paths.h" |
| 29 #include "chrome/common/extensions/extension_constants.h" | 29 #include "chrome/common/extensions/extension_constants.h" |
| 30 #include "chromeos/chromeos_paths.h" | 30 #include "chromeos/chromeos_paths.h" |
| 31 #include "chromeos/cryptohome/async_method_caller.h" | 31 #include "chromeos/cryptohome/async_method_caller.h" |
| 32 #include "chromeos/settings/cros_settings_names.h" | 32 #include "chromeos/settings/cros_settings_names.h" |
| 33 #include "content/public/browser/browser_thread.h" | 33 #include "content/public/browser/browser_thread.h" |
| 34 #include "ui/keyboard/keyboard_util.h" |
| 34 | 35 |
| 35 namespace chromeos { | 36 namespace chromeos { |
| 36 | 37 |
| 37 namespace { | 38 namespace { |
| 38 | 39 |
| 39 // Domain that is used for kiosk-app account IDs. | 40 // Domain that is used for kiosk-app account IDs. |
| 40 const char kKioskAppAccountDomain[] = "kiosk-apps"; | 41 const char kKioskAppAccountDomain[] = "kiosk-apps"; |
| 41 | 42 |
| 42 std::string GenerateKioskAppAccountId(const std::string& app_id) { | 43 std::string GenerateKioskAppAccountId(const std::string& app_id) { |
| 43 return app_id + '@' + kKioskAppAccountDomain; | 44 return app_id + '@' + kKioskAppAccountDomain; |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 | 378 |
| 378 UpdateAppData(); | 379 UpdateAppData(); |
| 379 local_accounts_subscription_ = | 380 local_accounts_subscription_ = |
| 380 CrosSettings::Get()->AddSettingsObserver( | 381 CrosSettings::Get()->AddSettingsObserver( |
| 381 kAccountsPrefDeviceLocalAccounts, | 382 kAccountsPrefDeviceLocalAccounts, |
| 382 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this))); | 383 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this))); |
| 383 local_account_auto_login_id_subscription_ = | 384 local_account_auto_login_id_subscription_ = |
| 384 CrosSettings::Get()->AddSettingsObserver( | 385 CrosSettings::Get()->AddSettingsObserver( |
| 385 kAccountsPrefDeviceLocalAccountAutoLoginId, | 386 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 386 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this))); | 387 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this))); |
| 388 keyboard_layout_subscription_ = CrosSettings::Get()->AddSettingsObserver( |
| 389 kKioskVirtualKeyboardLayout, |
| 390 base::Bind(&KioskAppManager::UpdateKeyboardLayout, |
| 391 base::Unretained(this))); |
| 392 } |
| 393 |
| 394 void KioskAppManager::UpdateKeyboardLayout() { |
| 395 std::string layout; |
| 396 CrosSettings::Get()->GetString(kKioskVirtualKeyboardLayout, &layout); |
| 397 // TODO(rsadam@): Use the policy specified layout instead of simply |
| 398 // enabling the keyboard to the default layout. |
| 399 keyboard::SetKioskKeyboardEnabled(!layout.empty()); |
| 387 } | 400 } |
| 388 | 401 |
| 389 KioskAppManager::~KioskAppManager() {} | 402 KioskAppManager::~KioskAppManager() {} |
| 390 | 403 |
| 391 void KioskAppManager::CleanUp() { | 404 void KioskAppManager::CleanUp() { |
| 392 local_accounts_subscription_.reset(); | 405 local_accounts_subscription_.reset(); |
| 393 local_account_auto_login_id_subscription_.reset(); | 406 local_account_auto_login_id_subscription_.reset(); |
| 407 keyboard_layout_subscription_.reset(); |
| 394 apps_.clear(); | 408 apps_.clear(); |
| 395 external_cache_.reset(); | 409 external_cache_.reset(); |
| 396 } | 410 } |
| 397 | 411 |
| 398 const KioskAppData* KioskAppManager::GetAppData( | 412 const KioskAppData* KioskAppManager::GetAppData( |
| 399 const std::string& app_id) const { | 413 const std::string& app_id) const { |
| 400 for (size_t i = 0; i < apps_.size(); ++i) { | 414 for (size_t i = 0; i < apps_.size(); ++i) { |
| 401 const KioskAppData* data = apps_[i]; | 415 const KioskAppData* data = apps_[i]; |
| 402 if (data->app_id() == app_id) | 416 if (data->app_id() == app_id) |
| 403 return data; | 417 return data; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); | 550 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); |
| 537 } | 551 } |
| 538 | 552 |
| 539 bool KioskAppManager::GetCachedCrx(const std::string& app_id, | 553 bool KioskAppManager::GetCachedCrx(const std::string& app_id, |
| 540 base::FilePath* file_path, | 554 base::FilePath* file_path, |
| 541 std::string* version) { | 555 std::string* version) { |
| 542 return external_cache_->GetExtension(app_id, file_path, version); | 556 return external_cache_->GetExtension(app_id, file_path, version); |
| 543 } | 557 } |
| 544 | 558 |
| 545 } // namespace chromeos | 559 } // namespace chromeos |
| OLD | NEW |