| 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" |
| 11 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
| 12 #include "base/files/file_util.h" | 12 #include "base/files/file_util.h" |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/prefs/pref_registry_simple.h" | 15 #include "base/prefs/pref_registry_simple.h" |
| 16 #include "base/prefs/pref_service.h" | 16 #include "base/prefs/pref_service.h" |
| 17 #include "base/prefs/scoped_user_pref_update.h" | 17 #include "base/prefs/scoped_user_pref_update.h" |
| 18 #include "base/stl_util.h" | 18 #include "base/stl_util.h" |
| 19 #include "base/sys_info.h" | 19 #include "base/sys_info.h" |
| 20 #include "chrome/browser/browser_process.h" | 20 #include "chrome/browser/browser_process.h" |
| 21 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" | 21 #include "chrome/browser/chromeos/app_mode/kiosk_app_data.h" |
| 22 #include "chrome/browser/chromeos/app_mode/kiosk_app_external_loader.h" | 22 #include "chrome/browser/chromeos/app_mode/kiosk_app_external_loader.h" |
| 23 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" | 23 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager_observer.h" |
| 24 #include "chrome/browser/chromeos/app_mode/kiosk_external_updater.h" | |
| 25 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" | 24 #include "chrome/browser/chromeos/ownership/owner_settings_service_chromeos_fact
ory.h" |
| 26 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 25 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 27 #include "chrome/browser/chromeos/policy/device_local_account.h" | 26 #include "chrome/browser/chromeos/policy/device_local_account.h" |
| 28 #include "chrome/browser/chromeos/settings/cros_settings.h" | 27 #include "chrome/browser/chromeos/settings/cros_settings.h" |
| 29 #include "chrome/browser/extensions/external_loader.h" | 28 #include "chrome/browser/extensions/external_loader.h" |
| 30 #include "chrome/browser/extensions/external_provider_impl.h" | 29 #include "chrome/browser/extensions/external_provider_impl.h" |
| 31 #include "chrome/common/chrome_paths.h" | 30 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/extensions/extension_constants.h" | 31 #include "chrome/common/extensions/extension_constants.h" |
| 33 #include "chromeos/chromeos_paths.h" | 32 #include "chromeos/chromeos_paths.h" |
| 34 #include "chromeos/cryptohome/async_method_caller.h" | 33 #include "chromeos/cryptohome/async_method_caller.h" |
| 35 #include "chromeos/settings/cros_settings_names.h" | 34 #include "chromeos/settings/cros_settings_names.h" |
| 36 #include "components/ownership/owner_key_util.h" | 35 #include "components/ownership/owner_key_util.h" |
| 37 #include "content/public/browser/browser_thread.h" | 36 #include "content/public/browser/browser_thread.h" |
| 38 #include "extensions/common/extension_urls.h" | 37 #include "extensions/common/extension_urls.h" |
| 39 | 38 |
| 39 #if !defined(USE_ATHENA) |
| 40 #include "chrome/browser/chromeos/app_mode/kiosk_external_updater.h" |
| 41 #endif |
| 42 |
| 40 namespace chromeos { | 43 namespace chromeos { |
| 41 | 44 |
| 42 namespace { | 45 namespace { |
| 43 | 46 |
| 44 // Domain that is used for kiosk-app account IDs. | 47 // Domain that is used for kiosk-app account IDs. |
| 45 const char kKioskAppAccountDomain[] = "kiosk-apps"; | 48 const char kKioskAppAccountDomain[] = "kiosk-apps"; |
| 46 | 49 |
| 47 std::string GenerateKioskAppAccountId(const std::string& app_id) { | 50 std::string GenerateKioskAppAccountId(const std::string& app_id) { |
| 48 return app_id + '@' + kKioskAppAccountDomain; | 51 return app_id + '@' + kKioskAppAccountDomain; |
| 49 } | 52 } |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this))); | 460 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this))); |
| 458 local_account_auto_login_id_subscription_ = | 461 local_account_auto_login_id_subscription_ = |
| 459 CrosSettings::Get()->AddSettingsObserver( | 462 CrosSettings::Get()->AddSettingsObserver( |
| 460 kAccountsPrefDeviceLocalAccountAutoLoginId, | 463 kAccountsPrefDeviceLocalAccountAutoLoginId, |
| 461 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this))); | 464 base::Bind(&KioskAppManager::UpdateAppData, base::Unretained(this))); |
| 462 } | 465 } |
| 463 | 466 |
| 464 KioskAppManager::~KioskAppManager() {} | 467 KioskAppManager::~KioskAppManager() {} |
| 465 | 468 |
| 466 void KioskAppManager::MonitorKioskExternalUpdate() { | 469 void KioskAppManager::MonitorKioskExternalUpdate() { |
| 470 #if !defined(USE_ATHENA) |
| 467 base::FilePath cache_dir; | 471 base::FilePath cache_dir; |
| 468 GetCrxCacheDir(&cache_dir); | 472 GetCrxCacheDir(&cache_dir); |
| 469 base::FilePath unpack_dir; | 473 base::FilePath unpack_dir; |
| 470 GetCrxUnpackDir(&unpack_dir); | 474 GetCrxUnpackDir(&unpack_dir); |
| 471 usb_stick_updater_.reset(new KioskExternalUpdater( | 475 usb_stick_updater_.reset(new KioskExternalUpdater( |
| 472 GetBackgroundTaskRunner(), cache_dir, unpack_dir)); | 476 GetBackgroundTaskRunner(), cache_dir, unpack_dir)); |
| 477 #endif |
| 473 } | 478 } |
| 474 | 479 |
| 475 void KioskAppManager::CleanUp() { | 480 void KioskAppManager::CleanUp() { |
| 476 local_accounts_subscription_.reset(); | 481 local_accounts_subscription_.reset(); |
| 477 local_account_auto_login_id_subscription_.reset(); | 482 local_account_auto_login_id_subscription_.reset(); |
| 478 apps_.clear(); | 483 apps_.clear(); |
| 484 #if !defined(USE_ATHENA) |
| 479 usb_stick_updater_.reset(); | 485 usb_stick_updater_.reset(); |
| 486 #endif |
| 480 external_cache_.reset(); | 487 external_cache_.reset(); |
| 481 } | 488 } |
| 482 | 489 |
| 483 const KioskAppData* KioskAppManager::GetAppData( | 490 const KioskAppData* KioskAppManager::GetAppData( |
| 484 const std::string& app_id) const { | 491 const std::string& app_id) const { |
| 485 for (size_t i = 0; i < apps_.size(); ++i) { | 492 for (size_t i = 0; i < apps_.size(); ++i) { |
| 486 const KioskAppData* data = apps_[i]; | 493 const KioskAppData* data = apps_[i]; |
| 487 if (data->app_id() == app_id) | 494 if (data->app_id() == app_id) |
| 488 return data; | 495 return data; |
| 489 } | 496 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); | 644 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); |
| 638 } | 645 } |
| 639 | 646 |
| 640 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) { | 647 void KioskAppManager::GetCrxUnpackDir(base::FilePath* unpack_dir) { |
| 641 base::FilePath temp_dir; | 648 base::FilePath temp_dir; |
| 642 base::GetTempDir(&temp_dir); | 649 base::GetTempDir(&temp_dir); |
| 643 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir); | 650 *unpack_dir = temp_dir.AppendASCII(kCrxUnpackDir); |
| 644 } | 651 } |
| 645 | 652 |
| 646 } // namespace chromeos | 653 } // namespace chromeos |
| OLD | NEW |