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

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

Issue 22914008: Refactor kiosk app launch to be part of login screen UI flow. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/app_mode/app_launch_utils.h"
6
7 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
8 #include "chrome/browser/chromeos/app_mode/startup_app_launcher.h"
9 #include "chrome/browser/lifetime/application_lifetime.h"
10
11 namespace chromeos {
12
13 // A simple manager for the app launch that starts the launch
14 // and deletes itself when the launch finishes. On launch failure,
15 // it exits the browser process.
16 class AppLaunchManager : public StartupAppLauncher::Observer {
17 public:
18 AppLaunchManager(Profile* profile, const std::string& app_id) {
19 startup_app_launcher_.reset(new StartupAppLauncher(profile, app_id));
20 }
21
22 void Start() {
23 startup_app_launcher_->AddObserver(this);
24 startup_app_launcher_->Start();
25 }
26
27 private:
28 virtual ~AppLaunchManager() {}
29
30 void Cleanup() { delete this; }
31
32 virtual void OnLoadingOAuthFile() OVERRIDE {}
33 virtual void OnInitializingTokenService() OVERRIDE {}
34 virtual void OnInitializingNetwork() OVERRIDE {}
35 virtual void OnNetworkWaitTimedout() OVERRIDE {}
36 virtual void OnInstallingApp() OVERRIDE {}
37 virtual void OnLaunchSucceeded() OVERRIDE { Cleanup(); }
38 virtual void OnLaunchFailed(KioskAppLaunchError::Error error) OVERRIDE {
39 KioskAppLaunchError::Save(error);
40 chrome::AttemptUserExit();
41 Cleanup();
42 }
43
44 scoped_ptr<StartupAppLauncher> startup_app_launcher_;
45
46 DISALLOW_COPY_AND_ASSIGN(AppLaunchManager);
47 };
48
49 void LaunchAppOrDie(Profile* profile, const std::string& app_id) {
50 // AppLaunchManager manages its own lifetime.
51 (new AppLaunchManager(profile, app_id))->Start();
52 }
53
54 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/app_mode/app_launch_utils.h ('k') | chrome/browser/chromeos/app_mode/kiosk_app_launcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698