| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/app_mode/kiosk_profile_loader.h" | 5 #include "chrome/browser/chromeos/app_mode/kiosk_profile_loader.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 KioskProfileLoader* loader_; | 112 KioskProfileLoader* loader_; |
| 113 int retry_count_; | 113 int retry_count_; |
| 114 | 114 |
| 115 DISALLOW_COPY_AND_ASSIGN(CryptohomedChecker); | 115 DISALLOW_COPY_AND_ASSIGN(CryptohomedChecker); |
| 116 }; | 116 }; |
| 117 | 117 |
| 118 | 118 |
| 119 //////////////////////////////////////////////////////////////////////////////// | 119 //////////////////////////////////////////////////////////////////////////////// |
| 120 // KioskProfileLoader | 120 // KioskProfileLoader |
| 121 | 121 |
| 122 KioskProfileLoader::KioskProfileLoader(const std::string& app_user_id, | 122 KioskProfileLoader::KioskProfileLoader(const AccountId& app_account_id, |
| 123 bool use_guest_mount, | 123 bool use_guest_mount, |
| 124 Delegate* delegate) | 124 Delegate* delegate) |
| 125 : user_id_(app_user_id), | 125 : account_id_(app_account_id), |
| 126 use_guest_mount_(use_guest_mount), | 126 use_guest_mount_(use_guest_mount), |
| 127 delegate_(delegate) {} | 127 delegate_(delegate) {} |
| 128 | 128 |
| 129 KioskProfileLoader::~KioskProfileLoader() {} | 129 KioskProfileLoader::~KioskProfileLoader() {} |
| 130 | 130 |
| 131 void KioskProfileLoader::Start() { | 131 void KioskProfileLoader::Start() { |
| 132 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 132 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 133 login_performer_.reset(); | 133 login_performer_.reset(); |
| 134 cryptohomed_checker_.reset(new CryptohomedChecker(this)); | 134 cryptohomed_checker_.reset(new CryptohomedChecker(this)); |
| 135 cryptohomed_checker_->StartCheck(); | 135 cryptohomed_checker_->StartCheck(); |
| 136 } | 136 } |
| 137 | 137 |
| 138 void KioskProfileLoader::LoginAsKioskAccount() { | 138 void KioskProfileLoader::LoginAsKioskAccount() { |
| 139 login_performer_.reset(new ChromeLoginPerformer(this)); | 139 login_performer_.reset(new ChromeLoginPerformer(this)); |
| 140 login_performer_->LoginAsKioskAccount(user_id_, use_guest_mount_); | 140 login_performer_->LoginAsKioskAccount(account_id_, use_guest_mount_); |
| 141 } | 141 } |
| 142 | 142 |
| 143 void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) { | 143 void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) { |
| 144 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 144 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 145 | 145 |
| 146 if (error != KioskAppLaunchError::NONE) { | 146 if (error != KioskAppLaunchError::NONE) { |
| 147 delegate_->OnProfileLoadFailed(error); | 147 delegate_->OnProfileLoadFailed(error); |
| 148 } | 148 } |
| 149 } | 149 } |
| 150 | 150 |
| 151 void KioskProfileLoader::OnAuthSuccess(const UserContext& user_context) { | 151 void KioskProfileLoader::OnAuthSuccess(const UserContext& user_context) { |
| 152 // LoginPerformer will delete itself. | 152 // LoginPerformer will delete itself. |
| 153 login_performer_->set_delegate(NULL); | 153 login_performer_->set_delegate(NULL); |
| 154 ignore_result(login_performer_.release()); | 154 ignore_result(login_performer_.release()); |
| 155 | 155 |
| 156 // If we are launching a demo session, we need to start MountGuest with the | 156 // If we are launching a demo session, we need to start MountGuest with the |
| 157 // guest username; this is because there are several places in the cros code | 157 // guest username; this is because there are several places in the cros code |
| 158 // which rely on the username sent to cryptohome to be $guest. Back in Chrome | 158 // which rely on the username sent to cryptohome to be $guest. Back in Chrome |
| 159 // we switch this back to the demo user name to correctly identify this | 159 // we switch this back to the demo user name to correctly identify this |
| 160 // user as a demo user. | 160 // user as a demo user. |
| 161 UserContext context = user_context; | 161 UserContext context = user_context; |
| 162 if (context.GetAccountId() == login::GuestAccountId()) | 162 if (context.GetAccountId() == login::GuestAccountId()) |
| 163 context.SetUserID(login::DemoAccountId().GetUserEmail()); | 163 context.SetAccountId(login::DemoAccountId()); |
| 164 UserSessionManager::GetInstance()->StartSession( | 164 UserSessionManager::GetInstance()->StartSession( |
| 165 context, UserSessionManager::PRIMARY_USER_SESSION, | 165 context, UserSessionManager::PRIMARY_USER_SESSION, |
| 166 false, // has_auth_cookies | 166 false, // has_auth_cookies |
| 167 false, // Start session for user. | 167 false, // Start session for user. |
| 168 this); | 168 this); |
| 169 } | 169 } |
| 170 | 170 |
| 171 void KioskProfileLoader::OnAuthFailure(const AuthFailure& error) { | 171 void KioskProfileLoader::OnAuthFailure(const AuthFailure& error) { |
| 172 ReportLaunchResult(LoginFailureToKioskAppLaunchError(error)); | 172 ReportLaunchResult(LoginFailureToKioskAppLaunchError(error)); |
| 173 } | 173 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 188 bool browser_launched) { | 188 bool browser_launched) { |
| 189 // This object could be deleted any time after successfully reporting | 189 // This object could be deleted any time after successfully reporting |
| 190 // a profile load, so invalidate the delegate now. | 190 // a profile load, so invalidate the delegate now. |
| 191 UserSessionManager::GetInstance()->DelegateDeleted(this); | 191 UserSessionManager::GetInstance()->DelegateDeleted(this); |
| 192 | 192 |
| 193 delegate_->OnProfileLoaded(profile); | 193 delegate_->OnProfileLoaded(profile); |
| 194 ReportLaunchResult(KioskAppLaunchError::NONE); | 194 ReportLaunchResult(KioskAppLaunchError::NONE); |
| 195 } | 195 } |
| 196 | 196 |
| 197 } // namespace chromeos | 197 } // namespace chromeos |
| OLD | NEW |