| 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" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #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/ui/login_display_host.h" | 11 #include "chrome/browser/chromeos/login/ui/login_display_host.h" |
| 12 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" | 12 #include "chrome/browser/chromeos/login/ui/login_display_host_impl.h" |
| 13 #include "chrome/browser/extensions/component_loader.h" | 13 #include "chrome/browser/extensions/component_loader.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/lifetime/application_lifetime.h" | 15 #include "chrome/browser/lifetime/application_lifetime.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/ui/extensions/app_launch_params.h" | 17 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 18 #include "chrome/browser/ui/extensions/application_launch.h" | 18 #include "chrome/browser/ui/extensions/application_launch.h" |
| 19 #include "chrome/common/chrome_switches.h" | 19 #include "chrome/common/chrome_switches.h" |
| 20 #include "chrome/common/extensions/extension_constants.h" | 20 #include "chrome/common/extensions/extension_constants.h" |
| 21 #include "chrome/grit/browser_resources.h" | 21 #include "chrome/grit/browser_resources.h" |
| 22 #include "chromeos/network/network_handler.h" | 22 #include "chromeos/network/network_handler.h" |
| 23 #include "chromeos/network/network_state_handler.h" | 23 #include "chromeos/network/network_state_handler.h" |
| 24 #include "components/user_manager/user_manager.h" | 24 #include "components/user_manager/user_manager.h" |
| 25 #include "extensions/browser/extension_system.h" | 25 #include "extensions/browser/extension_system.h" |
| 26 #include "extensions/common/constants.h" | 26 #include "extensions/common/constants.h" |
| 27 #include "extensions/common/extension.h" | 27 #include "extensions/common/extension.h" |
| 28 #include "ui/base/window_open_disposition.h" | 28 #include "ui/base/window_open_disposition.h" |
| 29 | 29 |
| 30 namespace { |
| 31 const char kDemoUserName[] = "demouser@demo.app.local"; |
| 32 } |
| 33 |
| 30 namespace chromeos { | 34 namespace chromeos { |
| 31 | 35 |
| 32 const char DemoAppLauncher::kDemoUserName[] = "demouser@demo.app.local"; | |
| 33 const char DemoAppLauncher::kDemoAppId[] = "klimoghijjogocdbaikffefjfcfheiel"; | 36 const char DemoAppLauncher::kDemoAppId[] = "klimoghijjogocdbaikffefjfcfheiel"; |
| 34 const base::FilePath::CharType kDefaultDemoAppPath[] = | 37 const base::FilePath::CharType kDefaultDemoAppPath[] = |
| 35 FILE_PATH_LITERAL("/usr/share/chromeos-assets/demo_app"); | 38 FILE_PATH_LITERAL("/usr/share/chromeos-assets/demo_app"); |
| 36 | 39 |
| 37 // static | 40 // static |
| 38 base::FilePath* DemoAppLauncher::demo_app_path_ = NULL; | 41 base::FilePath* DemoAppLauncher::demo_app_path_ = NULL; |
| 39 | 42 |
| 40 DemoAppLauncher::DemoAppLauncher() { | 43 DemoAppLauncher::DemoAppLauncher() { |
| 41 if (!demo_app_path_) | 44 if (!demo_app_path_) |
| 42 demo_app_path_ = new base::FilePath(kDefaultDemoAppPath); | 45 demo_app_path_ = new base::FilePath(kDefaultDemoAppPath); |
| 43 } | 46 } |
| 44 | 47 |
| 45 DemoAppLauncher::~DemoAppLauncher() { | 48 DemoAppLauncher::~DemoAppLauncher() { |
| 46 delete demo_app_path_; | 49 delete demo_app_path_; |
| 47 } | 50 } |
| 48 | 51 |
| 49 void DemoAppLauncher::StartDemoAppLaunch() { | 52 void DemoAppLauncher::StartDemoAppLaunch() { |
| 50 DVLOG(1) << "Launching demo app..."; | 53 DVLOG(1) << "Launching demo app..."; |
| 51 // user_id = DemoAppUserId, force_emphemeral = true, delegate = this. | 54 // user_id = DemoAppUserId, force_emphemeral = true, delegate = this. |
| 52 kiosk_profile_loader_.reset( | 55 kiosk_profile_loader_.reset( |
| 53 new KioskProfileLoader(kDemoUserName, true, this)); | 56 new KioskProfileLoader(GetDemoUserID(), true, this)); |
| 54 kiosk_profile_loader_->Start(); | 57 kiosk_profile_loader_->Start(); |
| 55 } | 58 } |
| 56 | 59 |
| 57 // static | 60 // static |
| 58 bool DemoAppLauncher::IsDemoAppSession(const std::string& user_id) { | 61 bool DemoAppLauncher::IsDemoAppSession(const user_manager::UserID& user_id) { |
| 59 return user_id == kDemoUserName; | 62 return user_id == GetDemoUserID(); |
| 60 } | 63 } |
| 61 | 64 |
| 62 // static | 65 // static |
| 63 void DemoAppLauncher::SetDemoAppPathForTesting(const base::FilePath& path) { | 66 void DemoAppLauncher::SetDemoAppPathForTesting(const base::FilePath& path) { |
| 64 delete demo_app_path_; | 67 delete demo_app_path_; |
| 65 demo_app_path_ = new base::FilePath(path); | 68 demo_app_path_ = new base::FilePath(path); |
| 66 } | 69 } |
| 67 | 70 |
| 71 // static |
| 72 user_manager::UserID DemoAppLauncher::GetDemoUserID() { |
| 73 return user_manager::UserID::FromUserEmail(kDemoUserName); |
| 74 } |
| 75 |
| 68 void DemoAppLauncher::OnProfileLoaded(Profile* profile) { | 76 void DemoAppLauncher::OnProfileLoaded(Profile* profile) { |
| 69 DVLOG(1) << "Profile loaded... Starting demo app launch."; | 77 DVLOG(1) << "Profile loaded... Starting demo app launch."; |
| 70 | 78 |
| 71 kiosk_profile_loader_.reset(); | 79 kiosk_profile_loader_.reset(); |
| 72 | 80 |
| 73 // Load our demo app, then launch it. | 81 // Load our demo app, then launch it. |
| 74 ExtensionService* extension_service = | 82 ExtensionService* extension_service = |
| 75 extensions::ExtensionSystem::Get(profile)->extension_service(); | 83 extensions::ExtensionSystem::Get(profile)->extension_service(); |
| 76 CHECK(demo_app_path_); | 84 CHECK(demo_app_path_); |
| 77 const std::string extension_id = extension_service->component_loader()->Add( | 85 const std::string extension_id = extension_service->component_loader()->Add( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 103 | 111 |
| 104 LoginDisplayHostImpl::default_host()->Finalize(); | 112 LoginDisplayHostImpl::default_host()->Finalize(); |
| 105 } | 113 } |
| 106 | 114 |
| 107 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { | 115 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { |
| 108 LOG(ERROR) << "Loading the Kiosk Profile failed: " << | 116 LOG(ERROR) << "Loading the Kiosk Profile failed: " << |
| 109 KioskAppLaunchError::GetErrorMessage(error); | 117 KioskAppLaunchError::GetErrorMessage(error); |
| 110 } | 118 } |
| 111 | 119 |
| 112 } // namespace chromeos | 120 } // namespace chromeos |
| OLD | NEW |