| 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/device_policy_cache.h" | 5 #include "chrome/browser/policy/device_policy_cache.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/callback.h" | 13 #include "base/callback.h" |
| 14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
| 15 #include "base/logging.h" | 15 #include "base/logging.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/values.h" | 17 #include "base/values.h" |
| 18 #include "chrome/browser/chromeos/cros_settings.h" | 18 #include "chrome/browser/chromeos/cros_settings.h" |
| 19 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 19 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 20 #include "chrome/browser/chromeos/dbus/update_engine_client.h" | 20 #include "chrome/browser/chromeos/dbus/update_engine_client.h" |
| 21 #include "chrome/browser/chromeos/login/authenticator.h" |
| 21 #include "chrome/browser/chromeos/login/ownership_service.h" | 22 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 22 #include "chrome/browser/chromeos/login/signed_settings_helper.h" | 23 #include "chrome/browser/chromeos/login/signed_settings_helper.h" |
| 23 #include "chrome/browser/policy/app_pack_updater.h" | 24 #include "chrome/browser/policy/app_pack_updater.h" |
| 24 #include "chrome/browser/policy/cloud_policy_data_store.h" | 25 #include "chrome/browser/policy/cloud_policy_data_store.h" |
| 25 #include "chrome/browser/policy/enterprise_install_attributes.h" | 26 #include "chrome/browser/policy/enterprise_install_attributes.h" |
| 26 #include "chrome/browser/policy/enterprise_metrics.h" | 27 #include "chrome/browser/policy/enterprise_metrics.h" |
| 27 #include "chrome/browser/policy/policy_map.h" | 28 #include "chrome/browser/policy/policy_map.h" |
| 28 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 29 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
| 29 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 30 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
| 30 #include "policy/policy_constants.h" | 31 #include "policy/policy_constants.h" |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 em::PolicyData policy_data; | 163 em::PolicyData policy_data; |
| 163 if (!policy_data.ParseFromString(policy.policy_data())) { | 164 if (!policy_data.ParseFromString(policy.policy_data())) { |
| 164 LOG(WARNING) << "Invalid policy protobuf"; | 165 LOG(WARNING) << "Invalid policy protobuf"; |
| 165 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy, | 166 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchInvalidPolicy, |
| 166 kMetricPolicySize); | 167 kMetricPolicySize); |
| 167 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | 168 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
| 168 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | 169 CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
| 169 return false; | 170 return false; |
| 170 } | 171 } |
| 171 | 172 |
| 172 if (registration_user != policy_data.username()) { | 173 // Existing installations may not have a canonicalized version of the |
| 174 // registration user name in install attributes, so re-canonicalize here. |
| 175 if (chromeos::Authenticator::Canonicalize(registration_user) != |
| 176 chromeos::Authenticator::Canonicalize(policy_data.username())) { |
| 173 LOG(WARNING) << "Refusing policy blob for " << policy_data.username() | 177 LOG(WARNING) << "Refusing policy blob for " << policy_data.username() |
| 174 << " which doesn't match " << registration_user; | 178 << " which doesn't match " << registration_user; |
| 175 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch, | 179 UMA_HISTOGRAM_ENUMERATION(kMetricPolicy, kMetricPolicyFetchUserMismatch, |
| 176 kMetricPolicySize); | 180 kMetricPolicySize); |
| 177 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, | 181 InformNotifier(CloudPolicySubsystem::LOCAL_ERROR, |
| 178 CloudPolicySubsystem::POLICY_LOCAL_ERROR); | 182 CloudPolicySubsystem::POLICY_LOCAL_ERROR); |
| 179 return false; | 183 return false; |
| 180 } | 184 } |
| 181 | 185 |
| 182 set_last_policy_refresh_time(base::Time::NowFromSystemTime()); | 186 set_last_policy_refresh_time(base::Time::NowFromSystemTime()); |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 PolicyMap* policies) { | 597 PolicyMap* policies) { |
| 594 // Decode the various groups of policies. | 598 // Decode the various groups of policies. |
| 595 DecodeLoginPolicies(policy, policies); | 599 DecodeLoginPolicies(policy, policies); |
| 596 DecodeKioskPolicies(policy, policies); | 600 DecodeKioskPolicies(policy, policies); |
| 597 DecodeNetworkPolicies(policy, policies); | 601 DecodeNetworkPolicies(policy, policies); |
| 598 DecodeReportingPolicies(policy, policies); | 602 DecodeReportingPolicies(policy, policies); |
| 599 DecodeGenericPolicies(policy, policies); | 603 DecodeGenericPolicies(policy, policies); |
| 600 } | 604 } |
| 601 | 605 |
| 602 } // namespace policy | 606 } // namespace policy |
| OLD | NEW |