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/chromeos/login/signed_settings.h" | 5 #include "chrome/browser/chromeos/login/signed_settings.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 | 627 |
628 } else if (prop == kSettingProxyEverywhere) { | 628 } else if (prop == kSettingProxyEverywhere) { |
629 // TODO(cmasone): NOTIMPLEMENTED() once http://crosbug.com/13052 is fixed. | 629 // TODO(cmasone): NOTIMPLEMENTED() once http://crosbug.com/13052 is fixed. |
630 bool success = pol.mutable_device_proxy_settings()->ParseFromString(value); | 630 bool success = pol.mutable_device_proxy_settings()->ParseFromString(value); |
631 DCHECK(success); | 631 DCHECK(success); |
632 | 632 |
633 } else if (prop == kReleaseChannel) { | 633 } else if (prop == kReleaseChannel) { |
634 em::ReleaseChannelProto* release_channel = pol.mutable_release_channel(); | 634 em::ReleaseChannelProto* release_channel = pol.mutable_release_channel(); |
635 release_channel->set_release_channel(value); | 635 release_channel->set_release_channel(value); |
636 | 636 |
| 637 } else if (prop == kStatsReportingPref) { |
| 638 em::MetricsEnabledProto* metrics = pol.mutable_metrics_enabled(); |
| 639 metrics->set_metrics_enabled(value == "true"); |
| 640 |
637 } else { | 641 } else { |
638 NOTREACHED(); | 642 NOTREACHED(); |
639 } | 643 } |
640 poldata->set_policy_value(pol.SerializeAsString()); | 644 poldata->set_policy_value(pol.SerializeAsString()); |
641 } | 645 } |
642 | 646 |
643 void StorePropertyOp::PerformCallback(SignedSettings::ReturnCode code, | 647 void StorePropertyOp::PerformCallback(SignedSettings::ReturnCode code, |
644 bool value) { | 648 bool value) { |
645 d_->OnSettingsOpCompleted(code, value); | 649 d_->OnSettingsOpCompleted(code, value); |
646 } | 650 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
725 // If we have the allow_new_users bool, and it is true, we honor that above. | 729 // If we have the allow_new_users bool, and it is true, we honor that above. |
726 // In all other cases (don't have it, have it and it is set to false, etc), | 730 // In all other cases (don't have it, have it and it is set to false, etc), |
727 // We will honor the user_whitelist() if it is there and populated. | 731 // We will honor the user_whitelist() if it is there and populated. |
728 // Otherwise, fail open (to do otherwise could render the device unusable). | 732 // Otherwise, fail open (to do otherwise could render the device unusable). |
729 if (!pol.has_user_whitelist()) | 733 if (!pol.has_user_whitelist()) |
730 return kVeritas[1]; // Default to allowing new users. | 734 return kVeritas[1]; // Default to allowing new users. |
731 return kVeritas[pol.user_whitelist().user_whitelist_size() == 0]; | 735 return kVeritas[pol.user_whitelist().user_whitelist_size() == 0]; |
732 | 736 |
733 } else if (prop == kAccountsPrefAllowGuest) { | 737 } else if (prop == kAccountsPrefAllowGuest) { |
734 if (!pol.has_guest_mode_enabled() || | 738 if (!pol.has_guest_mode_enabled() || |
735 !pol.guest_mode_enabled().has_guest_mode_enabled()) | 739 !pol.guest_mode_enabled().has_guest_mode_enabled()) { |
736 return kVeritas[1]; // Default to allowing guests; | 740 return kVeritas[1]; // Default to allowing guests; |
| 741 } |
737 return kVeritas[pol.guest_mode_enabled().guest_mode_enabled()]; | 742 return kVeritas[pol.guest_mode_enabled().guest_mode_enabled()]; |
738 | 743 |
739 } else if (prop == kAccountsPrefShowUserNamesOnSignIn) { | 744 } else if (prop == kAccountsPrefShowUserNamesOnSignIn) { |
740 if (!pol.has_show_user_names() || | 745 if (!pol.has_show_user_names() || |
741 !pol.show_user_names().has_show_user_names()) | 746 !pol.show_user_names().has_show_user_names()) { |
742 return kVeritas[1]; // Default to showing pods on the login screen; | 747 return kVeritas[1]; // Default to showing pods on the login screen; |
| 748 } |
743 return kVeritas[pol.show_user_names().show_user_names()]; | 749 return kVeritas[pol.show_user_names().show_user_names()]; |
744 | 750 |
745 } else if (prop == kSignedDataRoamingEnabled) { | 751 } else if (prop == kSignedDataRoamingEnabled) { |
746 if (!pol.has_data_roaming_enabled() || | 752 if (!pol.has_data_roaming_enabled() || |
747 !pol.data_roaming_enabled().has_data_roaming_enabled()) | 753 !pol.data_roaming_enabled().has_data_roaming_enabled()) { |
748 return kVeritas[0]; // Default to disabling cellular data roaming; | 754 return kVeritas[0]; // Default to disabling cellular data roaming; |
| 755 } |
749 return kVeritas[pol.data_roaming_enabled().data_roaming_enabled()]; | 756 return kVeritas[pol.data_roaming_enabled().data_roaming_enabled()]; |
750 | 757 |
751 } else if (prop == kSettingProxyEverywhere) { | 758 } else if (prop == kSettingProxyEverywhere) { |
752 // TODO(cmasone): NOTIMPLEMENTED() once http://crosbug.com/13052 is fixed. | 759 // TODO(cmasone): NOTIMPLEMENTED() once http://crosbug.com/13052 is fixed. |
753 std::string serialized; | 760 std::string serialized; |
754 if (!pol.has_device_proxy_settings() || | 761 if (!pol.has_device_proxy_settings() || |
755 !pol.device_proxy_settings().SerializeToString(&serialized)) | 762 !pol.device_proxy_settings().SerializeToString(&serialized)) { |
756 return ""; // Default to invalid proxy config (will be ignored). | 763 return ""; // Default to invalid proxy config (will be ignored). |
| 764 } |
757 return serialized; | 765 return serialized; |
758 | 766 |
759 } else if (prop == kReleaseChannel) { | 767 } else if (prop == kReleaseChannel) { |
760 if (!pol.has_release_channel() || | 768 if (!pol.has_release_channel() || |
761 !pol.release_channel().has_release_channel()) | 769 !pol.release_channel().has_release_channel()) { |
762 return ""; // Default to an invalid channel (will be ignored). | 770 return ""; // Default to an invalid channel (will be ignored). |
| 771 } |
763 return pol.release_channel().release_channel(); | 772 return pol.release_channel().release_channel(); |
764 | 773 |
| 774 } else if (prop == kStatsReportingPref) { |
| 775 if (!pol.has_metrics_enabled() || |
| 776 !pol.metrics_enabled().metrics_enabled()) { |
| 777 return kVeritas[0]; // Default to not collecting metrics. |
| 778 } |
| 779 return kVeritas[pol.metrics_enabled().metrics_enabled()]; |
| 780 |
765 } | 781 } |
766 return std::string(); | 782 return std::string(); |
767 } | 783 } |
768 | 784 |
769 void RetrievePropertyOp::PerformCallback(SignedSettings::ReturnCode code, | 785 void RetrievePropertyOp::PerformCallback(SignedSettings::ReturnCode code, |
770 const std::string& value) { | 786 const std::string& value) { |
771 d_->OnSettingsOpCompleted(code, value); | 787 d_->OnSettingsOpCompleted(code, value); |
772 } | 788 } |
773 | 789 |
774 StorePolicyOp::StorePolicyOp(em::PolicyFetchResponse* policy, | 790 StorePolicyOp::StorePolicyOp(em::PolicyFetchResponse* policy, |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 sig.assign(sig_ptr, sig_ptr + policy_.policy_data_signature().length()); | 958 sig.assign(sig_ptr, sig_ptr + policy_.policy_data_signature().length()); |
943 service_->StartVerifyAttempt(policy_.policy_data(), sig, this); | 959 service_->StartVerifyAttempt(policy_.policy_data(), sig, this); |
944 } | 960 } |
945 | 961 |
946 void RetrievePolicyOp::PerformCallback(SignedSettings::ReturnCode code, | 962 void RetrievePolicyOp::PerformCallback(SignedSettings::ReturnCode code, |
947 const em::PolicyFetchResponse& value) { | 963 const em::PolicyFetchResponse& value) { |
948 d_->OnSettingsOpCompleted(code, value); | 964 d_->OnSettingsOpCompleted(code, value); |
949 } | 965 } |
950 | 966 |
951 } // namespace chromeos | 967 } // namespace chromeos |
OLD | NEW |