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

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: 5 Created 9 years, 10 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/chromeos/login/user_manager.h" 10 #include "chrome/browser/chromeos/login/user_manager.h"
11 #include "chrome/browser/net/gaia/token_service.h" 11 #include "chrome/browser/net/gaia/token_service.h"
12 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
13 #include "chrome/browser/policy/proto/device_management_constants.h"
12 #include "chrome/browser/policy/proto/device_management_local.pb.h" 14 #include "chrome/browser/policy/proto/device_management_local.pb.h"
13 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/guid.h" 16 #include "chrome/common/guid.h"
15 #include "chrome/common/net/gaia/gaia_constants.h" 17 #include "chrome/common/net/gaia/gaia_constants.h"
16 #include "chrome/common/notification_details.h" 18 #include "chrome/common/notification_details.h"
17 #include "chrome/common/notification_service.h" 19 #include "chrome/common/notification_service.h"
18 #include "chrome/common/notification_source.h" 20 #include "chrome/common/notification_source.h"
19 21
20 namespace policy { 22 namespace policy {
21 23
(...skipping 11 matching lines...) Expand all
33 void Store(const std::string& token, const std::string& device_id); 35 void Store(const std::string& token, const std::string& device_id);
34 36
35 private: 37 private:
36 void LoadOnFileThread(); 38 void LoadOnFileThread();
37 void NotifyOnUIThread(const std::string& token, 39 void NotifyOnUIThread(const std::string& token,
38 const std::string& device_id); 40 const std::string& device_id);
39 void StoreOnFileThread(const std::string& token, 41 void StoreOnFileThread(const std::string& token,
40 const std::string& device_id); 42 const std::string& device_id);
41 43
42 const base::WeakPtr<UserPolicyIdentityStrategy> identity_strategy_; 44 const base::WeakPtr<UserPolicyIdentityStrategy> identity_strategy_;
43 const FilePath& cache_file_; 45 const FilePath cache_file_;
44 46
45 DISALLOW_COPY_AND_ASSIGN(TokenCache); 47 DISALLOW_COPY_AND_ASSIGN(TokenCache);
46 }; 48 };
47 49
48 UserPolicyIdentityStrategy::TokenCache::TokenCache( 50 UserPolicyIdentityStrategy::TokenCache::TokenCache(
49 const base::WeakPtr<UserPolicyIdentityStrategy>& identity_strategy, 51 const base::WeakPtr<UserPolicyIdentityStrategy>& identity_strategy,
50 const FilePath& cache_file) 52 const FilePath& cache_file)
51 : identity_strategy_(identity_strategy), 53 : identity_strategy_(identity_strategy),
52 cache_file_(cache_file) {} 54 cache_file_(cache_file) {
55 }
53 56
54 void UserPolicyIdentityStrategy::TokenCache::Load() { 57 void UserPolicyIdentityStrategy::TokenCache::Load() {
55 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 58 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
56 BrowserThread::PostTask( 59 BrowserThread::PostTask(
57 BrowserThread::FILE, FROM_HERE, 60 BrowserThread::FILE, FROM_HERE,
58 NewRunnableMethod( 61 NewRunnableMethod(
59 this, &UserPolicyIdentityStrategy::TokenCache::LoadOnFileThread)); 62 this, &UserPolicyIdentityStrategy::TokenCache::LoadOnFileThread));
60 } 63 }
61 64
62 void UserPolicyIdentityStrategy::TokenCache::Store( 65 void UserPolicyIdentityStrategy::TokenCache::Store(
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 UserPolicyIdentityStrategy::~UserPolicyIdentityStrategy() {} 153 UserPolicyIdentityStrategy::~UserPolicyIdentityStrategy() {}
151 154
152 std::string UserPolicyIdentityStrategy::GetDeviceToken() { 155 std::string UserPolicyIdentityStrategy::GetDeviceToken() {
153 return device_token_; 156 return device_token_;
154 } 157 }
155 158
156 std::string UserPolicyIdentityStrategy::GetDeviceID() { 159 std::string UserPolicyIdentityStrategy::GetDeviceID() {
157 return device_id_; 160 return device_id_;
158 } 161 }
159 162
163 std::string UserPolicyIdentityStrategy::GetMachineID() {
164 return device_id_;
165 }
166
167 em::DeviceRegisterRequest_Type
168 UserPolicyIdentityStrategy::GetPolicyRegisterType() {
169 return em::DeviceRegisterRequest::USER;
170 }
171
172 std::string UserPolicyIdentityStrategy::GetPolicyType() {
173 return kChromeUserPolicyType;
174 }
175
176
160 bool UserPolicyIdentityStrategy::GetCredentials(std::string* username, 177 bool UserPolicyIdentityStrategy::GetCredentials(std::string* username,
161 std::string* auth_token) { 178 std::string* auth_token) {
162 *username = GetCurrentUser(); 179 *username = GetCurrentUser();
163 *auth_token = profile_->GetTokenService()->GetTokenForService( 180 *auth_token = profile_->GetTokenService()->GetTokenForService(
164 GaiaConstants::kDeviceManagementService); 181 GaiaConstants::kDeviceManagementService);
165 182
166 return !username->empty() && !auth_token->empty() && !device_id_.empty(); 183 return !username->empty() && !auth_token->empty() && !device_id_.empty();
167 } 184 }
168 185
169 void UserPolicyIdentityStrategy::OnDeviceTokenAvailable( 186 void UserPolicyIdentityStrategy::OnDeviceTokenAvailable(
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 } else if (type == NotificationType::GOOGLE_SIGNIN_SUCCESSFUL) { 241 } else if (type == NotificationType::GOOGLE_SIGNIN_SUCCESSFUL) {
225 if (profile_ == Source<Profile>(source).ptr()) 242 if (profile_ == Source<Profile>(source).ptr())
226 CheckAndTriggerFetch(); 243 CheckAndTriggerFetch();
227 #endif 244 #endif
228 } else { 245 } else {
229 NOTREACHED(); 246 NOTREACHED();
230 } 247 }
231 } 248 }
232 249
233 } // namespace policy 250 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698