| Index: chrome/browser/chromeos/app_mode/startup_app_launcher.cc
|
| diff --git a/chrome/browser/chromeos/app_mode/startup_app_launcher.cc b/chrome/browser/chromeos/app_mode/startup_app_launcher.cc
|
| index 151562451ca3f0d2db7d3ac29f007cd0d1dd4f76..fed5be6a4a32b4684c5614218717ac9486449978 100644
|
| --- a/chrome/browser/chromeos/app_mode/startup_app_launcher.cc
|
| +++ b/chrome/browser/chromeos/app_mode/startup_app_launcher.cc
|
| @@ -72,12 +72,7 @@ StartupAppLauncher::StartupAppLauncher(Profile* profile,
|
| : profile_(profile),
|
| app_id_(app_id),
|
| diagnostic_mode_(diagnostic_mode),
|
| - delegate_(delegate),
|
| - network_ready_handled_(false),
|
| - launch_attempt_(0),
|
| - ready_to_launch_(false),
|
| - wait_for_crx_update_(false),
|
| - secondary_apps_updated_(false) {
|
| + delegate_(delegate) {
|
| DCHECK(profile_);
|
| DCHECK(crx_file::id_util::IdIsValid(app_id_));
|
| KioskAppManager::Get()->AddObserver(this);
|
| @@ -269,6 +264,59 @@ void StartupAppLauncher::MaybeLaunchApp() {
|
| }
|
| }
|
|
|
| +void StartupAppLauncher::MaybeCheckExtensionUpdate() {
|
| + extensions::ExtensionUpdater* updater =
|
| + extensions::ExtensionSystem::Get(profile_)
|
| + ->extension_service()
|
| + ->updater();
|
| + if (!delegate_->IsNetworkReady() || !updater) {
|
| + MaybeLaunchApp();
|
| + return;
|
| + }
|
| +
|
| + extension_update_found_ = false;
|
| + registrar_.Add(this, extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND,
|
| + content::NotificationService::AllSources());
|
| +
|
| + // Enforce an immediate version update check for all extensions before
|
| + // launching the primary app. After the chromeos is updated, the shared
|
| + // module(e.g. ARC runtime) may need to be updated to a newer version
|
| + // compatible with the new chromeos. See crbug.com/555083.
|
| + extensions::ExtensionUpdater::CheckParams params;
|
| + params.install_immediately = true;
|
| + params.callback = base::Bind(
|
| + &StartupAppLauncher::OnExtensionUpdateCheckFinished, AsWeakPtr());
|
| + updater->CheckNow(params);
|
| +}
|
| +
|
| +void StartupAppLauncher::OnExtensionUpdateCheckFinished() {
|
| + if (extension_update_found_) {
|
| + // Reload the primary app to make sure any reference to the previous version
|
| + // of the shared module, extension, etc will be cleaned up andthe new
|
| + // version will be loaded.
|
| + extensions::ExtensionSystem::Get(profile_)
|
| + ->extension_service()
|
| + ->ReloadExtension(app_id_);
|
| + extension_update_found_ = false;
|
| + }
|
| + registrar_.Remove(this, extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND,
|
| + content::NotificationService::AllSources());
|
| +
|
| + MaybeLaunchApp();
|
| +}
|
| +
|
| +void StartupAppLauncher::Observe(int type,
|
| + const content::NotificationSource& source,
|
| + const content::NotificationDetails& details) {
|
| + DCHECK(type == extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND);
|
| + typedef const std::pair<std::string, Version> UpdateDetails;
|
| + const std::string& id = content::Details<UpdateDetails>(details)->first;
|
| + const Version& version = content::Details<UpdateDetails>(details)->second;
|
| + VLOG(1) << "Found extension update id=" << id
|
| + << " version=" << version.GetString();
|
| + extension_update_found_ = true;
|
| +}
|
| +
|
| void StartupAppLauncher::OnFinishCrxInstall(const std::string& extension_id,
|
| bool success) {
|
| // Wait for pending updates or dependent extensions to download.
|
| @@ -293,10 +341,10 @@ void StartupAppLauncher::OnFinishCrxInstall(const std::string& extension_id,
|
| }
|
|
|
| if (GetPrimaryAppExtension()) {
|
| - if (!secondary_apps_updated_)
|
| + if (!secondary_apps_installed_)
|
| MaybeInstallSecondaryApps();
|
| else
|
| - MaybeLaunchApp();
|
| + MaybeCheckExtensionUpdate();
|
| }
|
| }
|
|
|
| @@ -465,7 +513,7 @@ void StartupAppLauncher::MaybeInstallSecondaryApps() {
|
| return;
|
| }
|
|
|
| - secondary_apps_updated_ = true;
|
| + secondary_apps_installed_ = true;
|
| extensions::KioskModeInfo* info =
|
| extensions::KioskModeInfo::Get(GetPrimaryAppExtension());
|
| KioskAppManager::Get()->InstallSecondaryApps(info->secondary_app_ids);
|
| @@ -479,8 +527,8 @@ void StartupAppLauncher::MaybeInstallSecondaryApps() {
|
| }
|
|
|
| if (AreSecondaryAppsInstalled()) {
|
| - // Launch the primary app.
|
| - MaybeLaunchApp();
|
| + // Check extension update before launching the primary kiosk app.
|
| + MaybeCheckExtensionUpdate();
|
| } else {
|
| OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
|
| }
|
|
|