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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
73 void UserCloudPolicyTokenForwarder::OnInitializationCompleted( | 73 void UserCloudPolicyTokenForwarder::OnInitializationCompleted( |
74 CloudPolicyService* service) { | 74 CloudPolicyService* service) { |
75 Initialize(); | 75 Initialize(); |
76 } | 76 } |
77 | 77 |
78 void UserCloudPolicyTokenForwarder::Initialize() { | 78 void UserCloudPolicyTokenForwarder::Initialize() { |
79 // TODO(mnissler): Once a better way to reconfirm whether a user is on the | 79 // TODO(mnissler): Once a better way to reconfirm whether a user is on the |
80 // login whitelist is available, there is no reason to fetch the OAuth2 token | 80 // login whitelist is available, there is no reason to fetch the OAuth2 token |
81 // here if the client is already registered, so check and bail out here. | 81 // here if the client is already registered, so check and bail out here. |
82 | 82 |
83 if (token_service_->RefreshTokenIsAvailable( | 83 if (signin_manager_->IsAuthenticated() && |
Joao da Silva
2014/10/08 13:19:17
This is ChromeOS code, so AFAICT this is always tr
| |
84 token_service_->RefreshTokenIsAvailable( | |
84 signin_manager_->GetAuthenticatedAccountId())) | 85 signin_manager_->GetAuthenticatedAccountId())) |
85 RequestAccessToken(); | 86 RequestAccessToken(); |
86 else | 87 else |
87 token_service_->AddObserver(this); | 88 token_service_->AddObserver(this); |
88 } | 89 } |
89 | 90 |
90 void UserCloudPolicyTokenForwarder::RequestAccessToken() { | 91 void UserCloudPolicyTokenForwarder::RequestAccessToken() { |
91 OAuth2TokenService::ScopeSet scopes; | 92 OAuth2TokenService::ScopeSet scopes; |
92 scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth); | 93 scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth); |
93 scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope); | 94 scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope); |
94 request_ = token_service_->StartRequest( | 95 request_ = token_service_->StartRequest( |
95 signin_manager_->GetAuthenticatedAccountId(), scopes, this); | 96 signin_manager_->GetAuthenticatedAccountId(), scopes, this); |
96 } | 97 } |
97 | 98 |
98 } // namespace policy | 99 } // namespace policy |
OLD | NEW |