Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(511)

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_token_forwarder.cc

Issue 137553007: User cloud policy token forwarder: Replace PO2TS::GetPrimaryAccountId() with SMB::GetAuthenticatedAc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "chrome/browser/signin/profile_oauth2_token_service.h" 9 #include "chrome/browser/signin/profile_oauth2_token_service.h"
10 #include "chrome/browser/signin/signin_manager.h"
10 #include "components/policy/core/common/cloud/cloud_policy_core.h" 11 #include "components/policy/core/common/cloud/cloud_policy_core.h"
11 #include "content/public/browser/notification_source.h" 12 #include "content/public/browser/notification_source.h"
12 #include "google_apis/gaia/gaia_constants.h" 13 #include "google_apis/gaia/gaia_constants.h"
13 #include "google_apis/gaia/gaia_urls.h" 14 #include "google_apis/gaia/gaia_urls.h"
14 15
15 namespace policy { 16 namespace policy {
16 17
17 UserCloudPolicyTokenForwarder::UserCloudPolicyTokenForwarder( 18 UserCloudPolicyTokenForwarder::UserCloudPolicyTokenForwarder(
18 UserCloudPolicyManagerChromeOS* manager, 19 UserCloudPolicyManagerChromeOS* manager,
19 ProfileOAuth2TokenService* token_service) 20 ProfileOAuth2TokenService* token_service,
21 SigninManagerBase* signin_manager)
20 : OAuth2TokenService::Consumer("policy_token_forwarder"), 22 : OAuth2TokenService::Consumer("policy_token_forwarder"),
21 manager_(manager), 23 manager_(manager),
22 token_service_(token_service) { 24 token_service_(token_service),
25 signin_manager_(signin_manager) {
23 // Start by waiting for the CloudPolicyService to be initialized, so that 26 // Start by waiting for the CloudPolicyService to be initialized, so that
24 // we can check if it already has a DMToken or not. 27 // we can check if it already has a DMToken or not.
25 if (manager_->core()->service()->IsInitializationComplete()) { 28 if (manager_->core()->service()->IsInitializationComplete()) {
26 Initialize(); 29 Initialize();
27 } else { 30 } else {
28 manager_->core()->service()->AddObserver(this); 31 manager_->core()->service()->AddObserver(this);
29 } 32 }
30 } 33 }
31 34
32 UserCloudPolicyTokenForwarder::~UserCloudPolicyTokenForwarder() {} 35 UserCloudPolicyTokenForwarder::~UserCloudPolicyTokenForwarder() {}
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 CloudPolicyService* service) { 75 CloudPolicyService* service) {
73 Initialize(); 76 Initialize();
74 } 77 }
75 78
76 void UserCloudPolicyTokenForwarder::Initialize() { 79 void UserCloudPolicyTokenForwarder::Initialize() {
77 // TODO(mnissler): Once a better way to reconfirm whether a user is on the 80 // TODO(mnissler): Once a better way to reconfirm whether a user is on the
78 // login whitelist is available, there is no reason to fetch the OAuth2 token 81 // login whitelist is available, there is no reason to fetch the OAuth2 token
79 // here if the client is already registered, so check and bail out here. 82 // here if the client is already registered, so check and bail out here.
80 83
81 if (token_service_->RefreshTokenIsAvailable( 84 if (token_service_->RefreshTokenIsAvailable(
82 token_service_->GetPrimaryAccountId())) 85 signin_manager_->GetAuthenticatedAccountId()))
83 RequestAccessToken(); 86 RequestAccessToken();
84 else 87 else
85 token_service_->AddObserver(this); 88 token_service_->AddObserver(this);
86 } 89 }
87 90
88 void UserCloudPolicyTokenForwarder::RequestAccessToken() { 91 void UserCloudPolicyTokenForwarder::RequestAccessToken() {
89 OAuth2TokenService::ScopeSet scopes; 92 OAuth2TokenService::ScopeSet scopes;
90 scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth); 93 scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth);
91 scopes.insert(GaiaUrls::GetInstance()->oauth_wrap_bridge_user_info_scope()); 94 scopes.insert(GaiaUrls::GetInstance()->oauth_wrap_bridge_user_info_scope());
92 request_ = token_service_->StartRequest( 95 request_ = token_service_->StartRequest(
93 token_service_->GetPrimaryAccountId(), scopes, this); 96 signin_manager_->GetAuthenticatedAccountId(), scopes, this);
94 } 97 }
95 98
96 } // namespace policy 99 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698