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

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

Issue 2662113002: When restoring kiosk app after crash, skip app installation steps (Closed)
Patch Set: . Created 3 years, 10 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/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/json/json_file_value_serializer.h" 10 #include "base/json/json_file_value_serializer.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 ->RemoveObserver(this); 89 ->RemoveObserver(this);
90 extensions::InstallTrackerFactory::GetForBrowserContext(profile_) 90 extensions::InstallTrackerFactory::GetForBrowserContext(profile_)
91 ->RemoveObserver(this); 91 ->RemoveObserver(this);
92 } 92 }
93 93
94 void StartupAppLauncher::Initialize() { 94 void StartupAppLauncher::Initialize() {
95 StartLoadingOAuthFile(); 95 StartLoadingOAuthFile();
96 } 96 }
97 97
98 void StartupAppLauncher::ContinueWithNetworkReady() { 98 void StartupAppLauncher::ContinueWithNetworkReady() {
99 if (!network_ready_handled_) { 99 if (network_ready_handled_)
100 network_ready_handled_ = true; 100 return;
101 // The network might not be ready when KioskAppManager tries to update 101
102 // external cache initially. Update the external cache now that the network 102 network_ready_handled_ = true;
103 // is ready for sure. 103
104 wait_for_crx_update_ = true; 104 if (delegate_->ShouldSkipAppInstallation()) {
105 KioskAppManager::Get()->UpdateExternalCache(); 105 MaybeLaunchApp();
106 return;
106 } 107 }
108
109 // The network might not be ready when KioskAppManager tries to update
110 // external cache initially. Update the external cache now that the network
111 // is ready for sure.
112 wait_for_crx_update_ = true;
113 KioskAppManager::Get()->UpdateExternalCache();
107 } 114 }
108 115
109 void StartupAppLauncher::StartLoadingOAuthFile() { 116 void StartupAppLauncher::StartLoadingOAuthFile() {
110 delegate_->OnLoadingOAuthFile(); 117 delegate_->OnLoadingOAuthFile();
111 118
112 KioskOAuthParams* auth_params = new KioskOAuthParams(); 119 KioskOAuthParams* auth_params = new KioskOAuthParams();
113 BrowserThread::PostBlockingPoolTaskAndReply( 120 BrowserThread::PostBlockingPoolTaskAndReply(
114 FROM_HERE, 121 FROM_HERE,
115 base::Bind(&StartupAppLauncher::LoadOAuthFileOnBlockingPool, 122 base::Bind(&StartupAppLauncher::LoadOAuthFileOnBlockingPool,
116 auth_params), 123 auth_params),
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 const bool requires_network = 188 const bool requires_network =
182 (!extension && !crx_cached) || 189 (!extension && !crx_cached) ||
183 (extension && 190 (extension &&
184 !extensions::OfflineEnabledInfo::IsOfflineEnabled(extension)); 191 !extensions::OfflineEnabledInfo::IsOfflineEnabled(extension));
185 192
186 if (requires_network) { 193 if (requires_network) {
187 delegate_->InitializeNetwork(); 194 delegate_->InitializeNetwork();
188 return; 195 return;
189 } 196 }
190 197
198 if (delegate_->ShouldSkipAppInstallation()) {
199 MaybeLaunchApp();
200 return;
201 }
202
191 // Update the offline enabled crx cache if the network is ready; 203 // Update the offline enabled crx cache if the network is ready;
192 // or just install the app. 204 // or just install the app.
193 if (delegate_->IsNetworkReady()) 205 if (delegate_->IsNetworkReady())
194 ContinueWithNetworkReady(); 206 ContinueWithNetworkReady();
195 else 207 else
196 BeginInstall(); 208 BeginInstall();
197 } 209 }
198 210
199 void StartupAppLauncher::InitializeTokenService() { 211 void StartupAppLauncher::InitializeTokenService() {
200 delegate_->OnInitializingTokenService(); 212 delegate_->OnInitializingTokenService();
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 MaybeInitializeNetwork(); 248 MaybeInitializeNetwork();
237 } 249 }
238 250
239 void StartupAppLauncher::OnRefreshTokensLoaded() { 251 void StartupAppLauncher::OnRefreshTokensLoaded() {
240 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_) 252 ProfileOAuth2TokenServiceFactory::GetForProfile(profile_)
241 ->RemoveObserver(this); 253 ->RemoveObserver(this);
242 MaybeInitializeNetwork(); 254 MaybeInitializeNetwork();
243 } 255 }
244 256
245 void StartupAppLauncher::MaybeLaunchApp() { 257 void StartupAppLauncher::MaybeLaunchApp() {
246 // Check if the app is offline enabled.
247 const Extension* extension = GetPrimaryAppExtension(); 258 const Extension* extension = GetPrimaryAppExtension();
248 DCHECK(extension); 259 // Verify that requred apps are installed. While the apps should be
260 // present at this point, crash recovery flow skips app installation steps -
261 // this means that the kiosk app might not yet be downloaded. If that is
262 // the case, bail out from the app launch.
263 if (!extension || !AreSecondaryAppsInstalled()) {
264 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_LAUNCH);
265 return;
266 }
267
249 const bool offline_enabled = 268 const bool offline_enabled =
250 extensions::OfflineEnabledInfo::IsOfflineEnabled(extension); 269 extensions::OfflineEnabledInfo::IsOfflineEnabled(extension);
270 // If the app is not offline enabled, make sure the network is ready before
271 // launching.
251 if (offline_enabled || delegate_->IsNetworkReady()) { 272 if (offline_enabled || delegate_->IsNetworkReady()) {
252 BrowserThread::PostTask( 273 BrowserThread::PostTask(
253 BrowserThread::UI, 274 BrowserThread::UI,
254 FROM_HERE, 275 FROM_HERE,
255 base::Bind(&StartupAppLauncher::OnReadyToLaunch, AsWeakPtr())); 276 base::Bind(&StartupAppLauncher::OnReadyToLaunch, AsWeakPtr()));
256 } else { 277 } else {
257 ++launch_attempt_; 278 ++launch_attempt_;
258 if (launch_attempt_ < kMaxLaunchAttempt) { 279 if (launch_attempt_ < kMaxLaunchAttempt) {
259 BrowserThread::PostTask( 280 BrowserThread::PostTask(
260 BrowserThread::UI, 281 BrowserThread::UI,
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 // Skip copying meta data from the current installed primary app when 578 // Skip copying meta data from the current installed primary app when
558 // there is a pending update. 579 // there is a pending update.
559 if (PrimaryAppHasPendingUpdate()) 580 if (PrimaryAppHasPendingUpdate())
560 return; 581 return;
561 582
562 KioskAppManager::Get()->ClearAppData(app_id_); 583 KioskAppManager::Get()->ClearAppData(app_id_);
563 KioskAppManager::Get()->UpdateAppDataFromProfile(app_id_, profile_, NULL); 584 KioskAppManager::Get()->UpdateAppDataFromProfile(app_id_, profile_, NULL);
564 } 585 }
565 586
566 } // namespace chromeos 587 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/app_mode/startup_app_launcher.h ('k') | chrome/browser/chromeos/login/app_launch_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698