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/chromeos/login/session/user_session_manager.h" | 5 #include "chrome/browser/chromeos/login/session/user_session_manager.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 1654 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1665 } else { | 1665 } else { |
1666 if (is_enterprise_managed) | 1666 if (is_enterprise_managed) |
1667 display = USER_PODS_DISPLAY_DISABLED_MANAGED; | 1667 display = USER_PODS_DISPLAY_DISABLED_MANAGED; |
1668 else | 1668 else |
1669 display = USER_PODS_DISPLAY_DISABLED_REGULAR; | 1669 display = USER_PODS_DISPLAY_DISABLED_REGULAR; |
1670 } | 1670 } |
1671 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, | 1671 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, |
1672 NUM_USER_PODS_DISPLAY); | 1672 NUM_USER_PODS_DISPLAY); |
1673 } | 1673 } |
1674 | 1674 |
| 1675 void UserSessionManager::OnOAuth2TokensFetched(UserContext context) { |
| 1676 if (StartupUtils::IsWebviewSigninEnabled() && TokenHandlesEnabled()) { |
| 1677 if (!token_handle_util_.get()) { |
| 1678 token_handle_util_.reset( |
| 1679 new TokenHandleUtil(user_manager::UserManager::Get())); |
| 1680 } |
| 1681 if (token_handle_util_->ShouldObtainHandle(context.GetUserID())) { |
| 1682 token_handle_util_->GetTokenHandle( |
| 1683 context.GetUserID(), context.GetAccessToken(), |
| 1684 base::Bind(&UserSessionManager::OnTokenHandleObtained, |
| 1685 weak_factory_.GetWeakPtr())); |
| 1686 } |
| 1687 } |
| 1688 } |
| 1689 |
| 1690 void UserSessionManager::OnTokenHandleObtained( |
| 1691 const user_manager::UserID& id, |
| 1692 TokenHandleUtil::TokenHandleStatus status) { |
| 1693 if (status != TokenHandleUtil::VALID) { |
| 1694 LOG(ERROR) << "OAuth2 token handle fetch failed."; |
| 1695 return; |
| 1696 } |
| 1697 } |
| 1698 |
| 1699 bool UserSessionManager::TokenHandlesEnabled() { |
| 1700 bool ephemeral_users_enabled = false; |
| 1701 bool show_names_on_signin = true; |
| 1702 auto cros_settings = CrosSettings::Get(); |
| 1703 cros_settings->GetBoolean(kAccountsPrefEphemeralUsersEnabled, |
| 1704 &ephemeral_users_enabled); |
| 1705 cros_settings->GetBoolean(kAccountsPrefShowUserNamesOnSignIn, |
| 1706 &show_names_on_signin); |
| 1707 return show_names_on_signin && !ephemeral_users_enabled; |
| 1708 } |
| 1709 |
| 1710 void UserSessionManager::Shutdown() { |
| 1711 token_handle_util_.reset(); |
| 1712 } |
| 1713 |
1675 } // namespace chromeos | 1714 } // namespace chromeos |
OLD | NEW |