| OLD | NEW |
| 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 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 delegate_->ShowErrorMessage(incorrect_passwords_count_++ ? | 175 delegate_->ShowErrorMessage(incorrect_passwords_count_++ ? |
| 176 IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME : | 176 IDS_LOGIN_ERROR_AUTHENTICATING_2ND_TIME : |
| 177 IDS_LOGIN_ERROR_AUTHENTICATING, | 177 IDS_LOGIN_ERROR_AUTHENTICATING, |
| 178 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); | 178 HelpAppLauncher::HELP_CANT_ACCESS_ACCOUNT); |
| 179 | 179 |
| 180 if (login_status_consumer_) | 180 if (login_status_consumer_) |
| 181 login_status_consumer_->OnLoginFailure(error); | 181 login_status_consumer_->OnLoginFailure(error); |
| 182 } | 182 } |
| 183 | 183 |
| 184 void ScreenLocker::OnLoginSuccess( | 184 void ScreenLocker::OnLoginSuccess( |
| 185 const std::string& username, | 185 const UserCredentials& credentials, |
| 186 const std::string& password, | |
| 187 bool pending_requests, | 186 bool pending_requests, |
| 188 bool using_oauth) { | 187 bool using_oauth) { |
| 189 incorrect_passwords_count_ = 0; | 188 incorrect_passwords_count_ = 0; |
| 190 if (authentication_start_time_.is_null()) { | 189 if (authentication_start_time_.is_null()) { |
| 191 if (!username.empty()) | 190 if (!credentials.username.empty()) |
| 192 LOG(ERROR) << "Start time is not set at authentication success"; | 191 LOG(ERROR) << "Start time is not set at authentication success"; |
| 193 } else { | 192 } else { |
| 194 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; | 193 base::TimeDelta delta = base::Time::Now() - authentication_start_time_; |
| 195 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; | 194 VLOG(1) << "Authentication success: " << delta.InSecondsF() << " second(s)"; |
| 196 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); | 195 UMA_HISTOGRAM_TIMES("ScreenLocker.AuthenticationSuccessTime", delta); |
| 197 } | 196 } |
| 198 | 197 |
| 199 Profile* profile = ProfileManager::GetDefaultProfile(); | 198 Profile* profile = ProfileManager::GetDefaultProfile(); |
| 200 if (profile && !password.empty()) { | 199 if (profile && !credentials.password.empty()) { |
| 201 // We have a non-empty password, so notify listeners (such as the sync | 200 // We have a non-empty password, so notify listeners (such as the sync |
| 202 // engine). | 201 // engine). |
| 203 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); | 202 SigninManager* signin = SigninManagerFactory::GetForProfile(profile); |
| 204 DCHECK(signin); | 203 DCHECK(signin); |
| 205 GoogleServiceSigninSuccessDetails details( | 204 GoogleServiceSigninSuccessDetails details( |
| 206 signin->GetAuthenticatedUsername(), | 205 signin->GetAuthenticatedUsername(), |
| 207 password); | 206 credentials.password); |
| 208 content::NotificationService::current()->Notify( | 207 content::NotificationService::current()->Notify( |
| 209 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, | 208 chrome::NOTIFICATION_GOOGLE_SIGNIN_SUCCESSFUL, |
| 210 content::Source<Profile>(profile), | 209 content::Source<Profile>(profile), |
| 211 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); | 210 content::Details<const GoogleServiceSigninSuccessDetails>(&details)); |
| 212 } | 211 } |
| 213 | 212 |
| 214 authentication_capture_.reset(new AuthenticationParametersCapture()); | 213 authentication_capture_.reset(new AuthenticationParametersCapture()); |
| 215 authentication_capture_->username = username; | 214 authentication_capture_->username = credentials.username; |
| 216 authentication_capture_->pending_requests = pending_requests; | 215 authentication_capture_->pending_requests = pending_requests; |
| 217 authentication_capture_->using_oauth = using_oauth; | 216 authentication_capture_->using_oauth = using_oauth; |
| 218 | 217 |
| 219 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 218 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 220 if (command_line->HasSwitch(ash::switches::kAshDisableNewLockAnimations)) { | 219 if (command_line->HasSwitch(ash::switches::kAshDisableNewLockAnimations)) { |
| 221 UnlockOnLoginSuccess(); | 220 UnlockOnLoginSuccess(); |
| 222 } else { | 221 } else { |
| 223 // Add guard for case when something get broken in call chain to unlock | 222 // Add guard for case when something get broken in call chain to unlock |
| 224 // for sure. | 223 // for sure. |
| 225 MessageLoop::current()->PostDelayedTask( | 224 MessageLoop::current()->PostDelayedTask( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 237 LOG(WARNING) << "Call to UnlockOnLoginSuccess without previous " << | 236 LOG(WARNING) << "Call to UnlockOnLoginSuccess without previous " << |
| 238 "authentication success."; | 237 "authentication success."; |
| 239 return; | 238 return; |
| 240 } | 239 } |
| 241 | 240 |
| 242 VLOG(1) << "Calling session manager's UnlockScreen D-Bus method"; | 241 VLOG(1) << "Calling session manager's UnlockScreen D-Bus method"; |
| 243 DBusThreadManager::Get()->GetSessionManagerClient()->RequestUnlockScreen(); | 242 DBusThreadManager::Get()->GetSessionManagerClient()->RequestUnlockScreen(); |
| 244 | 243 |
| 245 if (login_status_consumer_) { | 244 if (login_status_consumer_) { |
| 246 login_status_consumer_->OnLoginSuccess( | 245 login_status_consumer_->OnLoginSuccess( |
| 247 authentication_capture_->username, | 246 UserCredentials(authentication_capture_->username, |
| 248 std::string(), | 247 std::string(), // password |
| 248 std::string()), // auth_code |
| 249 authentication_capture_->pending_requests, | 249 authentication_capture_->pending_requests, |
| 250 authentication_capture_->using_oauth); | 250 authentication_capture_->using_oauth); |
| 251 } | 251 } |
| 252 authentication_capture_.reset(); | 252 authentication_capture_.reset(); |
| 253 weak_factory_.InvalidateWeakPtrs(); | 253 weak_factory_.InvalidateWeakPtrs(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 void ScreenLocker::Authenticate(const string16& password) { | 256 void ScreenLocker::Authenticate(const string16& password) { |
| 257 authentication_start_time_ = base::Time::Now(); | 257 authentication_start_time_ = base::Time::Now(); |
| 258 delegate_->SetInputEnabled(false); | 258 delegate_->SetInputEnabled(false); |
| 259 delegate_->OnAuthenticate(); | 259 delegate_->OnAuthenticate(); |
| 260 | 260 |
| 261 // If LoginPerformer instance exists, | 261 // If LoginPerformer instance exists, |
| 262 // initial online login phase is still active. | 262 // initial online login phase is still active. |
| 263 if (LoginPerformer::default_performer()) { | 263 if (LoginPerformer::default_performer()) { |
| 264 DVLOG(1) << "Delegating authentication to LoginPerformer."; | 264 DVLOG(1) << "Delegating authentication to LoginPerformer."; |
| 265 LoginPerformer::default_performer()->PerformLogin( | 265 LoginPerformer::default_performer()->PerformLogin( |
| 266 user_.email(), UTF16ToUTF8(password), | 266 UserCredentials(user_.email(), |
| 267 UTF16ToUTF8(password), |
| 268 std::string()), // auth_code |
| 267 LoginPerformer::AUTH_MODE_INTERNAL); | 269 LoginPerformer::AUTH_MODE_INTERNAL); |
| 268 } else { | 270 } else { |
| 269 BrowserThread::PostTask( | 271 BrowserThread::PostTask( |
| 270 BrowserThread::UI, FROM_HERE, | 272 BrowserThread::UI, FROM_HERE, |
| 271 base::Bind(&Authenticator::AuthenticateToUnlock, authenticator_.get(), | 273 base::Bind(&Authenticator::AuthenticateToUnlock, authenticator_.get(), |
| 272 user_.email(), UTF16ToUTF8(password))); | 274 UserCredentials(user_.email(), |
| 275 UTF16ToUTF8(password), |
| 276 std::string()))); // auth_code |
| 273 } | 277 } |
| 274 } | 278 } |
| 275 | 279 |
| 276 void ScreenLocker::ClearErrors() { | 280 void ScreenLocker::ClearErrors() { |
| 277 delegate_->ClearErrors(); | 281 delegate_->ClearErrors(); |
| 278 } | 282 } |
| 279 | 283 |
| 280 void ScreenLocker::EnableInput() { | 284 void ScreenLocker::EnableInput() { |
| 281 delegate_->SetInputEnabled(true); | 285 delegate_->SetInputEnabled(true); |
| 282 } | 286 } |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 content::Details<bool>(&state)); | 426 content::Details<bool>(&state)); |
| 423 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; | 427 VLOG(1) << "Calling session manager's HandleLockScreenShown D-Bus method"; |
| 424 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); | 428 DBusThreadManager::Get()->GetSessionManagerClient()->NotifyLockScreenShown(); |
| 425 } | 429 } |
| 426 | 430 |
| 427 content::WebUI* ScreenLocker::GetAssociatedWebUI() { | 431 content::WebUI* ScreenLocker::GetAssociatedWebUI() { |
| 428 return delegate_->GetAssociatedWebUI(); | 432 return delegate_->GetAssociatedWebUI(); |
| 429 } | 433 } |
| 430 | 434 |
| 431 } // namespace chromeos | 435 } // namespace chromeos |
| OLD | NEW |