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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // Should not have OAuth tokens if the user isn't signed in. |
116 DCHECK(!username.empty()); | 116 DCHECK(!username.empty()); |
117 // ProfileOAuth2TokenService now has a refresh token so initialize the | 117 // ProfileOAuth2TokenService now has a refresh token so initialize the |
118 // UserCloudPolicyManager. | 118 // UserCloudPolicyManager. |
119 InitializeForSignedInUser(username); | 119 InitializeForSignedInUser(username); |
120 } | 120 } |
121 | 121 |
122 void UserPolicySigninService::InitializeUserCloudPolicyManager( | 122 void UserPolicySigninService::InitializeUserCloudPolicyManager( |
| 123 const std::string& username, |
123 scoped_ptr<CloudPolicyClient> client) { | 124 scoped_ptr<CloudPolicyClient> client) { |
124 UserPolicySigninServiceBase::InitializeUserCloudPolicyManager(client.Pass()); | 125 UserPolicySigninServiceBase::InitializeUserCloudPolicyManager(username, |
| 126 client.Pass()); |
125 ProhibitSignoutIfNeeded(); | 127 ProhibitSignoutIfNeeded(); |
126 } | 128 } |
127 | 129 |
128 void UserPolicySigninService::ShutdownUserCloudPolicyManager() { | 130 void UserPolicySigninService::ShutdownUserCloudPolicyManager() { |
129 UserCloudPolicyManager* manager = GetManager(); | 131 UserCloudPolicyManager* manager = GetManager(); |
130 // Allow the user to signout again. | 132 // Allow the user to signout again. |
131 if (manager) | 133 if (manager) |
132 GetSigninManager()->ProhibitSignout(false); | 134 GetSigninManager()->ProhibitSignout(false); |
133 UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager(); | 135 UserPolicySigninServiceBase::ShutdownUserCloudPolicyManager(); |
134 } | 136 } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 } | 186 } |
185 | 187 |
186 void UserPolicySigninService::ProhibitSignoutIfNeeded() { | 188 void UserPolicySigninService::ProhibitSignoutIfNeeded() { |
187 if (GetManager()->IsClientRegistered()) { | 189 if (GetManager()->IsClientRegistered()) { |
188 DVLOG(1) << "User is registered for policy - prohibiting signout"; | 190 DVLOG(1) << "User is registered for policy - prohibiting signout"; |
189 GetSigninManager()->ProhibitSignout(true); | 191 GetSigninManager()->ProhibitSignout(true); |
190 } | 192 } |
191 } | 193 } |
192 | 194 |
193 } // namespace policy | 195 } // namespace policy |
OLD | NEW |