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

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

Issue 43203002: Remove hacks added to workaround a system salt issue for M31 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 7 years, 2 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"
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "base/values.h" 12 #include "base/values.h"
13 #include "chrome/browser/chrome_notification_types.h" 13 #include "chrome/browser/chrome_notification_types.h"
14 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h" 14 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h"
15 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" 15 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
16 #include "chrome/browser/chromeos/login/user_manager.h" 16 #include "chrome/browser/chromeos/login/user_manager.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_system.h" 18 #include "chrome/browser/extensions/extension_system.h"
19 #include "chrome/browser/extensions/webstore_startup_installer.h" 19 #include "chrome/browser/extensions/webstore_startup_installer.h"
20 #include "chrome/browser/lifetime/application_lifetime.h" 20 #include "chrome/browser/lifetime/application_lifetime.h"
21 #include "chrome/browser/signin/profile_oauth2_token_service.h" 21 #include "chrome/browser/signin/profile_oauth2_token_service.h"
22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 22 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
23 #include "chrome/browser/signin/token_service.h" 23 #include "chrome/browser/signin/token_service.h"
24 #include "chrome/browser/signin/token_service_factory.h" 24 #include "chrome/browser/signin/token_service_factory.h"
25 #include "chrome/browser/ui/extensions/application_launch.h" 25 #include "chrome/browser/ui/extensions/application_launch.h"
26 #include "chrome/common/chrome_paths.h" 26 #include "chrome/common/chrome_paths.h"
27 #include "chrome/common/chrome_switches.h" 27 #include "chrome/common/chrome_switches.h"
28 #include "chrome/common/extensions/extension.h" 28 #include "chrome/common/extensions/extension.h"
29 #include "chrome/common/extensions/manifest_handlers/kiosk_mode_info.h" 29 #include "chrome/common/extensions/manifest_handlers/kiosk_mode_info.h"
30 #include "chromeos/cryptohome/system_salt_getter.h"
31 #include "content/public/browser/browser_thread.h" 30 #include "content/public/browser/browser_thread.h"
32 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
33 #include "google_apis/gaia/gaia_auth_consumer.h" 32 #include "google_apis/gaia/gaia_auth_consumer.h"
34 #include "google_apis/gaia/gaia_constants.h" 33 #include "google_apis/gaia/gaia_constants.h"
35 34
36 using content::BrowserThread; 35 using content::BrowserThread;
37 using extensions::Extension; 36 using extensions::Extension;
38 using extensions::WebstoreStartupInstaller; 37 using extensions::WebstoreStartupInstaller;
39 38
40 namespace chromeos { 39 namespace chromeos {
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 OnLaunchSuccess(); 242 OnLaunchSuccess();
244 } 243 }
245 244
246 void StartupAppLauncher::BeginInstall() { 245 void StartupAppLauncher::BeginInstall() {
247 FOR_EACH_OBSERVER(Observer, observer_list_, OnInstallingApp()); 246 FOR_EACH_OBSERVER(Observer, observer_list_, OnInstallingApp());
248 247
249 DVLOG(1) << "BeginInstall... connection = " 248 DVLOG(1) << "BeginInstall... connection = "
250 << net::NetworkChangeNotifier::GetConnectionType(); 249 << net::NetworkChangeNotifier::GetConnectionType();
251 250
252 if (IsAppInstalled(profile_, app_id_)) { 251 if (IsAppInstalled(profile_, app_id_)) {
253 EnsureSystemSaltIsLoaded(); 252 OnReadyToLaunch();
254 return; 253 return;
255 } 254 }
256 255
257 installer_ = new WebstoreStartupInstaller( 256 installer_ = new WebstoreStartupInstaller(
258 app_id_, 257 app_id_,
259 profile_, 258 profile_,
260 false, 259 false,
261 base::Bind(&StartupAppLauncher::InstallCallback, AsWeakPtr())); 260 base::Bind(&StartupAppLauncher::InstallCallback, AsWeakPtr()));
262 installer_->BeginInstall(); 261 installer_->BeginInstall();
263 } 262 }
264 263
265 void StartupAppLauncher::InstallCallback(bool success, 264 void StartupAppLauncher::InstallCallback(bool success,
266 const std::string& error) { 265 const std::string& error) {
267 installer_ = NULL; 266 installer_ = NULL;
268 if (success) { 267 if (success) {
269 // Finish initialization after the callback returns. 268 // Finish initialization after the callback returns.
270 // So that the app finishes its installation. 269 // So that the app finishes its installation.
271 BrowserThread::PostTask( 270 BrowserThread::PostTask(
272 BrowserThread::UI, 271 BrowserThread::UI,
273 FROM_HERE, 272 FROM_HERE,
274 base::Bind(&StartupAppLauncher::EnsureSystemSaltIsLoaded, 273 base::Bind(&StartupAppLauncher::OnReadyToLaunch,
275 AsWeakPtr())); 274 AsWeakPtr()));
276 return; 275 return;
277 } 276 }
278 277
279 LOG(ERROR) << "App install failed: " << error; 278 LOG(ERROR) << "App install failed: " << error;
280 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL); 279 OnLaunchFailure(KioskAppLaunchError::UNABLE_TO_INSTALL);
281 } 280 }
282 281
283 void StartupAppLauncher::EnsureSystemSaltIsLoaded() { 282 void StartupAppLauncher::OnReadyToLaunch() {
284 // Defer app launch until system salt is loaded to make sure that identity
285 // api works with the enterprise kiosk app.
286 SystemSaltGetter::Get()->GetSystemSalt(
287 base::Bind(&StartupAppLauncher::OnReadyToLaunch, AsWeakPtr()));
288 }
289
290 void StartupAppLauncher::OnReadyToLaunch(const std::string& system_salt) {
291 if (system_salt.empty()) {
292 LOG(ERROR) << "Could not load system salt.";
293 OnLaunchFailure(KioskAppLaunchError::CRYPTOHOMED_NOT_RUNNING);
294 return;
295 }
296
297 ready_to_launch_ = true; 283 ready_to_launch_ = true;
298 FOR_EACH_OBSERVER(Observer, observer_list_, OnReadyToLaunch()); 284 FOR_EACH_OBSERVER(Observer, observer_list_, OnReadyToLaunch());
299 } 285 }
300 286
301 void StartupAppLauncher::OnNetworkChanged( 287 void StartupAppLauncher::OnNetworkChanged(
302 net::NetworkChangeNotifier::ConnectionType type) { 288 net::NetworkChangeNotifier::ConnectionType type) {
303 DVLOG(1) << "OnNetworkChanged... connection = " 289 DVLOG(1) << "OnNetworkChanged... connection = "
304 << net::NetworkChangeNotifier::GetConnectionType(); 290 << net::NetworkChangeNotifier::GetConnectionType();
305 if (!net::NetworkChangeNotifier::IsOffline()) { 291 if (!net::NetworkChangeNotifier::IsOffline()) {
306 DVLOG(1) << "Network up and running!"; 292 DVLOG(1) << "Network up and running!";
307 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this); 293 net::NetworkChangeNotifier::RemoveNetworkChangeObserver(this);
308 294
309 BeginInstall(); 295 BeginInstall();
310 } else { 296 } else {
311 DVLOG(1) << "Network not running yet!"; 297 DVLOG(1) << "Network not running yet!";
312 } 298 }
313 } 299 }
314 300
315 } // namespace chromeos 301 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698