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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/app_mode/app_launch_utils.cc
diff --git a/chrome/browser/chromeos/app_mode/app_launch_utils.cc b/chrome/browser/chromeos/app_mode/app_launch_utils.cc
new file mode 100644
index 0000000000000000000000000000000000000000..9b993e4c6e1e72281f8c54c7dcddb27141701658
--- /dev/null
+++ b/chrome/browser/chromeos/app_mode/app_launch_utils.cc
@@ -0,0 +1,54 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/app_mode/app_launch_utils.h"
+
+#include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h"
+#include "chrome/browser/chromeos/app_mode/startup_app_launcher.h"
+#include "chrome/browser/lifetime/application_lifetime.h"
+
+namespace chromeos {
+
+// A simple manager for the app launch that starts the launch
+// and deletes itself when the launch finishes. On launch failure,
+// it exits the browser process.
+class AppLaunchManager : public StartupAppLauncher::Observer {
+ public:
+ AppLaunchManager(Profile* profile, const std::string& app_id) {
+ startup_app_launcher_.reset(new StartupAppLauncher(profile, app_id));
+ }
+
+ void Start() {
+ startup_app_launcher_->AddObserver(this);
+ startup_app_launcher_->Start();
+ }
+
+ private:
+ virtual ~AppLaunchManager() {}
+
+ void Cleanup() { delete this; }
+
+ virtual void OnLoadingOAuthFile() OVERRIDE {}
+ virtual void OnInitializingTokenService() OVERRIDE {}
+ virtual void OnInitializingNetwork() OVERRIDE {}
+ virtual void OnNetworkWaitTimedout() OVERRIDE {}
+ virtual void OnInstallingApp() OVERRIDE {}
+ virtual void OnLaunchSucceeded() OVERRIDE { Cleanup(); }
+ virtual void OnLaunchFailed(KioskAppLaunchError::Error error) OVERRIDE {
+ KioskAppLaunchError::Save(error);
+ chrome::AttemptUserExit();
+ Cleanup();
+ }
+
+ scoped_ptr<StartupAppLauncher> startup_app_launcher_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppLaunchManager);
+};
+
+void LaunchAppOrDie(Profile* profile, const std::string& app_id) {
+ // AppLaunchManager manages its own lifetime.
+ (new AppLaunchManager(profile, app_id))->Start();
+}
+
+} // namespace chromeos
« 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