| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/signin/chrome_signin_client.h" | 5 #include "chrome/browser/signin/chrome_signin_client.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 266 // Don't store password hash except when lock is available for the user. | 266 // Don't store password hash except when lock is available for the user. |
| 267 if (!password.empty() && profiles::IsLockAvailable(profile_)) | 267 if (!password.empty() && profiles::IsLockAvailable(profile_)) |
| 268 LocalAuth::SetLocalAuthCredentials(profile_, password); | 268 LocalAuth::SetLocalAuthCredentials(profile_, password); |
| 269 #endif | 269 #endif |
| 270 } | 270 } |
| 271 | 271 |
| 272 void ChromeSigninClient::PreSignOut( | 272 void ChromeSigninClient::PreSignOut( |
| 273 const base::Callback<void()>& sign_out, | 273 const base::Callback<void()>& sign_out, |
| 274 signin_metrics::ProfileSignout signout_source_metric) { | 274 signin_metrics::ProfileSignout signout_source_metric) { |
| 275 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 275 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 276 |
| 277 // These sign out won't remove the policy cache, keep the window opened. |
| 278 bool keep_window_opened = |
| 279 signout_source_metric == |
| 280 signin_metrics::GOOGLE_SERVICE_NAME_PATTERN_CHANGED || |
| 281 signout_source_metric == signin_metrics::SERVER_FORCED_DISABLE || |
| 282 signout_source_metric == signin_metrics::SIGNOUT_PREF_CHANGED; |
| 276 if (signin_util::IsForceSigninEnabled() && !profile_->IsSystemProfile() && | 283 if (signin_util::IsForceSigninEnabled() && !profile_->IsSystemProfile() && |
| 277 !profile_->IsGuestSession() && !profile_->IsSupervised()) { | 284 !profile_->IsGuestSession() && !profile_->IsSupervised() && |
| 278 // TODO(zmin): force window closing based on the reason of sign-out. | 285 !keep_window_opened) { |
| 279 // This will be updated after force window closing CL is commited. | 286 if (signout_source_metric == |
| 280 | 287 signin_metrics::SIGNIN_PREF_CHANGED_DURING_SIGNIN) { |
| 281 // User can't abort the window closing unless user sign out manually. | 288 // SIGNIN_PREF_CHANGED_DURING_SIGNIN will be triggered when SigninManager |
| 282 BrowserList::CloseAllBrowsersWithProfile( | 289 // is initialized before window opening, there is no need to close window. |
| 283 profile_, | 290 // Call OnCloseBrowsersSuccess to continue sign out and show UserManager |
| 284 base::Bind(&ChromeSigninClient::OnCloseBrowsersSuccess, | 291 // afterwards. |
| 285 base::Unretained(this), sign_out, signout_source_metric), | 292 should_display_user_manager_ = false; // Don't show UserManager twice. |
| 286 base::Bind(&ChromeSigninClient::OnCloseBrowsersAborted, | 293 OnCloseBrowsersSuccess(sign_out, signout_source_metric, |
| 287 base::Unretained(this)), | 294 profile_->GetPath()); |
| 288 false); | 295 } else { |
| 296 BrowserList::CloseAllBrowsersWithProfile( |
| 297 profile_, |
| 298 base::Bind(&ChromeSigninClient::OnCloseBrowsersSuccess, |
| 299 base::Unretained(this), sign_out, signout_source_metric), |
| 300 base::Bind(&ChromeSigninClient::OnCloseBrowsersAborted, |
| 301 base::Unretained(this)), |
| 302 signout_source_metric == signin_metrics::ABORT_SIGNIN || |
| 303 signout_source_metric == |
| 304 signin_metrics::AUTHENTICATION_FAILED_WITH_FORCE_SIGNIN || |
| 305 signout_source_metric == signin_metrics::TRANSFER_CREDENTIALS); |
| 306 } |
| 289 } else { | 307 } else { |
| 290 #else | 308 #else |
| 291 { | 309 { |
| 292 #endif | 310 #endif |
| 293 SigninClient::PreSignOut(sign_out, signout_source_metric); | 311 SigninClient::PreSignOut(sign_out, signout_source_metric); |
| 294 } | 312 } |
| 295 } | 313 } |
| 296 | 314 |
| 297 void ChromeSigninClient::OnErrorChanged() { | 315 void ChromeSigninClient::OnErrorChanged() { |
| 298 // Some tests don't have a ProfileManager. | 316 // Some tests don't have a ProfileManager. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 // the new profile soon. | 452 // the new profile soon. |
| 435 should_display_user_manager_ = false; | 453 should_display_user_manager_ = false; |
| 436 } | 454 } |
| 437 } | 455 } |
| 438 | 456 |
| 439 void ChromeSigninClient::OnCloseBrowsersSuccess( | 457 void ChromeSigninClient::OnCloseBrowsersSuccess( |
| 440 const base::Callback<void()>& sign_out, | 458 const base::Callback<void()>& sign_out, |
| 441 const signin_metrics::ProfileSignout signout_source_metric, | 459 const signin_metrics::ProfileSignout signout_source_metric, |
| 442 const base::FilePath& profile_path) { | 460 const base::FilePath& profile_path) { |
| 443 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 461 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 444 if (signin_util::IsForceSigninEnabled() && force_signin_verifier_.get()) | 462 if (signin_util::IsForceSigninEnabled() && force_signin_verifier_.get()) { |
| 445 force_signin_verifier_->Cancel(); | 463 force_signin_verifier_->Cancel(); |
| 464 force_signin_verifier_->AbortSignoutCountdownIfExisted(); |
| 465 } |
| 446 #endif | 466 #endif |
| 447 SigninClient::PreSignOut(sign_out, signout_source_metric); | 467 SigninClient::PreSignOut(sign_out, signout_source_metric); |
| 448 | 468 |
| 449 LockForceSigninProfile(profile_path); | 469 LockForceSigninProfile(profile_path); |
| 450 // After sign out, lock the profile and show UserManager if necessary. | 470 // After sign out, lock the profile and show UserManager if necessary. |
| 451 if (should_display_user_manager_) { | 471 if (should_display_user_manager_) { |
| 452 ShowUserManager(profile_path); | 472 ShowUserManager(profile_path); |
| 453 } else { | 473 } else { |
| 454 should_display_user_manager_ = true; | 474 should_display_user_manager_ = true; |
| 455 } | 475 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 471 return; | 491 return; |
| 472 entry->LockForceSigninProfile(true); | 492 entry->LockForceSigninProfile(true); |
| 473 } | 493 } |
| 474 | 494 |
| 475 void ChromeSigninClient::ShowUserManager(const base::FilePath& profile_path) { | 495 void ChromeSigninClient::ShowUserManager(const base::FilePath& profile_path) { |
| 476 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 496 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 477 UserManager::Show(profile_path, | 497 UserManager::Show(profile_path, |
| 478 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 498 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 479 #endif | 499 #endif |
| 480 } | 500 } |
| OLD | NEW |