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/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
110 int retry_count_; | 110 int retry_count_; |
111 | 111 |
112 DISALLOW_COPY_AND_ASSIGN(CryptohomedChecker); | 112 DISALLOW_COPY_AND_ASSIGN(CryptohomedChecker); |
113 }; | 113 }; |
114 | 114 |
115 | 115 |
116 //////////////////////////////////////////////////////////////////////////////// | 116 //////////////////////////////////////////////////////////////////////////////// |
117 // KioskProfileLoader | 117 // KioskProfileLoader |
118 | 118 |
119 KioskProfileLoader::KioskProfileLoader(const std::string& app_user_id, | 119 KioskProfileLoader::KioskProfileLoader(const std::string& app_user_id, |
120 bool force_ephemeral, | 120 bool force_guest, |
121 Delegate* delegate) | 121 Delegate* delegate) |
122 : user_id_(app_user_id), | 122 : user_id_(app_user_id), |
123 force_ephemeral_(force_ephemeral), | 123 force_guest_(force_guest), |
124 delegate_(delegate) {} | 124 delegate_(delegate) {} |
125 | 125 |
126 KioskProfileLoader::~KioskProfileLoader() {} | 126 KioskProfileLoader::~KioskProfileLoader() {} |
127 | 127 |
128 void KioskProfileLoader::Start() { | 128 void KioskProfileLoader::Start() { |
129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 129 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
130 login_performer_.reset(); | 130 login_performer_.reset(); |
131 cryptohomed_checker_.reset(new CryptohomedChecker(this)); | 131 cryptohomed_checker_.reset(new CryptohomedChecker(this)); |
132 cryptohomed_checker_->StartCheck(); | 132 cryptohomed_checker_->StartCheck(); |
133 } | 133 } |
134 | 134 |
135 void KioskProfileLoader::LoginAsKioskAccount() { | 135 void KioskProfileLoader::LoginAsKioskAccount() { |
136 login_performer_.reset(new LoginPerformer(this)); | 136 login_performer_.reset(new LoginPerformer(this)); |
137 login_performer_->LoginAsKioskAccount(user_id_, force_ephemeral_); | 137 login_performer_->LoginAsKioskAccount(user_id_, force_guest_); |
138 } | 138 } |
139 | 139 |
140 void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) { | 140 void KioskProfileLoader::ReportLaunchResult(KioskAppLaunchError::Error error) { |
141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 141 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
142 | 142 |
143 if (error != KioskAppLaunchError::NONE) { | 143 if (error != KioskAppLaunchError::NONE) { |
144 delegate_->OnProfileLoadFailed(error); | 144 delegate_->OnProfileLoadFailed(error); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 void KioskProfileLoader::OnLoginSuccess(const UserContext& user_context) { | 148 void KioskProfileLoader::OnLoginSuccess(const UserContext& user_context) { |
149 // LoginPerformer will delete itself. | 149 // LoginPerformer will delete itself. |
150 login_performer_->set_delegate(NULL); | 150 login_performer_->set_delegate(NULL); |
151 ignore_result(login_performer_.release()); | 151 ignore_result(login_performer_.release()); |
152 | 152 |
153 // If we are launching a demo session, we need to start MountGuest with the | 153 // If we are launching a demo session, we need to start MountGuest with the |
154 // guest username; this is because there are several places in the cros code | 154 // guest username; this is because there are several places in the cros code |
155 // which rely on the username sent to cryptohome to be $guest. Back in Chrome | 155 // which rely on the username sent to cryptohome to be $guest. Back in Chrome |
156 // we switch this back to the demo user name to correctly identify this | 156 // we switch this back to the demo user name to correctly identify this |
157 // user as a demo user. | 157 // user as a demo user. |
158 UserContext context = user_context; | 158 UserContext context = user_context; |
159 if (context.username == UserManager::kGuestUserName) | 159 if (context.username == UserManager::kGuestUserName) { |
160 context.username = DemoAppLauncher::kDemoUserName; | 160 context.username = DemoAppLauncher::kDemoUserName; |
161 // We can't have an empty hash. Currently mounting guest does not actually | |
162 // give us a user hash; the way we deal with this for Guest Mode is by | |
163 // setting a fake hash value. This needs to be fixed, see crbug.com/355134. | |
164 if (context.username_hash.empty()) | |
165 context.username_hash = context.username + "- demouserhashfakevalue"; | |
xiyuan
2014/03/22 04:02:42
nit: strip the space between "-" and the suffix.
bartfab (slow)
2014/03/25 12:52:54
1) Why not simply use "demouserhashfakevalue" as t
rkc
2014/03/26 21:30:40
So this wasn't really a good solution to go with.
rkc
2014/03/26 21:30:40
Code removed.
| |
166 } | |
161 LoginUtils::Get()->PrepareProfile(context, | 167 LoginUtils::Get()->PrepareProfile(context, |
162 std::string(), // display email | 168 std::string(), // display email |
163 false, // has_cookies | 169 false, // has_cookies |
164 false, // has_active_session | 170 false, // has_active_session |
165 this); | 171 this); |
166 } | 172 } |
167 | 173 |
168 void KioskProfileLoader::OnLoginFailure(const LoginFailure& error) { | 174 void KioskProfileLoader::OnLoginFailure(const LoginFailure& error) { |
169 ReportLaunchResult(LoginFailureToKioskAppLaunchError(error)); | 175 ReportLaunchResult(LoginFailureToKioskAppLaunchError(error)); |
170 } | 176 } |
(...skipping 14 matching lines...) Expand all Loading... | |
185 void KioskProfileLoader::OnProfilePrepared(Profile* profile) { | 191 void KioskProfileLoader::OnProfilePrepared(Profile* profile) { |
186 // This object could be deleted any time after successfully reporting | 192 // This object could be deleted any time after successfully reporting |
187 // a profile load, so invalidate the LoginUtils delegate now. | 193 // a profile load, so invalidate the LoginUtils delegate now. |
188 LoginUtils::Get()->DelegateDeleted(this); | 194 LoginUtils::Get()->DelegateDeleted(this); |
189 | 195 |
190 delegate_->OnProfileLoaded(profile); | 196 delegate_->OnProfileLoaded(profile); |
191 ReportLaunchResult(KioskAppLaunchError::NONE); | 197 ReportLaunchResult(KioskAppLaunchError::NONE); |
192 } | 198 } |
193 | 199 |
194 } // namespace chromeos | 200 } // namespace chromeos |
OLD | NEW |