OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/policy/core/browser/url_blacklist_policy_handler.h" | 5 #include "components/policy/core/browser/url_blacklist_policy_handler.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/values.h" | 10 #include "base/values.h" |
11 #include "components/policy/core/browser/policy_error_map.h" | 11 #include "components/policy/core/browser/policy_error_map.h" |
12 #include "components/policy/core/common/policy_map.h" | 12 #include "components/policy/core/common/policy_map.h" |
13 #include "components/policy/core/common/policy_pref_names.h" | 13 #include "components/policy/core/common/policy_pref_names.h" |
14 #include "components/policy/policy_constants.h" | 14 #include "components/policy/policy_constants.h" |
15 #include "components/prefs/pref_value_map.h" | 15 #include "components/prefs/pref_value_map.h" |
16 #include "grit/components_strings.h" | 16 #include "grit/components_strings.h" |
17 | 17 |
18 namespace policy { | 18 namespace policy { |
19 | 19 |
20 URLBlacklistPolicyHandler::URLBlacklistPolicyHandler() {} | 20 URLBlacklistPolicyHandler::URLBlacklistPolicyHandler() {} |
21 | 21 |
22 URLBlacklistPolicyHandler::~URLBlacklistPolicyHandler() {} | 22 URLBlacklistPolicyHandler::~URLBlacklistPolicyHandler() {} |
23 | 23 |
24 bool URLBlacklistPolicyHandler::CheckPolicySettings(const PolicyMap& policies, | 24 bool URLBlacklistPolicyHandler::CheckPolicySettings(const PolicyMap& policies, |
25 PolicyErrorMap* errors) { | 25 PolicyErrorMap* errors) { |
26 const base::Value* disabled_schemes = | 26 const base::Value* disabled_schemes = |
27 policies.GetValue(key::kDisabledSchemes); | 27 policies.GetValue(key::kDisabledSchemes); |
28 const base::Value* url_blacklist = policies.GetValue(key::kURLBlacklist); | 28 const base::Value* url_blacklist = policies.GetValue(key::kURLBlacklist); |
29 | 29 |
30 if (disabled_schemes && !disabled_schemes->IsType(base::Value::TYPE_LIST)) { | 30 if (disabled_schemes && !disabled_schemes->IsType(base::Value::Type::LIST)) { |
31 errors->AddError(key::kDisabledSchemes, IDS_POLICY_TYPE_ERROR, | 31 errors->AddError(key::kDisabledSchemes, IDS_POLICY_TYPE_ERROR, |
32 base::Value::GetTypeName(base::Value::TYPE_LIST)); | 32 base::Value::GetTypeName(base::Value::Type::LIST)); |
33 } | 33 } |
34 | 34 |
35 if (url_blacklist && !url_blacklist->IsType(base::Value::TYPE_LIST)) { | 35 if (url_blacklist && !url_blacklist->IsType(base::Value::Type::LIST)) { |
36 errors->AddError(key::kURLBlacklist, IDS_POLICY_TYPE_ERROR, | 36 errors->AddError(key::kURLBlacklist, IDS_POLICY_TYPE_ERROR, |
37 base::Value::GetTypeName(base::Value::TYPE_LIST)); | 37 base::Value::GetTypeName(base::Value::Type::LIST)); |
38 } | 38 } |
39 | 39 |
40 return true; | 40 return true; |
41 } | 41 } |
42 | 42 |
43 void URLBlacklistPolicyHandler::ApplyPolicySettings(const PolicyMap& policies, | 43 void URLBlacklistPolicyHandler::ApplyPolicySettings(const PolicyMap& policies, |
44 PrefValueMap* prefs) { | 44 PrefValueMap* prefs) { |
45 const base::Value* url_blacklist_policy = | 45 const base::Value* url_blacklist_policy = |
46 policies.GetValue(key::kURLBlacklist); | 46 policies.GetValue(key::kURLBlacklist); |
47 const base::ListValue* url_blacklist = NULL; | 47 const base::ListValue* url_blacklist = NULL; |
(...skipping 14 matching lines...) Expand all Loading... |
62 std::string entry_value; | 62 std::string entry_value; |
63 if (entry->GetAsString(&entry_value)) { | 63 if (entry->GetAsString(&entry_value)) { |
64 entry_value.append("://*"); | 64 entry_value.append("://*"); |
65 merged_url_blacklist->AppendString(entry_value); | 65 merged_url_blacklist->AppendString(entry_value); |
66 } | 66 } |
67 } | 67 } |
68 } | 68 } |
69 | 69 |
70 if (url_blacklist) { | 70 if (url_blacklist) { |
71 for (const auto& entry : *url_blacklist) { | 71 for (const auto& entry : *url_blacklist) { |
72 if (entry->IsType(base::Value::TYPE_STRING)) | 72 if (entry->IsType(base::Value::Type::STRING)) |
73 merged_url_blacklist->Append(entry->CreateDeepCopy()); | 73 merged_url_blacklist->Append(entry->CreateDeepCopy()); |
74 } | 74 } |
75 } | 75 } |
76 | 76 |
77 if (disabled_schemes || url_blacklist) { | 77 if (disabled_schemes || url_blacklist) { |
78 prefs->SetValue(policy_prefs::kUrlBlacklist, | 78 prefs->SetValue(policy_prefs::kUrlBlacklist, |
79 std::move(merged_url_blacklist)); | 79 std::move(merged_url_blacklist)); |
80 } | 80 } |
81 } | 81 } |
82 | 82 |
83 } // namespace policy | 83 } // namespace policy |
OLD | NEW |