Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" | 5 #include "chrome/browser/chromeos/login/demo_mode/demo_app_launcher.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | |
| 9 #include "base/logging.h" | |
| 8 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h" | 10 #include "chrome/browser/chromeos/app_mode/app_session_lifetime.h" |
| 11 #include "chrome/browser/chromeos/login/login_display_host.h" | |
| 9 #include "chrome/browser/chromeos/login/login_display_host_impl.h" | 12 #include "chrome/browser/chromeos/login/login_display_host_impl.h" |
| 10 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
| 11 #include "chrome/browser/extensions/component_loader.h" | 14 #include "chrome/browser/extensions/component_loader.h" |
| 12 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/profiles/profile.h" | |
| 13 #include "chrome/browser/ui/extensions/application_launch.h" | 17 #include "chrome/browser/ui/extensions/application_launch.h" |
| 14 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | |
| 15 #include "extensions/browser/extension_system.h" | 20 #include "extensions/browser/extension_system.h" |
| 21 #include "extensions/common/extension.h" | |
| 16 #include "grit/browser_resources.h" | 22 #include "grit/browser_resources.h" |
| 23 #include "ui/base/window_open_disposition.h" | |
| 17 | 24 |
| 18 namespace { | 25 namespace { |
| 19 | 26 |
| 20 const char kDemoAppUserId[] = "demouser@demo.app.local"; | 27 const char kDemoAppUserId[] = "demouser@demo.app.local"; |
| 21 | 28 |
| 22 } | 29 } |
| 23 | 30 |
| 24 namespace chromeos { | 31 namespace chromeos { |
| 25 | 32 |
| 26 DemoAppLauncher::DemoAppLauncher() : profile_(NULL) {} | 33 DemoAppLauncher::DemoAppLauncher() {} |
| 27 | 34 |
| 28 DemoAppLauncher::~DemoAppLauncher() {} | 35 DemoAppLauncher::~DemoAppLauncher() {} |
| 29 | 36 |
| 30 void DemoAppLauncher::StartDemoAppLaunch() { | 37 void DemoAppLauncher::StartDemoAppLaunch() { |
| 31 DVLOG(1) << "Launching demo app..."; | 38 DVLOG(1) << "Launching demo app..."; |
| 32 // user_id = DemoAppUserId, force_emphemeral = true, delegate = this. | 39 // user_id = DemoAppUserId, force_emphemeral = true, delegate = this. |
| 33 kiosk_profile_loader_.reset( | 40 kiosk_profile_loader_.reset( |
| 34 new KioskProfileLoader(kDemoAppUserId, true, this)); | 41 new KioskProfileLoader(kDemoAppUserId, true, this)); |
| 35 kiosk_profile_loader_->Start(); | 42 kiosk_profile_loader_->Start(); |
| 36 } | 43 } |
| 37 | 44 |
| 38 // static | 45 // static |
| 39 bool DemoAppLauncher::IsDemoAppSession(const std::string& user_id) { | 46 bool DemoAppLauncher::IsDemoAppSession(const std::string& user_id) { |
| 40 return user_id == kDemoAppUserId ? true : false; | 47 return (user_id == kDemoAppUserId); |
|
bartfab (slow)
2014/02/17 15:53:58
Nit: The parentheses violate the style guide:
htt
| |
| 41 } | 48 } |
| 42 | 49 |
| 43 void DemoAppLauncher::OnProfileLoaded(Profile* profile) { | 50 void DemoAppLauncher::OnProfileLoaded(Profile* profile) { |
| 44 DVLOG(1) << "Profile loaded... Starting demo app launch."; | 51 DVLOG(1) << "Profile loaded... Starting demo app launch."; |
| 45 profile_ = profile; | |
| 46 | |
| 47 kiosk_profile_loader_.reset(); | 52 kiosk_profile_loader_.reset(); |
| 48 | 53 |
| 49 // Load our demo app, then launch it. | 54 // Load our demo app, then launch it. |
| 50 ExtensionService* extension_service = | 55 ExtensionService* extension_service = |
| 51 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 56 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 52 std::string extension_id = extension_service->component_loader()->Add( | 57 const std::string extension_id = extension_service->component_loader()->Add( |
| 53 IDR_DEMO_APP_MANIFEST, | 58 IDR_DEMO_APP_MANIFEST, |
| 54 base::FilePath("/usr/share/chromeos-assets/demo_app")); | 59 base::FilePath("/usr/share/chromeos-assets/demo_app")); |
| 55 | 60 |
| 56 const extensions::Extension* extension = | 61 const extensions::Extension* extension = |
| 57 extension_service->GetExtensionById(extension_id, true); | 62 extension_service->GetExtensionById(extension_id, true); |
| 58 | 63 |
| 59 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 64 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 60 command_line->AppendSwitch(switches::kForceAppMode); | 65 command_line->AppendSwitch(switches::kForceAppMode); |
| 61 command_line->AppendSwitchASCII(switches::kAppId, extension_id); | 66 command_line->AppendSwitchASCII(switches::kAppId, extension_id); |
| 62 | 67 |
| 63 OpenApplication(AppLaunchParams( | 68 OpenApplication(AppLaunchParams( |
| 64 profile_, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); | 69 profile, extension, extensions::LAUNCH_CONTAINER_WINDOW, NEW_WINDOW)); |
| 65 InitAppSession(profile_, extension_id); | 70 InitAppSession(profile, extension_id); |
| 66 | 71 |
| 67 UserManager::Get()->SessionStarted(); | 72 UserManager::Get()->SessionStarted(); |
| 68 | 73 |
| 69 LoginDisplayHostImpl::default_host()->Finalize(); | 74 LoginDisplayHostImpl::default_host()->Finalize(); |
| 70 } | 75 } |
| 71 | 76 |
| 72 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { | 77 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { |
| 73 LOG(ERROR) << "Loading the Kiosk Profile failed."; | 78 LOG(ERROR) << "Loading the Kiosk Profile failed."; |
| 74 } | 79 } |
| 75 | 80 |
| 76 } // namespace chromeos | 81 } // namespace chromeos |
| OLD | NEW |