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