Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(335)

Unified Diff: chrome/browser/chromeos/app_mode/startup_app_launcher.cc

Issue 1488393002: Check import module update before launching the primary kiosk app. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browser tests and address code review commnents. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..182b0d862b53b0bbf79382b5706625a0923a160d 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,58 @@ void StartupAppLauncher::MaybeLaunchApp() {
}
}
+void StartupAppLauncher::MaybeCheckExtensionUpdate() {
+ extensions::ExtensionUpdater* updater =
+ extensions::ExtensionSystem::Get(profile_)
+ ->extension_service()
+ ->updater();
+ if (!delegate_->IsNetworkReady() || !updater) {
+ MaybeLaunchApp();
+ return;
+ }
+
+ // 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());
+ extension_update_found_ = false;
+ registrar_.Add(this, extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND,
+ content::NotificationService::AllSources());
xiyuan 2015/12/03 00:46:53 Sorry for the confusion. I meant to moving this be
jennyz 2015/12/03 01:23:47 Done.
+ 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 +340,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 +512,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 +526,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);
}

Powered by Google App Engine
This is Rietveld 408576698