OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/policy/cloud/user_policy_signin_service.h" | 5 #include "chrome/browser/policy/cloud/user_policy_signin_service.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
105 void UserPolicySigninService::OnRefreshTokenAvailable( | 105 void UserPolicySigninService::OnRefreshTokenAvailable( |
106 const std::string& account_id) { | 106 const std::string& account_id) { |
107 // If using a TestingProfile with no UserCloudPolicyManager, skip | 107 // If using a TestingProfile with no UserCloudPolicyManager, skip |
108 // initialization. | 108 // initialization. |
109 if (!GetManager()) { | 109 if (!GetManager()) { |
110 DVLOG(1) << "Skipping initialization for tests due to missing components."; | 110 DVLOG(1) << "Skipping initialization for tests due to missing components."; |
111 return; | 111 return; |
112 } | 112 } |
113 | 113 |
114 std::string username = GetSigninManager()->GetAuthenticatedUsername(); | 114 std::string username = GetSigninManager()->GetAuthenticatedUsername(); |
115 // Should not have OAuth tokens if the user isn't signed in. | 115 |
116 DCHECK(!username.empty()); | 116 // Ignore OAuth tokens for any account but the primary one. |
Bernhard Bauer
2013/10/30 16:23:23
Drew: I changed this. We should here also ignore t
| |
117 if (username != account_id) | |
118 return; | |
119 | |
117 // ProfileOAuth2TokenService now has a refresh token so initialize the | 120 // ProfileOAuth2TokenService now has a refresh token so initialize the |
118 // UserCloudPolicyManager. | 121 // UserCloudPolicyManager. |
119 InitializeForSignedInUser(username); | 122 InitializeForSignedInUser(username); |
120 } | 123 } |
121 | 124 |
122 void UserPolicySigninService::InitializeUserCloudPolicyManager( | 125 void UserPolicySigninService::InitializeUserCloudPolicyManager( |
123 scoped_ptr<CloudPolicyClient> client) { | 126 scoped_ptr<CloudPolicyClient> client) { |
124 UserPolicySigninServiceBase::InitializeUserCloudPolicyManager(client.Pass()); | 127 UserPolicySigninServiceBase::InitializeUserCloudPolicyManager(client.Pass()); |
125 ProhibitSignoutIfNeeded(); | 128 ProhibitSignoutIfNeeded(); |
126 } | 129 } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
184 } | 187 } |
185 | 188 |
186 void UserPolicySigninService::ProhibitSignoutIfNeeded() { | 189 void UserPolicySigninService::ProhibitSignoutIfNeeded() { |
187 if (GetManager()->IsClientRegistered()) { | 190 if (GetManager()->IsClientRegistered()) { |
188 DVLOG(1) << "User is registered for policy - prohibiting signout"; | 191 DVLOG(1) << "User is registered for policy - prohibiting signout"; |
189 GetSigninManager()->ProhibitSignout(true); | 192 GetSigninManager()->ProhibitSignout(true); |
190 } | 193 } |
191 } | 194 } |
192 | 195 |
193 } // namespace policy | 196 } // namespace policy |
OLD | NEW |