OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/javascript_policy_handler.h" | 5 #include "chrome/browser/policy/javascript_policy_handler.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "components/content_settings/core/common/content_settings.h" | 8 #include "components/content_settings/core/common/content_settings.h" |
9 #include "components/content_settings/core/common/pref_names.h" | 9 #include "components/content_settings/core/common/pref_names.h" |
10 #include "components/policy/core/browser/policy_error_map.h" | 10 #include "components/policy/core/browser/policy_error_map.h" |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 bool JavascriptPolicyHandler::CheckPolicySettings(const PolicyMap& policies, | 22 bool JavascriptPolicyHandler::CheckPolicySettings(const PolicyMap& policies, |
23 PolicyErrorMap* errors) { | 23 PolicyErrorMap* errors) { |
24 const base::Value* javascript_enabled = | 24 const base::Value* javascript_enabled = |
25 policies.GetValue(key::kJavascriptEnabled); | 25 policies.GetValue(key::kJavascriptEnabled); |
26 const base::Value* default_setting = | 26 const base::Value* default_setting = |
27 policies.GetValue(key::kDefaultJavaScriptSetting); | 27 policies.GetValue(key::kDefaultJavaScriptSetting); |
28 | 28 |
29 if (javascript_enabled && | 29 if (javascript_enabled && |
30 !javascript_enabled->IsType(base::Value::TYPE_BOOLEAN)) { | 30 !javascript_enabled->IsType(base::Value::TYPE_BOOLEAN)) { |
31 errors->AddError(key::kJavascriptEnabled, | 31 errors->AddError(key::kJavascriptEnabled, IDS_POLICY_TYPE_ERROR, |
32 IDS_POLICY_TYPE_ERROR, | 32 base::Value::GetTypeName(base::Value::TYPE_BOOLEAN)); |
33 ValueTypeToString(base::Value::TYPE_BOOLEAN)); | |
34 } | 33 } |
35 | 34 |
36 if (default_setting && !default_setting->IsType(base::Value::TYPE_INTEGER)) { | 35 if (default_setting && !default_setting->IsType(base::Value::TYPE_INTEGER)) { |
37 errors->AddError(key::kDefaultJavaScriptSetting, | 36 errors->AddError(key::kDefaultJavaScriptSetting, IDS_POLICY_TYPE_ERROR, |
38 IDS_POLICY_TYPE_ERROR, | 37 base::Value::GetTypeName(base::Value::TYPE_INTEGER)); |
39 ValueTypeToString(base::Value::TYPE_INTEGER)); | |
40 } | 38 } |
41 | 39 |
42 if (javascript_enabled && default_setting) { | 40 if (javascript_enabled && default_setting) { |
43 errors->AddError(key::kJavascriptEnabled, | 41 errors->AddError(key::kJavascriptEnabled, |
44 IDS_POLICY_OVERRIDDEN, | 42 IDS_POLICY_OVERRIDDEN, |
45 key::kDefaultJavaScriptSetting); | 43 key::kDefaultJavaScriptSetting); |
46 } | 44 } |
47 | 45 |
48 return true; | 46 return true; |
49 } | 47 } |
(...skipping 15 matching lines...) Expand all Loading... |
65 !enabled) { | 63 !enabled) { |
66 setting = CONTENT_SETTING_BLOCK; | 64 setting = CONTENT_SETTING_BLOCK; |
67 } | 65 } |
68 } | 66 } |
69 | 67 |
70 if (setting != CONTENT_SETTING_DEFAULT) | 68 if (setting != CONTENT_SETTING_DEFAULT) |
71 prefs->SetInteger(prefs::kManagedDefaultJavaScriptSetting, setting); | 69 prefs->SetInteger(prefs::kManagedDefaultJavaScriptSetting, setting); |
72 } | 70 } |
73 | 71 |
74 } // namespace policy | 72 } // namespace policy |
OLD | NEW |