| 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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 471 return; | 489 return; |
| 472 entry->LockForceSigninProfile(true); | 490 entry->LockForceSigninProfile(true); |
| 473 } | 491 } |
| 474 | 492 |
| 475 void ChromeSigninClient::ShowUserManager(const base::FilePath& profile_path) { | 493 void ChromeSigninClient::ShowUserManager(const base::FilePath& profile_path) { |
| 476 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) | 494 #if !defined(OS_ANDROID) && !defined(OS_CHROMEOS) |
| 477 UserManager::Show(profile_path, | 495 UserManager::Show(profile_path, |
| 478 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 496 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 479 #endif | 497 #endif |
| 480 } | 498 } |
| OLD | NEW |