Chromium Code Reviews| Index: chrome/browser/chromeos/login/screen_locker.cc |
| diff --git a/chrome/browser/chromeos/login/screen_locker.cc b/chrome/browser/chromeos/login/screen_locker.cc |
| index 3915714005adf4db441a951e54e8e90d9b940fa1..e1e69f90a371ee06b03d456c9e6d84689d392c11 100644 |
| --- a/chrome/browser/chromeos/login/screen_locker.cc |
| +++ b/chrome/browser/chromeos/login/screen_locker.cc |
| @@ -24,6 +24,7 @@ |
| #include "base/strings/string_util.h" |
| #include "base/timer/timer.h" |
| #include "chrome/browser/chrome_notification_types.h" |
| +#include "chrome/browser/chromeos/extensions/screenlock_private_api.h" |
| #include "chrome/browser/chromeos/login/authenticator.h" |
| #include "chrome/browser/chromeos/login/login_performer.h" |
| #include "chrome/browser/chromeos/login/login_utils.h" |
| @@ -257,10 +258,26 @@ void ScreenLocker::UnlockOnLoginSuccess() { |
| void ScreenLocker::Authenticate(const UserContext& user_context) { |
| LOG_ASSERT(IsUserLoggedIn(user_context.username)) |
| << "Invalid user trying to unlock."; |
| + |
| authentication_start_time_ = base::Time::Now(); |
| delegate_->SetInputEnabled(false); |
| delegate_->OnAuthenticate(); |
| + // Send authentication request to app using chrome.screenlockPrivate API |
| + // if the authentication type is not the system password. |
| + LoginDisplay::AuthType auth_type = GetAuthType(user_context.username); |
| + if (auth_type != LoginDisplay::OFFLINE_PASSWORD) { |
| + const User* unlock_user = |
| + UserManager::Get()->FindUser(user_context.username); |
|
xiyuan
2014/02/19 21:48:44
nit: It's better use the |users_| of ScreenLocker,
Tim Song
2014/02/20 00:06:46
Done.
|
| + LOG_ASSERT(unlock_user); |
| + Profile* profile = UserManager::Get()->GetProfileByUser(unlock_user); |
| + extensions::ScreenlockPrivateEventRouter* router = |
| + extensions::ScreenlockPrivateEventRouter::GetFactoryInstance() |
| + ->GetForProfile(profile); |
| + router->OnAuthAttempted(auth_type, user_context.password); |
| + return; |
| + } |
| + |
| BrowserThread::PostTask( |
| BrowserThread::UI, FROM_HERE, |
| base::Bind(&Authenticator::AuthenticateToUnlock, |
| @@ -304,10 +321,36 @@ void ScreenLocker::ShowUserPodButton(const std::string& username, |
| screenlock_icon_provider_->AddIcon(username, icon); |
| - // Append the current time to the URL so the image will not be cached. |
| - std::string icon_url = ScreenlockIconSource::GetIconURLForUser(username) |
| - + "?" + base::Int64ToString(base::Time::Now().ToInternalValue()); |
| - delegate_->ShowUserPodButton(username, icon_url, click_callback); |
| + if (!username.empty()) { |
| + // Append the current time to the URL so the image will not be cached. |
| + std::string icon_url = |
| + ScreenlockIconSource::GetIconURLForUser(username) + "?uniq=" + |
| + base::Int64ToString(base::Time::Now().ToInternalValue()); |
| + delegate_->ShowUserPodButton(username, icon_url, click_callback); |
| + } |
| +} |
| + |
| +void ScreenLocker::HideUserPodButton(const std::string& username) { |
| + if (!locked_) |
| + return; |
| + screenlock_icon_provider_->RemoveIcon(username); |
| + delegate_->HideUserPodButton(username); |
| +} |
| + |
| +void ScreenLocker::SetAuthType(const std::string& username, |
| + LoginDisplay::AuthType auth_type, |
| + const std::string& initial_value) { |
| + if (!locked_) |
| + return; |
| + delegate_->SetAuthType(username, auth_type, initial_value); |
| +} |
| + |
| +LoginDisplay::AuthType ScreenLocker::GetAuthType(const std::string& username) |
| + const { |
| + // Return default authentication type when not locked. |
| + if (!locked_) |
| + return LoginDisplay::OFFLINE_PASSWORD; |
| + return delegate_->GetAuthType(username); |
| } |
| void ScreenLocker::ShowErrorMessage(int error_msg_id, |