OLD | NEW |
---|---|
(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) {} | |
bartfab (slow)
2014/02/13 19:51:53
Nit: #include "chrome/browser/profiles/profile.h"
rkc
2014/02/13 23:22:01
Done.
| |
27 | |
28 DemoAppLauncher::~DemoAppLauncher() {} | |
29 | |
30 void DemoAppLauncher::StartDemoAppLaunch() { | |
31 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.
| |
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; | |
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.
| |
41 } | |
42 | |
43 void DemoAppLauncher::OnProfileLoaded(Profile* profile) { | |
44 DVLOG(1) << "Profile loaded... Starting demo app launch."; | |
45 profile_ = profile; | |
46 | |
47 kiosk_profile_loader_.reset(); | |
48 | |
49 // Load our demo app, then launch it. | |
50 ExtensionService* extension_service = | |
51 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
52 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.
| |
53 IDR_DEMO_APP_MANIFEST, | |
54 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.
| |
55 | |
56 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.
| |
57 extension_service->GetExtensionById(extension_id, true); | |
58 | |
59 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
60 command_line->AppendSwitch(switches::kForceAppMode); | |
61 command_line->AppendSwitchASCII(switches::kAppId, extension_id); | |
62 | |
63 OpenApplication(AppLaunchParams( | |
64 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.
| |
65 InitAppSession(profile_, extension_id); | |
66 | |
67 UserManager::Get()->SessionStarted(); | |
68 | |
69 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.
| |
70 } | |
71 | |
72 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { | |
73 LOG(ERROR) << "Loading the Kiosk Profile failed."; | |
74 } | |
75 | |
76 } // namespace chromeos | |
OLD | NEW |