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

Side by Side Diff: chrome/browser/chromeos/app_mode/startup_app_launcher.cc

Issue 1869483002: kiosk: Defer app update until platform matches (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for comments from jenny Created 4 years, 8 months 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 unified diff | Download patch
OLDNEW
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/startup_app_launcher.h" 5 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/files/file_path.h" 8 #include "base/files/file_path.h"
9 #include "base/json/json_file_value_serializer.h" 9 #include "base/json/json_file_value_serializer.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 } 262 }
263 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_LAUNCH); 263 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_LAUNCH);
264 } 264 }
265 } 265 }
266 266
267 void StartupAppLauncher::MaybeCheckExtensionUpdate() { 267 void StartupAppLauncher::MaybeCheckExtensionUpdate() {
268 extensions::ExtensionUpdater* updater = 268 extensions::ExtensionUpdater* updater =
269 extensions::ExtensionSystem::Get(profile_) 269 extensions::ExtensionSystem::Get(profile_)
270 ->extension_service() 270 ->extension_service()
271 ->updater(); 271 ->updater();
272 if (!delegate_->IsNetworkReady() || !updater) { 272 if (!delegate_->IsNetworkReady() || !updater ||
273 PrimaryAppHasPendingUpdate()) {
273 MaybeLaunchApp(); 274 MaybeLaunchApp();
274 return; 275 return;
275 } 276 }
276 277
277 extension_update_found_ = false; 278 extension_update_found_ = false;
278 registrar_.Add(this, extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND, 279 registrar_.Add(this, extensions::NOTIFICATION_EXTENSION_UPDATE_FOUND,
279 content::NotificationService::AllSources()); 280 content::NotificationService::AllSources());
280 281
281 // Enforce an immediate version update check for all extensions before 282 // Enforce an immediate version update check for all extensions before
282 // launching the primary app. After the chromeos is updated, the shared 283 // launching the primary app. After the chromeos is updated, the shared
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 399 }
399 return true; 400 return true;
400 } 401 }
401 402
402 bool StartupAppLauncher::HasSecondaryApps() const { 403 bool StartupAppLauncher::HasSecondaryApps() const {
403 const extensions::Extension* extension = GetPrimaryAppExtension(); 404 const extensions::Extension* extension = GetPrimaryAppExtension();
404 DCHECK(extension); 405 DCHECK(extension);
405 return extensions::KioskModeInfo::HasSecondaryApps(extension); 406 return extensions::KioskModeInfo::HasSecondaryApps(extension);
406 } 407 }
407 408
409 bool StartupAppLauncher::PrimaryAppHasPendingUpdate() const {
410 return !!extensions::ExtensionSystem::Get(profile_)
411 ->extension_service()
412 ->GetPendingExtensionUpdate(app_id_);
413 }
414
408 bool StartupAppLauncher::DidPrimaryOrSecondaryAppFailedToInstall( 415 bool StartupAppLauncher::DidPrimaryOrSecondaryAppFailedToInstall(
409 bool success, 416 bool success,
410 const std::string& id) const { 417 const std::string& id) const {
411 if (success) 418 if (success)
412 return false; 419 return false;
413 420
414 if (id == app_id_) { 421 if (id == app_id_) {
415 LOG(ERROR) << "Failed to install crx file of the primary app id=" << id; 422 LOG(ERROR) << "Failed to install crx file of the primary app id=" << id;
416 return true; 423 return true;
417 } 424 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 if (AreSecondaryAppsInstalled()) { 536 if (AreSecondaryAppsInstalled()) {
530 // Check extension update before launching the primary kiosk app. 537 // Check extension update before launching the primary kiosk app.
531 MaybeCheckExtensionUpdate(); 538 MaybeCheckExtensionUpdate();
532 } else { 539 } else {
533 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL); 540 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
534 } 541 }
535 } 542 }
536 543
537 void StartupAppLauncher::OnReadyToLaunch() { 544 void StartupAppLauncher::OnReadyToLaunch() {
538 ready_to_launch_ = true; 545 ready_to_launch_ = true;
539 UpdateAppData(); 546 MaybeUpdateAppData();
540 delegate_->OnReadyToLaunch(); 547 delegate_->OnReadyToLaunch();
541 } 548 }
542 549
543 void StartupAppLauncher::UpdateAppData() { 550 void StartupAppLauncher::MaybeUpdateAppData() {
551 // Skip copying meta data from the current installed primary app when
552 // there is a pending update.
553 if (PrimaryAppHasPendingUpdate())
554 return;
555
544 KioskAppManager::Get()->ClearAppData(app_id_); 556 KioskAppManager::Get()->ClearAppData(app_id_);
545 KioskAppManager::Get()->UpdateAppDataFromProfile(app_id_, profile_, NULL); 557 KioskAppManager::Get()->UpdateAppDataFromProfile(app_id_, profile_, NULL);
546 } 558 }
547 559
548 } // namespace chromeos 560 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/app_mode/startup_app_launcher.h ('k') | chrome/browser/chromeos/login/kiosk_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698