Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(271)

Side by Side Diff: chrome/browser/chromeos/login/screen_locker.cc

Issue 168813002: Refactor user pods to use authType property for distinct authentication modes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/screen_locker.h" 5 #include "chrome/browser/chromeos/login/screen_locker.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "ash/ash_switches.h" 10 #include "ash/ash_switches.h"
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 authentication_capture_.reset(); 250 authentication_capture_.reset();
251 weak_factory_.InvalidateWeakPtrs(); 251 weak_factory_.InvalidateWeakPtrs();
252 252
253 VLOG(1) << "Hiding the lock screen."; 253 VLOG(1) << "Hiding the lock screen.";
254 chromeos::ScreenLocker::Hide(); 254 chromeos::ScreenLocker::Hide();
255 } 255 }
256 256
257 void ScreenLocker::Authenticate(const UserContext& user_context) { 257 void ScreenLocker::Authenticate(const UserContext& user_context) {
258 LOG_ASSERT(IsUserLoggedIn(user_context.username)) 258 LOG_ASSERT(IsUserLoggedIn(user_context.username))
259 << "Invalid user trying to unlock."; 259 << "Invalid user trying to unlock.";
260
261 // Send authentication request to app using chrome.screenlockPrivate API
262 // if the authentication type is not the system password.
263 LoginDisplay::AuthType auth_type = GetAuthType(user_context.username);
264 if (auth_type != LoginDisplay::SYSTEM_PASSWORD) {
265 Profile* profile = UserManager::Get()->GetProfileByUser(
266 UserManager::Get()->GetActiveUser());
xiyuan 2014/02/16 18:38:14 This is not always the case when multi profile is
Tim Song 2014/02/18 23:32:44 It seems that ScreenLocker already assumes there i
xiyuan 2014/02/19 00:17:52 That is a bad assumption and we should not follow
Tim Song 2014/02/19 19:26:57 Done.
267 extensions::ScreenlockPrivateEventRouter* router =
268 extensions::ScreenlockPrivateEventRouter::GetFactoryInstance()
269 ->GetForProfile(profile);
270 router->OnAuthAttempted(auth_type, user_context.password);
xiyuan 2014/02/16 18:38:14 How do we get feedback from the auth attempt? What
Tim Song 2014/02/18 23:32:44 The app can unlock the screen if the auth attempt
xiyuan 2014/02/19 00:17:52 We do after we moved the "SetInputEnabled(false)"
Tim Song 2014/02/19 19:26:57 You're right. I added an acceptAuthAttempt() funct
xiyuan 2014/02/19 21:48:44 SGTM. I saw you call ScreenLocker::EnableInput in
271 return;
272 }
xiyuan 2014/02/16 18:38:14 Should we move the whole block under "delegate_->O
Tim Song 2014/02/18 23:32:44 Done.
273
260 authentication_start_time_ = base::Time::Now(); 274 authentication_start_time_ = base::Time::Now();
261 delegate_->SetInputEnabled(false); 275 delegate_->SetInputEnabled(false);
262 delegate_->OnAuthenticate(); 276 delegate_->OnAuthenticate();
263 277
264 BrowserThread::PostTask( 278 BrowserThread::PostTask(
265 BrowserThread::UI, FROM_HERE, 279 BrowserThread::UI, FROM_HERE,
266 base::Bind(&Authenticator::AuthenticateToUnlock, 280 base::Bind(&Authenticator::AuthenticateToUnlock,
267 authenticator_.get(), 281 authenticator_.get(),
268 user_context)); 282 user_context));
269 } 283 }
(...skipping 27 matching lines...) Expand all
297 } 311 }
298 312
299 void ScreenLocker::ShowUserPodButton(const std::string& username, 313 void ScreenLocker::ShowUserPodButton(const std::string& username,
300 const gfx::Image& icon, 314 const gfx::Image& icon,
301 const base::Closure& click_callback) { 315 const base::Closure& click_callback) {
302 if (!locked_) 316 if (!locked_)
303 return; 317 return;
304 318
305 screenlock_icon_provider_->AddIcon(username, icon); 319 screenlock_icon_provider_->AddIcon(username, icon);
306 320
307 // Append the current time to the URL so the image will not be cached. 321 if (!username.empty()) {
308 std::string icon_url = ScreenlockIconSource::GetIconURLForUser(username) 322 // Append the current time to the URL so the image will not be cached.
309 + "?" + base::Int64ToString(base::Time::Now().ToInternalValue()); 323 std::string icon_url =
310 delegate_->ShowUserPodButton(username, icon_url, click_callback); 324 ScreenlockIconSource::GetIconURLForUser(username) + "?" +
325 base::Int64ToString(base::Time::Now().ToInternalValue());
xiyuan 2014/02/16 18:38:14 nit: prepend a "uniq=" to give the time a param na
Tim Song 2014/02/18 23:32:44 Done.
326 delegate_->ShowUserPodButton(username, icon_url, click_callback);
327 }
328 }
329
330 void ScreenLocker::HideUserPodButton(const std::string& username) {
331 if (!locked_)
332 return;
333 screenlock_icon_provider_->RemoveIcon(username);
334 delegate_->HideUserPodButton(username);
335 }
336
337 void ScreenLocker::SetAuthType(const std::string& username,
338 LoginDisplay::AuthType auth_type,
339 const std::string& initial_value) {
340 if (!locked_)
341 return;
342 delegate_->SetAuthType(username, auth_type, initial_value);
343 }
344
345 LoginDisplay::AuthType ScreenLocker::GetAuthType(const std::string& username)
346 const {
347 // Return default authentication type when not locked.
348 if (!locked_)
349 return LoginDisplay::SYSTEM_PASSWORD;
350 return delegate_->GetAuthType(username);
311 } 351 }
312 352
313 void ScreenLocker::ShowErrorMessage(int error_msg_id, 353 void ScreenLocker::ShowErrorMessage(int error_msg_id,
314 HelpAppLauncher::HelpTopic help_topic_id, 354 HelpAppLauncher::HelpTopic help_topic_id,
315 bool sign_out_only) { 355 bool sign_out_only) {
316 delegate_->SetInputEnabled(!sign_out_only); 356 delegate_->SetInputEnabled(!sign_out_only);
317 delegate_->ShowErrorMessage(error_msg_id, help_topic_id); 357 delegate_->ShowErrorMessage(error_msg_id, help_topic_id);
318 } 358 }
319 359
320 void ScreenLocker::SetLoginStatusConsumer( 360 void ScreenLocker::SetLoginStatusConsumer(
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 515
476 bool ScreenLocker::IsUserLoggedIn(const std::string& username) { 516 bool ScreenLocker::IsUserLoggedIn(const std::string& username) {
477 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) { 517 for (UserList::const_iterator it = users_.begin(); it != users_.end(); ++it) {
478 if ((*it)->email() == username) 518 if ((*it)->email() == username)
479 return true; 519 return true;
480 } 520 }
481 return false; 521 return false;
482 } 522 }
483 523
484 } // namespace chromeos 524 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698