| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 570 prefs->Set(id, std::move(extension_entry)); | 570 prefs->Set(id, std::move(extension_entry)); |
| 571 } | 571 } |
| 572 secondary_app_external_loader_->SetCurrentAppExtensions(std::move(prefs)); | 572 secondary_app_external_loader_->SetCurrentAppExtensions(std::move(prefs)); |
| 573 } | 573 } |
| 574 | 574 |
| 575 void KioskAppManager::UpdateExternalCache() { | 575 void KioskAppManager::UpdateExternalCache() { |
| 576 UpdateAppData(); | 576 UpdateAppData(); |
| 577 } | 577 } |
| 578 | 578 |
| 579 void KioskAppManager::OnKioskAppCacheUpdated(const std::string& app_id) { | 579 void KioskAppManager::OnKioskAppCacheUpdated(const std::string& app_id) { |
| 580 FOR_EACH_OBSERVER( | 580 for (auto& observer : observers_) |
| 581 KioskAppManagerObserver, observers_, OnKioskAppCacheUpdated(app_id)); | 581 observer.OnKioskAppCacheUpdated(app_id); |
| 582 } | 582 } |
| 583 | 583 |
| 584 void KioskAppManager::OnKioskAppExternalUpdateComplete(bool success) { | 584 void KioskAppManager::OnKioskAppExternalUpdateComplete(bool success) { |
| 585 FOR_EACH_OBSERVER(KioskAppManagerObserver, | 585 for (auto& observer : observers_) |
| 586 observers_, | 586 observer.OnKioskAppExternalUpdateComplete(success); |
| 587 OnKioskAppExternalUpdateComplete(success)); | |
| 588 } | 587 } |
| 589 | 588 |
| 590 void KioskAppManager::PutValidatedExternalExtension( | 589 void KioskAppManager::PutValidatedExternalExtension( |
| 591 const std::string& app_id, | 590 const std::string& app_id, |
| 592 const base::FilePath& crx_path, | 591 const base::FilePath& crx_path, |
| 593 const std::string& version, | 592 const std::string& version, |
| 594 const ExternalCache::PutExternalExtensionCallback& callback) { | 593 const ExternalCache::PutExternalExtensionCallback& callback) { |
| 595 external_cache_->PutExternalExtension(app_id, crx_path, version, callback); | 594 external_cache_->PutExternalExtension(app_id, crx_path, version, callback); |
| 596 } | 595 } |
| 597 | 596 |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 736 cached_crx)); | 735 cached_crx)); |
| 737 apps_.back()->Load(); | 736 apps_.back()->Load(); |
| 738 } | 737 } |
| 739 CancelDelayedCryptohomeRemoval(cryptohome::Identification(account_id)); | 738 CancelDelayedCryptohomeRemoval(cryptohome::Identification(account_id)); |
| 740 } | 739 } |
| 741 | 740 |
| 742 ClearRemovedApps(old_apps); | 741 ClearRemovedApps(old_apps); |
| 743 UpdateExternalCachePrefs(); | 742 UpdateExternalCachePrefs(); |
| 744 RetryFailedAppDataFetch(); | 743 RetryFailedAppDataFetch(); |
| 745 | 744 |
| 746 FOR_EACH_OBSERVER(KioskAppManagerObserver, observers_, | 745 for (auto& observer : observers_) |
| 747 OnKioskAppsSettingsChanged()); | 746 observer.OnKioskAppsSettingsChanged(); |
| 748 } | 747 } |
| 749 | 748 |
| 750 void KioskAppManager::ClearRemovedApps( | 749 void KioskAppManager::ClearRemovedApps( |
| 751 const std::map<std::string, std::unique_ptr<KioskAppData>>& old_apps) { | 750 const std::map<std::string, std::unique_ptr<KioskAppData>>& old_apps) { |
| 752 base::Closure cryptohomes_barrier_closure; | 751 base::Closure cryptohomes_barrier_closure; |
| 753 | 752 |
| 754 const user_manager::User* active_user = | 753 const user_manager::User* active_user = |
| 755 user_manager::UserManager::Get()->GetActiveUser(); | 754 user_manager::UserManager::Get()->GetActiveUser(); |
| 756 if (active_user) { | 755 if (active_user) { |
| 757 const AccountId active_account_id = active_user->GetAccountId(); | 756 const AccountId active_account_id = active_user->GetAccountId(); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 external_cache_->UpdateExtensionsList(std::move(prefs)); | 796 external_cache_->UpdateExtensionsList(std::move(prefs)); |
| 798 } | 797 } |
| 799 | 798 |
| 800 void KioskAppManager::GetKioskAppIconCacheDir(base::FilePath* cache_dir) { | 799 void KioskAppManager::GetKioskAppIconCacheDir(base::FilePath* cache_dir) { |
| 801 base::FilePath user_data_dir; | 800 base::FilePath user_data_dir; |
| 802 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 801 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
| 803 *cache_dir = user_data_dir.AppendASCII(kIconCacheDir); | 802 *cache_dir = user_data_dir.AppendASCII(kIconCacheDir); |
| 804 } | 803 } |
| 805 | 804 |
| 806 void KioskAppManager::OnKioskAppDataChanged(const std::string& app_id) { | 805 void KioskAppManager::OnKioskAppDataChanged(const std::string& app_id) { |
| 807 FOR_EACH_OBSERVER(KioskAppManagerObserver, | 806 for (auto& observer : observers_) |
| 808 observers_, | 807 observer.OnKioskAppDataChanged(app_id); |
| 809 OnKioskAppDataChanged(app_id)); | |
| 810 } | 808 } |
| 811 | 809 |
| 812 void KioskAppManager::OnKioskAppDataLoadFailure(const std::string& app_id) { | 810 void KioskAppManager::OnKioskAppDataLoadFailure(const std::string& app_id) { |
| 813 FOR_EACH_OBSERVER(KioskAppManagerObserver, | 811 for (auto& observer : observers_) |
| 814 observers_, | 812 observer.OnKioskAppDataLoadFailure(app_id); |
| 815 OnKioskAppDataLoadFailure(app_id)); | |
| 816 } | 813 } |
| 817 | 814 |
| 818 void KioskAppManager::OnExtensionListsUpdated( | 815 void KioskAppManager::OnExtensionListsUpdated( |
| 819 const base::DictionaryValue* prefs) { | 816 const base::DictionaryValue* prefs) { |
| 820 } | 817 } |
| 821 | 818 |
| 822 void KioskAppManager::OnExtensionLoadedInCache(const std::string& id) { | 819 void KioskAppManager::OnExtensionLoadedInCache(const std::string& id) { |
| 823 KioskAppData* app_data = GetAppDataMutable(id); | 820 KioskAppData* app_data = GetAppDataMutable(id); |
| 824 if (!app_data) | 821 if (!app_data) |
| 825 return; | 822 return; |
| 826 | 823 |
| 827 base::FilePath crx_path; | 824 base::FilePath crx_path; |
| 828 std::string version; | 825 std::string version; |
| 829 if (GetCachedCrx(id, &crx_path, &version)) | 826 if (GetCachedCrx(id, &crx_path, &version)) |
| 830 app_data->SetCachedCrx(crx_path); | 827 app_data->SetCachedCrx(crx_path); |
| 831 | 828 |
| 832 FOR_EACH_OBSERVER(KioskAppManagerObserver, | 829 for (auto& observer : observers_) |
| 833 observers_, | 830 observer.OnKioskExtensionLoadedInCache(id); |
| 834 OnKioskExtensionLoadedInCache(id)); | |
| 835 | |
| 836 } | 831 } |
| 837 | 832 |
| 838 void KioskAppManager::OnExtensionDownloadFailed( | 833 void KioskAppManager::OnExtensionDownloadFailed( |
| 839 const std::string& id, | 834 const std::string& id, |
| 840 extensions::ExtensionDownloaderDelegate::Error error) { | 835 extensions::ExtensionDownloaderDelegate::Error error) { |
| 841 KioskAppData* app_data = GetAppDataMutable(id); | 836 KioskAppData* app_data = GetAppDataMutable(id); |
| 842 if (!app_data) | 837 if (!app_data) |
| 843 return; | 838 return; |
| 844 FOR_EACH_OBSERVER(KioskAppManagerObserver, | 839 for (auto& observer : observers_) |
| 845 observers_, | 840 observer.OnKioskExtensionDownloadFailed(id); |
| 846 OnKioskExtensionDownloadFailed(id)); | |
| 847 } | 841 } |
| 848 | 842 |
| 849 KioskAppManager::AutoLoginState KioskAppManager::GetAutoLoginState() const { | 843 KioskAppManager::AutoLoginState KioskAppManager::GetAutoLoginState() const { |
| 850 PrefService* prefs = g_browser_process->local_state(); | 844 PrefService* prefs = g_browser_process->local_state(); |
| 851 const base::DictionaryValue* dict = | 845 const base::DictionaryValue* dict = |
| 852 prefs->GetDictionary(KioskAppManager::kKioskDictionaryName); | 846 prefs->GetDictionary(KioskAppManager::kKioskDictionaryName); |
| 853 int value; | 847 int value; |
| 854 if (!dict->GetInteger(kKeyAutoLoginState, &value)) | 848 if (!dict->GetInteger(kKeyAutoLoginState, &value)) |
| 855 return AUTOLOGIN_NONE; | 849 return AUTOLOGIN_NONE; |
| 856 | 850 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 880 base::TimeDelta KioskAppManager::GetAutoLaunchDelay() const { | 874 base::TimeDelta KioskAppManager::GetAutoLaunchDelay() const { |
| 881 int delay; | 875 int delay; |
| 882 if (!CrosSettings::Get()->GetInteger( | 876 if (!CrosSettings::Get()->GetInteger( |
| 883 kAccountsPrefDeviceLocalAccountAutoLoginDelay, &delay)) { | 877 kAccountsPrefDeviceLocalAccountAutoLoginDelay, &delay)) { |
| 884 return base::TimeDelta(); // Default delay is 0ms. | 878 return base::TimeDelta(); // Default delay is 0ms. |
| 885 } | 879 } |
| 886 return base::TimeDelta::FromMilliseconds(delay); | 880 return base::TimeDelta::FromMilliseconds(delay); |
| 887 } | 881 } |
| 888 | 882 |
| 889 } // namespace chromeos | 883 } // namespace chromeos |
| OLD | NEW |