Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
|
Lei Zhang
2014/02/11 22:13:59
2014
rkc
2014/02/11 22:37:38
Done.
| |
| 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"; | |
| 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 kiosk_profile_loader_.reset(new KioskProfileLoader(kDemoAppUserId, this)); | |
| 33 kiosk_profile_loader_->Start(); | |
| 34 } | |
| 35 | |
| 36 void DemoAppLauncher::OnProfileLoaded(Profile* profile) { | |
| 37 DVLOG(1) << "Profile loaded... Starting demo app launch."; | |
| 38 profile_ = profile; | |
| 39 | |
| 40 kiosk_profile_loader_.reset(); | |
| 41 | |
| 42 // Load our demo app, then launch it. | |
| 43 ExtensionService* extension_service = | |
| 44 extensions::ExtensionSystem::Get(profile_)->extension_service(); | |
| 45 std::string extension_id = extension_service->component_loader()->Add( | |
| 46 IDR_DEMO_APP_MANIFEST, | |
| 47 base::FilePath(FILE_PATH_LITERAL("/usr/share/chromeos-assets/demo_app"))); | |
|
Lei Zhang
2014/02/11 22:13:59
you don't need FILE_PATH_LITERAL since it's CrOS-o
rkc
2014/02/11 22:37:38
Done.
| |
| 48 | |
| 49 const extensions::Extension* extension = | |
| 50 extension_service->GetExtensionById(extension_id, true); | |
| 51 | |
| 52 CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
| 53 command_line->AppendSwitch(switches::kForceAppMode); | |
| 54 command_line->AppendSwitchASCII(switches::kAppId, extension_id); | |
| 55 | |
| 56 OpenApplication(AppLaunchParams( | |
| 57 profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); | |
| 58 InitAppSession(profile_, extension_id); | |
| 59 | |
| 60 UserManager::Get()->SessionStarted(); | |
| 61 | |
| 62 LoginDisplayHostImpl::default_host()->Finalize(); | |
| 63 } | |
| 64 | |
| 65 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { | |
| 66 LOG(ERROR) << "Loading the Kiosk Profile failed."; | |
|
Lei Zhang
2014/02/11 22:13:59
Wouldn't you want to include GetErrorMessage(error
rkc
2014/02/11 22:37:38
There isn't anything we can do with the error at t
| |
| 67 } | |
| 68 | |
| 69 } // namespace chromeos | |
| OLD | NEW |