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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <set> | 9 #include <set> |
10 #include <string> | 10 #include <string> |
(...skipping 1526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1537 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager(); | 1537 EasyUnlockKeyManager* key_manager = GetEasyUnlockKeyManager(); |
1538 running_easy_unlock_key_ops_ = true; | 1538 running_easy_unlock_key_ops_ = true; |
1539 key_manager->RefreshKeys( | 1539 key_manager->RefreshKeys( |
1540 user_context, *device_list, | 1540 user_context, *device_list, |
1541 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(), | 1541 base::Bind(&UserSessionManager::OnEasyUnlockKeyOpsFinished, AsWeakPtr(), |
1542 user_context.GetAccountId().GetUserEmail())); | 1542 user_context.GetAccountId().GetUserEmail())); |
1543 } | 1543 } |
1544 | 1544 |
1545 net::URLRequestContextGetter* | 1545 net::URLRequestContextGetter* |
1546 UserSessionManager::GetAuthRequestContext() const { | 1546 UserSessionManager::GetAuthRequestContext() const { |
1547 net::URLRequestContextGetter* auth_request_context = nullptr; | 1547 content::StoragePartition* signin_partition = login::GetSigninPartition(); |
| 1548 if (!signin_partition) |
| 1549 return nullptr; |
1548 | 1550 |
1549 if (StartupUtils::IsWebviewSigninEnabled()) { | 1551 return signin_partition->GetURLRequestContext(); |
1550 // Webview uses different partition storage than iframe. We need to get | |
1551 // cookies from the right storage for url request to get auth token into | |
1552 // session. | |
1553 content::StoragePartition* signin_partition = login::GetSigninPartition(); | |
1554 if (signin_partition) | |
1555 auth_request_context = signin_partition->GetURLRequestContext(); | |
1556 } else if (authenticator_.get() && authenticator_->authentication_context()) { | |
1557 auth_request_context = | |
1558 content::BrowserContext::GetDefaultStoragePartition( | |
1559 authenticator_->authentication_context())->GetURLRequestContext(); | |
1560 } | |
1561 return auth_request_context; | |
1562 } | 1552 } |
1563 | 1553 |
1564 void UserSessionManager::AttemptRestart(Profile* profile) { | 1554 void UserSessionManager::AttemptRestart(Profile* profile) { |
1565 // Restart unconditionally in case if we are stuck somewhere in a session | 1555 // Restart unconditionally in case if we are stuck somewhere in a session |
1566 // restore process. http://crbug.com/520346. | 1556 // restore process. http://crbug.com/520346. |
1567 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 1557 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
1568 FROM_HERE, base::Bind(RestartOnTimeout), | 1558 FROM_HERE, base::Bind(RestartOnTimeout), |
1569 base::TimeDelta::FromSeconds(kMaxRestartDelaySeconds)); | 1559 base::TimeDelta::FromSeconds(kMaxRestartDelaySeconds)); |
1570 | 1560 |
1571 if (CheckEasyUnlockKeyOps(base::Bind(&UserSessionManager::AttemptRestart, | 1561 if (CheckEasyUnlockKeyOps(base::Bind(&UserSessionManager::AttemptRestart, |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1784 if (is_enterprise_managed) | 1774 if (is_enterprise_managed) |
1785 display = USER_PODS_DISPLAY_DISABLED_MANAGED; | 1775 display = USER_PODS_DISPLAY_DISABLED_MANAGED; |
1786 else | 1776 else |
1787 display = USER_PODS_DISPLAY_DISABLED_REGULAR; | 1777 display = USER_PODS_DISPLAY_DISABLED_REGULAR; |
1788 } | 1778 } |
1789 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, | 1779 UMA_HISTOGRAM_ENUMERATION("UserSessionManager.UserPodsDisplay", display, |
1790 NUM_USER_PODS_DISPLAY); | 1780 NUM_USER_PODS_DISPLAY); |
1791 } | 1781 } |
1792 | 1782 |
1793 void UserSessionManager::OnOAuth2TokensFetched(UserContext context) { | 1783 void UserSessionManager::OnOAuth2TokensFetched(UserContext context) { |
1794 if (StartupUtils::IsWebviewSigninEnabled() && TokenHandlesEnabled()) { | 1784 if (!TokenHandlesEnabled()) |
1795 CreateTokenUtilIfMissing(); | 1785 return; |
1796 if (!token_handle_util_->HasToken(context.GetAccountId())) { | 1786 |
1797 token_handle_fetcher_.reset(new TokenHandleFetcher( | 1787 CreateTokenUtilIfMissing(); |
1798 token_handle_util_.get(), context.GetAccountId())); | 1788 if (!token_handle_util_->HasToken(context.GetAccountId())) { |
1799 token_handle_fetcher_->FillForNewUser( | 1789 token_handle_fetcher_.reset(new TokenHandleFetcher(token_handle_util_.get(), |
1800 context.GetAccessToken(), | 1790 context.GetAccountId())); |
1801 base::Bind(&UserSessionManager::OnTokenHandleObtained, | 1791 token_handle_fetcher_->FillForNewUser( |
1802 weak_factory_.GetWeakPtr())); | 1792 context.GetAccessToken(), |
1803 } | 1793 base::Bind(&UserSessionManager::OnTokenHandleObtained, |
| 1794 weak_factory_.GetWeakPtr())); |
1804 } | 1795 } |
1805 } | 1796 } |
1806 | 1797 |
1807 void UserSessionManager::OnTokenHandleObtained(const AccountId& account_id, | 1798 void UserSessionManager::OnTokenHandleObtained(const AccountId& account_id, |
1808 bool success) { | 1799 bool success) { |
1809 if (!success) | 1800 if (!success) |
1810 LOG(ERROR) << "OAuth2 token handle fetch failed."; | 1801 LOG(ERROR) << "OAuth2 token handle fetch failed."; |
1811 token_handle_fetcher_.reset(); | 1802 token_handle_fetcher_.reset(); |
1812 } | 1803 } |
1813 | 1804 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1847 ->browser_policy_connector_chromeos() | 1838 ->browser_policy_connector_chromeos() |
1848 ->IsEnterpriseManaged()) { | 1839 ->IsEnterpriseManaged()) { |
1849 return false; | 1840 return false; |
1850 } | 1841 } |
1851 | 1842 |
1852 // Do not show end of life notification if this is a guest session | 1843 // Do not show end of life notification if this is a guest session |
1853 return !profile->IsGuestSession(); | 1844 return !profile->IsGuestSession(); |
1854 } | 1845 } |
1855 | 1846 |
1856 } // namespace chromeos | 1847 } // namespace chromeos |
OLD | NEW |