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

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

Issue 209143002: Added shortcut for NW config screen in kiosk. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 9 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 | Annotate | Revision Log
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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 #include "url/gurl.h" 44 #include "url/gurl.h"
45 45
46 using content::BrowserThread; 46 using content::BrowserThread;
47 using extensions::Extension; 47 using extensions::Extension;
48 using extensions::WebstoreStartupInstaller; 48 using extensions::WebstoreStartupInstaller;
49 49
50 namespace chromeos { 50 namespace chromeos {
51 51
52 namespace { 52 namespace {
53 53
54 const int kRerunDelay = 2;
xiyuan 2014/03/26 16:24:16 no longer needed.
zel 2014/03/26 17:30:58 Done.
54 const char kOAuthRefreshToken[] = "refresh_token"; 55 const char kOAuthRefreshToken[] = "refresh_token";
55 const char kOAuthClientId[] = "client_id"; 56 const char kOAuthClientId[] = "client_id";
56 const char kOAuthClientSecret[] = "client_secret"; 57 const char kOAuthClientSecret[] = "client_secret";
57 58
58 const base::FilePath::CharType kOAuthFileName[] = 59 const base::FilePath::CharType kOAuthFileName[] =
59 FILE_PATH_LITERAL("kiosk_auth"); 60 FILE_PATH_LITERAL("kiosk_auth");
60 61
61 const int kMaxInstallAttempt = 5; 62 const int kMaxInstallAttempt = 5;
62 63
63 } // namespace 64 } // namespace
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 UserManager::Get()->SetAppModeChromeClientOAuthInfo( 142 UserManager::Get()->SetAppModeChromeClientOAuthInfo(
142 auth_params_.client_id, 143 auth_params_.client_id,
143 auth_params_.client_secret); 144 auth_params_.client_secret);
144 } 145 }
145 146
146 // If we are restarting chrome (i.e. on crash), we need to initialize 147 // If we are restarting chrome (i.e. on crash), we need to initialize
147 // OAuth2TokenService as well. 148 // OAuth2TokenService as well.
148 InitializeTokenService(); 149 InitializeTokenService();
149 } 150 }
150 151
152 void StartupAppLauncher::RestartLauncher() {
153 // If installer is still running in the background, delay the restart.
xiyuan 2014/03/26 16:24:16 nit: Update the comment to clarify that start up c
zel 2014/03/26 17:30:58 Done.
154 if (installer_ != NULL) {
155 LOG(WARNING) << "Installer still running";
156 return;
157 }
158
159 MaybeInitializeNetwork();
160 }
161
151 void StartupAppLauncher::MaybeInitializeNetwork() { 162 void StartupAppLauncher::MaybeInitializeNetwork() {
152 network_ready_handled_ = false; 163 network_ready_handled_ = false;
153 164
154 const Extension* extension = extensions::ExtensionSystem::Get(profile_)-> 165 const Extension* extension = extensions::ExtensionSystem::Get(profile_)->
155 extension_service()->GetInstalledExtension(app_id_); 166 extension_service()->GetInstalledExtension(app_id_);
156 const bool requires_network = !extension || 167 const bool requires_network = !extension ||
157 !extensions::OfflineEnabledInfo::IsOfflineEnabled(extension); 168 !extensions::OfflineEnabledInfo::IsOfflineEnabled(extension);
158 169
159 if (requires_network) { 170 if (requires_network) {
160 delegate_->InitializeNetwork(); 171 delegate_->InitializeNetwork();
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 app_id_, 299 app_id_,
289 profile_, 300 profile_,
290 false, 301 false,
291 base::Bind(&StartupAppLauncher::InstallCallback, AsWeakPtr())); 302 base::Bind(&StartupAppLauncher::InstallCallback, AsWeakPtr()));
292 installer_->BeginInstall(); 303 installer_->BeginInstall();
293 } 304 }
294 305
295 void StartupAppLauncher::InstallCallback(bool success, 306 void StartupAppLauncher::InstallCallback(bool success,
296 const std::string& error) { 307 const std::string& error) {
297 installer_ = NULL; 308 installer_ = NULL;
309 if (delegate_->IsShowingNetworkConfigScreen()) {
310 LOG(WARNING) << "Showing network config screen";
311 return;
312 }
313
298 if (success) { 314 if (success) {
299 // Finish initialization after the callback returns. 315 // Finish initialization after the callback returns.
300 // So that the app finishes its installation. 316 // So that the app finishes its installation.
301 BrowserThread::PostTask( 317 BrowserThread::PostTask(
302 BrowserThread::UI, 318 BrowserThread::UI,
303 FROM_HERE, 319 FROM_HERE,
304 base::Bind(&StartupAppLauncher::OnReadyToLaunch, 320 base::Bind(&StartupAppLauncher::OnReadyToLaunch,
305 AsWeakPtr())); 321 AsWeakPtr()));
306 return; 322 return;
307 } 323 }
308 324
309 LOG(ERROR) << "App install failed: " << error 325 LOG(ERROR) << "App install failed: " << error
310 << ", for attempt " << install_attempt_; 326 << ", for attempt " << install_attempt_;
311 327
312 ++install_attempt_; 328 ++install_attempt_;
313 if (install_attempt_ < kMaxInstallAttempt) { 329 if (install_attempt_ < kMaxInstallAttempt) {
314 BrowserThread::PostTask( 330 BrowserThread::PostTask(
315 BrowserThread::UI, 331 BrowserThread::UI,
316 FROM_HERE, 332 FROM_HERE,
317 base::Bind(&StartupAppLauncher::MaybeInitializeNetwork, 333 base::Bind(&StartupAppLauncher::MaybeInitializeNetwork,
318 AsWeakPtr())); 334 AsWeakPtr()));
319 return; 335 return;
320 } 336 }
321 337
322 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL); 338 if (!delegate_->IsShowingNetworkConfigScreen())
xiyuan 2014/03/26 16:24:16 This "if" seem unnecessary.
zel 2014/03/26 17:30:58 Done.
339 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
323 } 340 }
324 341
325 void StartupAppLauncher::OnReadyToLaunch() { 342 void StartupAppLauncher::OnReadyToLaunch() {
326 ready_to_launch_ = true; 343 ready_to_launch_ = true;
327 delegate_->OnReadyToLaunch(); 344 delegate_->OnReadyToLaunch();
328 } 345 }
329 346
330 void StartupAppLauncher::UpdateAppData() { 347 void StartupAppLauncher::UpdateAppData() {
331 KioskAppManager::Get()->ClearAppData(app_id_); 348 KioskAppManager::Get()->ClearAppData(app_id_);
332 KioskAppManager::Get()->UpdateAppDataFromProfile(app_id_, profile_, NULL); 349 KioskAppManager::Get()->UpdateAppDataFromProfile(app_id_, profile_, NULL);
333 } 350 }
334 351
335 } // namespace chromeos 352 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698