| 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/kiosk_app_manager.h" | 10 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.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/extensions/component_loader.h" | 12 #include "chrome/browser/extensions/component_loader.h" |
| 13 #include "chrome/browser/extensions/extension_service.h" | 13 #include "chrome/browser/extensions/extension_service.h" |
| 14 #include "chrome/browser/lifetime/application_lifetime.h" | 14 #include "chrome/browser/lifetime/application_lifetime.h" |
| 15 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
| 16 #include "chrome/browser/ui/extensions/app_launch_params.h" | 16 #include "chrome/browser/ui/extensions/app_launch_params.h" |
| 17 #include "chrome/browser/ui/extensions/application_launch.h" | 17 #include "chrome/browser/ui/extensions/application_launch.h" |
| 18 #include "chrome/common/chrome_switches.h" | 18 #include "chrome/common/chrome_switches.h" |
| 19 #include "chrome/common/extensions/extension_constants.h" | 19 #include "chrome/common/extensions/extension_constants.h" |
| 20 #include "chrome/grit/browser_resources.h" | 20 #include "chrome/grit/browser_resources.h" |
| 21 #include "chromeos/login/user_names.h" | |
| 22 #include "chromeos/network/network_handler.h" | 21 #include "chromeos/network/network_handler.h" |
| 23 #include "chromeos/network/network_state_handler.h" | 22 #include "chromeos/network/network_state_handler.h" |
| 24 #include "components/signin/core/account_id/account_id.h" | 23 #include "components/signin/core/account_id/account_id.h" |
| 25 #include "components/user_manager/user_manager.h" | 24 #include "components/user_manager/user_manager.h" |
| 25 #include "components/user_manager/user_names.h" |
| 26 #include "extensions/browser/extension_system.h" | 26 #include "extensions/browser/extension_system.h" |
| 27 #include "extensions/common/constants.h" | 27 #include "extensions/common/constants.h" |
| 28 #include "extensions/common/extension.h" | 28 #include "extensions/common/extension.h" |
| 29 #include "ui/base/window_open_disposition.h" | 29 #include "ui/base/window_open_disposition.h" |
| 30 | 30 |
| 31 namespace chromeos { | 31 namespace chromeos { |
| 32 | 32 |
| 33 const char DemoAppLauncher::kDemoAppId[] = "klimoghijjogocdbaikffefjfcfheiel"; | 33 const char DemoAppLauncher::kDemoAppId[] = "klimoghijjogocdbaikffefjfcfheiel"; |
| 34 const base::FilePath::CharType kDefaultDemoAppPath[] = | 34 const base::FilePath::CharType kDefaultDemoAppPath[] = |
| 35 FILE_PATH_LITERAL("/usr/share/chromeos-assets/demo_app"); | 35 FILE_PATH_LITERAL("/usr/share/chromeos-assets/demo_app"); |
| 36 | 36 |
| 37 // static | 37 // static |
| 38 base::FilePath* DemoAppLauncher::demo_app_path_ = NULL; | 38 base::FilePath* DemoAppLauncher::demo_app_path_ = NULL; |
| 39 | 39 |
| 40 DemoAppLauncher::DemoAppLauncher() { | 40 DemoAppLauncher::DemoAppLauncher() { |
| 41 if (!demo_app_path_) | 41 if (!demo_app_path_) |
| 42 demo_app_path_ = new base::FilePath(kDefaultDemoAppPath); | 42 demo_app_path_ = new base::FilePath(kDefaultDemoAppPath); |
| 43 } | 43 } |
| 44 | 44 |
| 45 DemoAppLauncher::~DemoAppLauncher() { | 45 DemoAppLauncher::~DemoAppLauncher() { |
| 46 delete demo_app_path_; | 46 delete demo_app_path_; |
| 47 } | 47 } |
| 48 | 48 |
| 49 void DemoAppLauncher::StartDemoAppLaunch() { | 49 void DemoAppLauncher::StartDemoAppLaunch() { |
| 50 DVLOG(1) << "Launching demo app..."; | 50 DVLOG(1) << "Launching demo app..."; |
| 51 // user_id = DemoAppUserId, force_emphemeral = true, delegate = this. | 51 // user_id = DemoAppUserId, force_emphemeral = true, delegate = this. |
| 52 kiosk_profile_loader_.reset( | 52 kiosk_profile_loader_.reset(new KioskProfileLoader( |
| 53 new KioskProfileLoader(login::DemoAccountId(), true, this)); | 53 user_manager::chromeos::DemoAccountId(), true, this)); |
| 54 kiosk_profile_loader_->Start(); | 54 kiosk_profile_loader_->Start(); |
| 55 } | 55 } |
| 56 | 56 |
| 57 // static | 57 // static |
| 58 bool DemoAppLauncher::IsDemoAppSession(const AccountId& account_id) { | 58 bool DemoAppLauncher::IsDemoAppSession(const AccountId& account_id) { |
| 59 return account_id == login::DemoAccountId(); | 59 return account_id == user_manager::chromeos::DemoAccountId(); |
| 60 } | 60 } |
| 61 | 61 |
| 62 // static | 62 // static |
| 63 void DemoAppLauncher::SetDemoAppPathForTesting(const base::FilePath& path) { | 63 void DemoAppLauncher::SetDemoAppPathForTesting(const base::FilePath& path) { |
| 64 delete demo_app_path_; | 64 delete demo_app_path_; |
| 65 demo_app_path_ = new base::FilePath(path); | 65 demo_app_path_ = new base::FilePath(path); |
| 66 } | 66 } |
| 67 | 67 |
| 68 void DemoAppLauncher::OnProfileLoaded(Profile* profile) { | 68 void DemoAppLauncher::OnProfileLoaded(Profile* profile) { |
| 69 DVLOG(1) << "Profile loaded... Starting demo app launch."; | 69 DVLOG(1) << "Profile loaded... Starting demo app launch."; |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 | 104 |
| 105 LoginDisplayHost::default_host()->Finalize(); | 105 LoginDisplayHost::default_host()->Finalize(); |
| 106 } | 106 } |
| 107 | 107 |
| 108 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { | 108 void DemoAppLauncher::OnProfileLoadFailed(KioskAppLaunchError::Error error) { |
| 109 LOG(ERROR) << "Loading the Kiosk Profile failed: " << | 109 LOG(ERROR) << "Loading the Kiosk Profile failed: " << |
| 110 KioskAppLaunchError::GetErrorMessage(error); | 110 KioskAppLaunchError::GetErrorMessage(error); |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace chromeos | 113 } // namespace chromeos |
| OLD | NEW |