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

Unified Diff: chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc

Issue 156493004: Add the ability to show a demo app on OOBE if a machine is derelict. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc
diff --git a/chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc b/chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc
new file mode 100644
index 0000000000000000000000000000000000000000..6503d9b9708e6e0ddb8323af1301025991e6f7fa
--- /dev/null
+++ b/chrome/browser/chromeos/login/demo_mode/demo_app_launcher.cc
@@ -0,0 +1,76 @@
+// Copyright 2014 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/login/demo_mode/demo_app_launcher.h"
+
+#include "base/command_line.h"
+#include "chrome/browser/chromeos/app_mode/app_session_lifetime.h"
+#include "chrome/browser/chromeos/login/login_display_host_impl.h"
+#include "chrome/browser/chromeos/login/user_manager.h"
+#include "chrome/browser/extensions/component_loader.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/ui/extensions/application_launch.h"
+#include "chrome/common/chrome_switches.h"
+#include "extensions/browser/extension_system.h"
+#include "grit/browser_resources.h"
+
+namespace {
+
+const char kDemoAppUserId[] = "demouser@demo.app.local";
+
+}
+
+namespace chromeos {
+
+DemoAppLauncher::DemoAppLauncher() : profile_(NULL) {}
bartfab (slow) 2014/02/13 19:51:53 Nit: #include "chrome/browser/profiles/profile.h"
rkc 2014/02/13 23:22:01 Done.
+
+DemoAppLauncher::~DemoAppLauncher() {}
+
+void DemoAppLauncher::StartDemoAppLaunch() {
+ DVLOG(1) << "Launching demo app...";
bartfab (slow) 2014/02/13 19:51:53 Nit: #include "base/logging.h"
rkc 2014/02/13 23:22:01 Done.
+ // user_id = DemoAppUserId, force_emphemeral = true, delegate = this.
+ kiosk_profile_loader_.reset(
+ new KioskProfileLoader(kDemoAppUserId, true, this));
+ kiosk_profile_loader_->Start();
+}
+
+// static
+bool DemoAppLauncher::IsDemoAppSession(const std::string& user_id) {
+ return user_id == kDemoAppUserId ? true : false;
bartfab (slow) 2014/02/13 19:51:53 Nit: No need for a ternary operator. The result of
rkc 2014/02/13 23:22:01 Done.
+}
+
+void DemoAppLauncher::OnProfileLoaded(Profile* profile) {
+ DVLOG(1) << "Profile loaded... Starting demo app launch.";
+ profile_ = profile;
+
+ kiosk_profile_loader_.reset();
+
+ // Load our demo app, then launch it.
+ ExtensionService* extension_service =
+ extensions::ExtensionSystem::Get(profile_)->extension_service();
+ std::string extension_id = extension_service->component_loader()->Add(
bartfab (slow) 2014/02/13 19:51:53 Nit: const
rkc 2014/02/13 23:22:01 Done.
+ IDR_DEMO_APP_MANIFEST,
+ base::FilePath("/usr/share/chromeos-assets/demo_app"));
bartfab (slow) 2014/02/13 19:51:53 Nit: #include "base/files/file_path.h"
rkc 2014/02/13 23:22:01 Done.
rkc 2014/02/13 23:22:01 Done.
+
+ const extensions::Extension* extension =
bartfab (slow) 2014/02/13 19:51:53 Nit: #include "extensions/common/extension.h"
rkc 2014/02/13 23:22:01 Done.
+ extension_service->GetExtensionById(extension_id, true);
+
+ CommandLine* command_line = CommandLine::ForCurrentProcess();
+ command_line->AppendSwitch(switches::kForceAppMode);
+ command_line->AppendSwitchASCII(switches::kAppId, extension_id);
+
+ OpenApplication(AppLaunchParams(
+ profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW));
bartfab (slow) 2014/02/13 19:51:53 Nit 1: #include "chrome/common/extensions/extensio
rkc 2014/02/13 23:22:01 Done.
rkc 2014/02/13 23:22:01 Done.
+ InitAppSession(profile_, extension_id);
+
+ UserManager::Get()->SessionStarted();
+
+ LoginDisplayHostImpl::default_host()->Finalize();
bartfab (slow) 2014/02/13 19:51:53 Nit: #include "chrome/browser/chromeos/login/login
rkc 2014/02/13 23:22:01 Done.
+}
+
+void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) {
+ LOG(ERROR) << "Loading the Kiosk Profile failed.";
+}
+
+} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698