| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/policy/user_cloud_policy_token_forwarder.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 8 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 9 #include "components/policy/core/common/cloud/cloud_policy_core.h" | 9 #include "components/policy/core/common/cloud/cloud_policy_core.h" |
| 10 #include "components/signin/core/browser/profile_oauth2_token_service.h" | 10 #include "components/signin/core/browser/profile_oauth2_token_service.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 manager_->OnAccessTokenAvailable(access_token); | 51 manager_->OnAccessTokenAvailable(access_token); |
| 52 // All done here. | 52 // All done here. |
| 53 Shutdown(); | 53 Shutdown(); |
| 54 } | 54 } |
| 55 | 55 |
| 56 void UserCloudPolicyTokenForwarder::OnGetTokenFailure( | 56 void UserCloudPolicyTokenForwarder::OnGetTokenFailure( |
| 57 const OAuth2TokenService::Request* request, | 57 const OAuth2TokenService::Request* request, |
| 58 const GoogleServiceAuthError& error) { | 58 const GoogleServiceAuthError& error) { |
| 59 // This should seldom happen: if the user is signing in for the first time | 59 // This should seldom happen: if the user is signing in for the first time |
| 60 // then this was an online signin and network errors are unlikely; if the | 60 // then this was an online signin and network errors are unlikely; if the |
| 61 // user had already signed in before then he should have policy cached, and | 61 // user had already signed in before then they should have policy cached, and |
| 62 // RequestAccessToken() wouldn't have been invoked. | 62 // RequestAccessToken() wouldn't have been invoked. |
| 63 // Still, something just went wrong (server 500, or something). Currently | 63 // Still, something just went wrong (server 500, or something). Currently |
| 64 // we don't recover in this case, and we'll just try to register for policy | 64 // we don't recover in this case, and we'll just try to register for policy |
| 65 // again on the next signin. | 65 // again on the next signin. |
| 66 // TODO(joaodasilva, atwilson): consider blocking signin when this happens, | 66 // TODO(joaodasilva, atwilson): consider blocking signin when this happens, |
| 67 // so that the user has to try again before getting into the session. That | 67 // so that the user has to try again before getting into the session. That |
| 68 // would guarantee that a session always has fresh policy, or at least | 68 // would guarantee that a session always has fresh policy, or at least |
| 69 // enforces a cached policy. | 69 // enforces a cached policy. |
| 70 Shutdown(); | 70 Shutdown(); |
| 71 } | 71 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 89 | 89 |
| 90 void UserCloudPolicyTokenForwarder::RequestAccessToken() { | 90 void UserCloudPolicyTokenForwarder::RequestAccessToken() { |
| 91 OAuth2TokenService::ScopeSet scopes; | 91 OAuth2TokenService::ScopeSet scopes; |
| 92 scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth); | 92 scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth); |
| 93 scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope); | 93 scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope); |
| 94 request_ = token_service_->StartRequest( | 94 request_ = token_service_->StartRequest( |
| 95 signin_manager_->GetAuthenticatedAccountId(), scopes, this); | 95 signin_manager_->GetAuthenticatedAccountId(), scopes, this); |
| 96 } | 96 } |
| 97 | 97 |
| 98 } // namespace policy | 98 } // namespace policy |
| OLD | NEW |