https_only_mode_policy_handler.cc 1.1 KB

123456789101112131415161718192021222324252627282930
  1. // Copyright 2021 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "components/security_interstitials/core/https_only_mode_policy_handler.h"
  5. #include "components/policy/core/common/policy_map.h"
  6. #include "components/policy/policy_constants.h"
  7. #include "components/prefs/pref_value_map.h"
  8. namespace policy {
  9. HttpsOnlyModePolicyHandler::HttpsOnlyModePolicyHandler(
  10. const char* const pref_name)
  11. : TypeCheckingPolicyHandler(key::kHttpsOnlyMode, base::Value::Type::STRING),
  12. pref_name_(pref_name) {}
  13. HttpsOnlyModePolicyHandler::~HttpsOnlyModePolicyHandler() = default;
  14. void HttpsOnlyModePolicyHandler::ApplyPolicySettings(const PolicyMap& policies,
  15. PrefValueMap* prefs) {
  16. const base::Value* value =
  17. policies.GetValue(key::kHttpsOnlyMode, base::Value::Type::STRING);
  18. if (value && value->GetString() == "disallowed") {
  19. // Only apply the policy to the pref if it is set to "disallowed".
  20. prefs->SetBoolean(pref_name_, false);
  21. }
  22. }
  23. } // namespace policy