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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 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/login/demo_mode/demo_app_launcher.h"
6
7 #include "base/command_line.h"
8 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h"
9 #include "chrome/browser/chromeos/login/login_display_host_impl.h"
10 #include "chrome/browser/chromeos/login/user_manager.h"
11 #include "chrome/browser/extensions/component_loader.h"
12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/ui/extensions/application_launch.h"
14 #include "chrome/common/chrome_switches.h"
15 #include "extensions/browser/extension_system.h"
16 #include "grit/browser_resources.h"
17
18 namespace {
19
20 const char kDemoAppUserId[] = "demouser@demo.app.local";
21
22 }
23
24 namespace chromeos {
25
26 DemoAppLauncher::DemoAppLauncher() : profile_(NULL) {}
27
28 DemoAppLauncher::~DemoAppLauncher() {}
29
30 void DemoAppLauncher::StartDemoAppLaunch() {
31 DVLOG(1) << "Launching demo app...";
32 // user_id = DemoAppUserId, force_emphemeral = true, delegate = this.
33 kiosk_profile_loader_.reset(
34 new KioskProfileLoader(kDemoAppUserId, true, this));
35 kiosk_profile_loader_->Start();
36 }
37
38 // static
39 bool DemoAppLauncher::IsDemoAppSession(const std::string& user_id) {
40 return user_id == kDemoAppUserId ? true : false;
41 }
42
xiyuan 2014/02/12 00:03:22 nit: nuke one empty line
rkc 2014/02/12 00:08:07 Done.
43
44 void DemoAppLauncher::OnProfileLoaded(Profile* profile) {
45 DVLOG(1) << "Profile loaded... Starting demo app launch.";
46 profile_ = profile;
47
48 kiosk_profile_loader_.reset();
49
50 // Load our demo app, then launch it.
51 ExtensionService* extension_service =
52 extensions::ExtensionSystem::Get(profile_)->extension_service();
53 std::string extension_id = extension_service->component_loader()->Add(
54 IDR_DEMO_APP_MANIFEST,
55 base::FilePath("/usr/share/chromeos-assets/demo_app"));
56
57 const extensions::Extension* extension =
58 extension_service->GetExtensionById(extension_id, true);
59
60 CommandLine* command_line = CommandLine::ForCurrentProcess();
61 command_line->AppendSwitch(switches::kForceAppMode);
62 command_line->AppendSwitchASCII(switches::kAppId, extension_id);
63
64 OpenApplication(AppLaunchParams(
65 profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW));
66 InitAppSession(profile_, extension_id);
67
68 UserManager::Get()->SessionStarted();
69
70 LoginDisplayHostImpl::default_host()->Finalize();
71 }
72
73 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) {
74 LOG(ERROR) << "Loading the Kiosk Profile failed.";
75 }
76
77 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698