| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 const std::string& app_id, | 349 const std::string& app_id, |
| 350 Profile* profile, | 350 Profile* profile, |
| 351 const extensions::Extension* app) { | 351 const extensions::Extension* app) { |
| 352 KioskAppData* app_data = GetAppDataMutable(app_id); | 352 KioskAppData* app_data = GetAppDataMutable(app_id); |
| 353 if (!app_data) | 353 if (!app_data) |
| 354 return; | 354 return; |
| 355 | 355 |
| 356 app_data->LoadFromInstalledApp(profile, app); | 356 app_data->LoadFromInstalledApp(profile, app); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void KioskAppManager::RetryFailedAppDataFetch() { |
| 360 for (size_t i = 0; i < apps_.size(); ++i) { |
| 361 if (apps_[i]->status() == KioskAppData::STATUS_ERROR) |
| 362 apps_[i]->Load(); |
| 363 } |
| 364 } |
| 365 |
| 359 void KioskAppManager::AddObserver(KioskAppManagerObserver* observer) { | 366 void KioskAppManager::AddObserver(KioskAppManagerObserver* observer) { |
| 360 observers_.AddObserver(observer); | 367 observers_.AddObserver(observer); |
| 361 } | 368 } |
| 362 | 369 |
| 363 void KioskAppManager::RemoveObserver(KioskAppManagerObserver* observer) { | 370 void KioskAppManager::RemoveObserver(KioskAppManagerObserver* observer) { |
| 364 observers_.RemoveObserver(observer); | 371 observers_.RemoveObserver(observer); |
| 365 } | 372 } |
| 366 | 373 |
| 367 KioskAppManager::KioskAppManager() : ownership_established_(false) { | 374 KioskAppManager::KioskAppManager() : ownership_established_(false) { |
| 368 base::FilePath cache_dir; | 375 base::FilePath cache_dir; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 462 STLDeleteValues(&old_apps); | 469 STLDeleteValues(&old_apps); |
| 463 external_cache_->RemoveExtensions(apps_to_remove); | 470 external_cache_->RemoveExtensions(apps_to_remove); |
| 464 | 471 |
| 465 // Request external_cache_ to download new apps and update the existing | 472 // Request external_cache_ to download new apps and update the existing |
| 466 // apps. | 473 // apps. |
| 467 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); | 474 scoped_ptr<base::DictionaryValue> prefs(new base::DictionaryValue); |
| 468 for (size_t i = 0; i < apps_.size(); ++i) | 475 for (size_t i = 0; i < apps_.size(); ++i) |
| 469 prefs->Set(apps_[i]->app_id(), new base::DictionaryValue); | 476 prefs->Set(apps_[i]->app_id(), new base::DictionaryValue); |
| 470 external_cache_->UpdateExtensionsList(prefs.Pass()); | 477 external_cache_->UpdateExtensionsList(prefs.Pass()); |
| 471 | 478 |
| 479 RetryFailedAppDataFetch(); |
| 480 |
| 472 FOR_EACH_OBSERVER(KioskAppManagerObserver, observers_, | 481 FOR_EACH_OBSERVER(KioskAppManagerObserver, observers_, |
| 473 OnKioskAppsSettingsChanged()); | 482 OnKioskAppsSettingsChanged()); |
| 474 } | 483 } |
| 475 | 484 |
| 476 void KioskAppManager::GetKioskAppIconCacheDir(base::FilePath* cache_dir) { | 485 void KioskAppManager::GetKioskAppIconCacheDir(base::FilePath* cache_dir) { |
| 477 base::FilePath user_data_dir; | 486 base::FilePath user_data_dir; |
| 478 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); | 487 CHECK(PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)); |
| 479 *cache_dir = user_data_dir.AppendASCII(kIconCacheDir); | 488 *cache_dir = user_data_dir.AppendASCII(kIconCacheDir); |
| 480 } | 489 } |
| 481 | 490 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); | 545 *cache_dir = user_data_dir.AppendASCII(kCrxCacheDir); |
| 537 } | 546 } |
| 538 | 547 |
| 539 bool KioskAppManager::GetCachedCrx(const std::string& app_id, | 548 bool KioskAppManager::GetCachedCrx(const std::string& app_id, |
| 540 base::FilePath* file_path, | 549 base::FilePath* file_path, |
| 541 std::string* version) { | 550 std::string* version) { |
| 542 return external_cache_->GetExtension(app_id, file_path, version); | 551 return external_cache_->GetExtension(app_id, file_path, version); |
| 543 } | 552 } |
| 544 | 553 |
| 545 } // namespace chromeos | 554 } // namespace chromeos |
| OLD | NEW |