| OLD | NEW |
| 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/cloud_policy_controller.h" | 5 #include "chrome/browser/policy/cloud_policy_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/rand_util.h" | 10 #include "base/rand_util.h" |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 205 if (identity_strategy_->GetCredentials(&username, &auth_token) && | 205 if (identity_strategy_->GetCredentials(&username, &auth_token) && |
| 206 CanBeInManagedDomain(username)) { | 206 CanBeInManagedDomain(username)) { |
| 207 token_fetcher_->FetchToken(auth_token, device_id, policy_type, machine_id); | 207 token_fetcher_->FetchToken(auth_token, device_id, policy_type, machine_id); |
| 208 } | 208 } |
| 209 } | 209 } |
| 210 | 210 |
| 211 void CloudPolicyController::SendPolicyRequest() { | 211 void CloudPolicyController::SendPolicyRequest() { |
| 212 DCHECK(!identity_strategy_->GetDeviceToken().empty()); | 212 DCHECK(!identity_strategy_->GetDeviceToken().empty()); |
| 213 em::DevicePolicyRequest policy_request; | 213 em::DevicePolicyRequest policy_request; |
| 214 em::PolicyFetchRequest* fetch_request = policy_request.add_request(); | 214 em::PolicyFetchRequest* fetch_request = policy_request.add_request(); |
| 215 fetch_request->set_signature_type(em::PolicyFetchRequest::X509); | 215 fetch_request->set_signature_type(em::PolicyFetchRequest::SHA1_RSA); |
| 216 fetch_request->set_policy_type(identity_strategy_->GetPolicyType()); | 216 fetch_request->set_policy_type(identity_strategy_->GetPolicyType()); |
| 217 if (!cache_->is_unmanaged() && | 217 if (!cache_->is_unmanaged() && |
| 218 !cache_->last_policy_refresh_time().is_null()) { | 218 !cache_->last_policy_refresh_time().is_null()) { |
| 219 base::TimeDelta timestamp = | 219 base::TimeDelta timestamp = |
| 220 cache_->last_policy_refresh_time() - base::Time::UnixEpoch(); | 220 cache_->last_policy_refresh_time() - base::Time::UnixEpoch(); |
| 221 fetch_request->set_timestamp(timestamp.InMilliseconds()); | 221 fetch_request->set_timestamp(timestamp.InMilliseconds()); |
| 222 } | 222 } |
| 223 | 223 |
| 224 // TODO(gfeher): Remove the following block when the server is migrated. | 224 // TODO(gfeher): Remove the following block when the server is migrated. |
| 225 // Set fields for the old protocol. | 225 // Set fields for the old protocol. |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 314 } |
| 315 | 315 |
| 316 int64 CloudPolicyController::GetRefreshDelay() { | 316 int64 CloudPolicyController::GetRefreshDelay() { |
| 317 int64 deviation = (policy_refresh_deviation_factor_percent_ * | 317 int64 deviation = (policy_refresh_deviation_factor_percent_ * |
| 318 policy_refresh_rate_ms_) / 100; | 318 policy_refresh_rate_ms_) / 100; |
| 319 deviation = std::min(deviation, policy_refresh_deviation_max_ms_); | 319 deviation = std::min(deviation, policy_refresh_deviation_max_ms_); |
| 320 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); | 320 return policy_refresh_rate_ms_ - base::RandGenerator(deviation + 1); |
| 321 } | 321 } |
| 322 | 322 |
| 323 } // namespace policy | 323 } // namespace policy |
| OLD | NEW |