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

Side by Side Diff: chrome/browser/policy/user_policy_identity_strategy.cc

Issue 6537020: Update policy backend and testserver for the newest policy protocol (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more last minute changes Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/user_policy_identity_strategy.h" 5 #include "chrome/browser/policy/user_policy_identity_strategy.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "chrome/browser/browser_signin.h" 8 #include "chrome/browser/browser_signin.h"
9 #include "chrome/browser/browser_thread.h" 9 #include "chrome/browser/browser_thread.h"
10 #include "chrome/browser/net/gaia/token_service.h" 10 #include "chrome/browser/net/gaia/token_service.h"
11 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
12 #include "chrome/browser/policy/proto/device_management_constants.h"
11 #include "chrome/browser/policy/proto/device_management_local.pb.h" 13 #include "chrome/browser/policy/proto/device_management_local.pb.h"
12 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/guid.h" 15 #include "chrome/common/guid.h"
14 #include "chrome/common/net/gaia/gaia_constants.h" 16 #include "chrome/common/net/gaia/gaia_constants.h"
15 #include "chrome/common/notification_details.h" 17 #include "chrome/common/notification_details.h"
16 #include "chrome/common/notification_service.h" 18 #include "chrome/common/notification_service.h"
17 #include "chrome/common/notification_source.h" 19 #include "chrome/common/notification_source.h"
18 20
19 #if defined(OS_CHROMEOS) 21 #if defined(OS_CHROMEOS)
20 #include "chrome/browser/chromeos/login/user_manager.h" 22 #include "chrome/browser/chromeos/login/user_manager.h"
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 UserPolicyIdentityStrategy::~UserPolicyIdentityStrategy() {} 158 UserPolicyIdentityStrategy::~UserPolicyIdentityStrategy() {}
157 159
158 std::string UserPolicyIdentityStrategy::GetDeviceToken() { 160 std::string UserPolicyIdentityStrategy::GetDeviceToken() {
159 return device_token_; 161 return device_token_;
160 } 162 }
161 163
162 std::string UserPolicyIdentityStrategy::GetDeviceID() { 164 std::string UserPolicyIdentityStrategy::GetDeviceID() {
163 return device_id_; 165 return device_id_;
164 } 166 }
165 167
168 std::string UserPolicyIdentityStrategy::GetMachineID() {
169 return "";
170 }
171
172 em::DeviceRegisterRequest_Type
173 UserPolicyIdentityStrategy::GetPolicyRegisterType() {
174 return em::DeviceRegisterRequest::USER;
175 }
176
177 std::string UserPolicyIdentityStrategy::GetPolicyType() {
178 return kChromeUserPolicyType;
179 }
180
181
166 bool UserPolicyIdentityStrategy::GetCredentials(std::string* username, 182 bool UserPolicyIdentityStrategy::GetCredentials(std::string* username,
167 std::string* auth_token) { 183 std::string* auth_token) {
168 *username = GetCurrentUser(); 184 *username = GetCurrentUser();
169 *auth_token = profile_->GetTokenService()->GetTokenForService( 185 *auth_token = profile_->GetTokenService()->GetTokenForService(
170 GaiaConstants::kDeviceManagementService); 186 GaiaConstants::kDeviceManagementService);
171 187
172 return !username->empty() && !auth_token->empty() && !device_id_.empty(); 188 return !username->empty() && !auth_token->empty() && !device_id_.empty();
173 } 189 }
174 190
175 void UserPolicyIdentityStrategy::OnDeviceTokenAvailable( 191 void UserPolicyIdentityStrategy::OnDeviceTokenAvailable(
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 230
215 void UserPolicyIdentityStrategy::Observe(NotificationType type, 231 void UserPolicyIdentityStrategy::Observe(NotificationType type,
216 const NotificationSource& source, 232 const NotificationSource& source,
217 const NotificationDetails& details) { 233 const NotificationDetails& details) {
218 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 234 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
219 if (type == NotificationType::TOKEN_AVAILABLE) { 235 if (type == NotificationType::TOKEN_AVAILABLE) {
220 if (Source<TokenService>(source).ptr() == profile_->GetTokenService()) { 236 if (Source<TokenService>(source).ptr() == profile_->GetTokenService()) {
221 const TokenService::TokenAvailableDetails* token_details = 237 const TokenService::TokenAvailableDetails* token_details =
222 Details<const TokenService::TokenAvailableDetails>(details).ptr(); 238 Details<const TokenService::TokenAvailableDetails>(details).ptr();
223 if (token_details->service() == GaiaConstants::kDeviceManagementService) 239 if (token_details->service() == GaiaConstants::kDeviceManagementService)
224 CheckAndTriggerFetch(); 240 if (device_token_.empty()) {
241 // Request a new device management server token, but only in case we
242 // don't already have it.
243 CheckAndTriggerFetch();
244 }
225 } 245 }
226 #if defined(OS_CHROMEOS) 246 #if defined(OS_CHROMEOS)
227 } else if (type == NotificationType::LOGIN_USER_CHANGED) { 247 } else if (type == NotificationType::LOGIN_USER_CHANGED) {
228 CheckAndTriggerFetch(); 248 CheckAndTriggerFetch();
229 #else 249 #else
230 } else if (type == NotificationType::GOOGLE_SIGNIN_SUCCESSFUL) { 250 } else if (type == NotificationType::GOOGLE_SIGNIN_SUCCESSFUL) {
231 if (profile_ == Source<Profile>(source).ptr()) 251 if (profile_ == Source<Profile>(source).ptr())
232 CheckAndTriggerFetch(); 252 CheckAndTriggerFetch();
233 #endif 253 #endif
234 } else { 254 } else {
235 NOTREACHED(); 255 NOTREACHED();
236 } 256 }
237 } 257 }
238 258
239 } // namespace policy 259 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/user_policy_identity_strategy.h ('k') | chrome/test/data/policy/device_management » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698