Chromium Code Reviews| 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/policy/configuration_policy_handler.h" | 5 #include "chrome/browser/policy/configuration_policy_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1233 } | 1233 } |
| 1234 | 1234 |
| 1235 JavascriptPolicyHandler::~JavascriptPolicyHandler() { | 1235 JavascriptPolicyHandler::~JavascriptPolicyHandler() { |
| 1236 } | 1236 } |
| 1237 | 1237 |
| 1238 bool JavascriptPolicyHandler::CheckPolicySettings(const PolicyMap* policies, | 1238 bool JavascriptPolicyHandler::CheckPolicySettings(const PolicyMap* policies, |
| 1239 PolicyErrorMap* errors) { | 1239 PolicyErrorMap* errors) { |
| 1240 const Value* javascript_enabled = policies->Get(kPolicyJavascriptEnabled); | 1240 const Value* javascript_enabled = policies->Get(kPolicyJavascriptEnabled); |
| 1241 const Value* default_setting = policies->Get(kPolicyDefaultJavaScriptSetting); | 1241 const Value* default_setting = policies->Get(kPolicyDefaultJavaScriptSetting); |
| 1242 | 1242 |
| 1243 if (javascript_enabled && !javascript_enabled->IsType(Value::TYPE_BOOLEAN)) { | 1243 bool enabled = true; |
| 1244 if (javascript_enabled && !javascript_enabled->GetAsBoolean(&enabled)) { | |
| 1244 errors->AddError(kPolicyJavascriptEnabled, | 1245 errors->AddError(kPolicyJavascriptEnabled, |
| 1245 IDS_POLICY_TYPE_ERROR, | 1246 IDS_POLICY_TYPE_ERROR, |
| 1246 ValueTypeToString(Value::TYPE_BOOLEAN)); | 1247 ValueTypeToString(Value::TYPE_BOOLEAN)); |
| 1247 javascript_enabled = NULL; | 1248 javascript_enabled = NULL; |
| 1248 } | 1249 } |
| 1249 | 1250 |
| 1250 if (default_setting && !default_setting->IsType(Value::TYPE_INTEGER)) { | 1251 int setting = CONTENT_SETTING_DEFAULT; |
| 1252 if (default_setting && !default_setting->GetAsInteger(&setting)) { | |
| 1251 errors->AddError(kPolicyDefaultJavaScriptSetting, | 1253 errors->AddError(kPolicyDefaultJavaScriptSetting, |
| 1252 IDS_POLICY_TYPE_ERROR, | 1254 IDS_POLICY_TYPE_ERROR, |
| 1253 ValueTypeToString(Value::TYPE_INTEGER)); | 1255 ValueTypeToString(Value::TYPE_INTEGER)); |
| 1254 default_setting = NULL; | 1256 default_setting = NULL; |
| 1255 } | 1257 } |
| 1256 | 1258 |
| 1257 bool enabled; | |
| 1258 int setting; | |
| 1259 if (javascript_enabled && | 1259 if (javascript_enabled && |
| 1260 default_setting && | 1260 default_setting && |
| 1261 javascript_enabled->GetAsBoolean(&enabled) && | |
| 1262 default_setting->GetAsInteger(&setting) && | |
| 1263 !enabled && | 1261 !enabled && |
| 1264 setting != CONTENT_SETTING_BLOCK) { | 1262 setting != CONTENT_SETTING_BLOCK) { |
| 1265 errors->AddError(kPolicyDefaultJavaScriptSetting, | 1263 errors->AddError(kPolicyDefaultJavaScriptSetting, |
| 1266 IDS_POLICY_OVERRIDDEN, | 1264 IDS_POLICY_OVERRIDDEN, |
| 1267 GetPolicyName(kPolicyJavascriptEnabled)); | 1265 GetPolicyName(kPolicyJavascriptEnabled)); |
| 1268 } | 1266 } |
| 1269 return true; | 1267 return true; |
| 1270 } | 1268 } |
| 1271 | 1269 |
| 1272 void JavascriptPolicyHandler::ApplyPolicySettings(const PolicyMap* policies, | 1270 void JavascriptPolicyHandler::ApplyPolicySettings(const PolicyMap* policies, |
| 1273 PrefValueMap* prefs) { | 1271 PrefValueMap* prefs) { |
| 1274 const Value* javascript_enabled = policies->Get(kPolicyJavascriptEnabled); | 1272 const Value* javascript_enabled = policies->Get(kPolicyJavascriptEnabled); |
| 1275 const Value* default_setting = policies->Get(kPolicyDefaultJavaScriptSetting); | 1273 const Value* default_setting = policies->Get(kPolicyDefaultJavaScriptSetting); |
| 1276 | 1274 |
| 1277 int setting = CONTENT_SETTING_DEFAULT; | 1275 int setting = CONTENT_SETTING_DEFAULT; |
| 1278 if (default_setting) | 1276 if (default_setting) |
| 1279 default_setting->GetAsInteger(&setting); | 1277 default_setting->GetAsInteger(&setting); |
| 1280 | 1278 |
| 1281 bool enabled = true; | 1279 bool enabled = true; |
| 1282 if (javascript_enabled && javascript_enabled->GetAsBoolean(&enabled)) { | 1280 if (javascript_enabled && |
| 1283 prefs->SetValue(prefs::kWebKitJavascriptEnabled, | 1281 javascript_enabled->GetAsBoolean(&enabled) && |
| 1284 javascript_enabled->DeepCopy()); | 1282 !enabled) { |
| 1285 // Force the javascript content setting to BLOCK when this policy disables | 1283 // This policy is deprecated, and currently overrides the content setting. |
|
Mattias Nissler (ping if slow)
2011/11/03 18:42:02
I would expect this to be the other way round. Is
Joao da Silva
2011/11/03 20:46:55
No particular reason for it. The other deprecated
| |
| 1286 // javascript globally. | 1284 setting = CONTENT_SETTING_BLOCK; |
| 1287 if (!enabled) | |
| 1288 setting = CONTENT_SETTING_BLOCK; | |
| 1289 } | 1285 } |
| 1290 | 1286 |
| 1291 if (setting != CONTENT_SETTING_DEFAULT) | 1287 if (setting != CONTENT_SETTING_DEFAULT) { |
| 1292 prefs->SetValue(prefs::kManagedDefaultJavaScriptSetting, | 1288 prefs->SetValue(prefs::kManagedDefaultJavaScriptSetting, |
| 1293 Value::CreateIntegerValue(setting)); | 1289 Value::CreateIntegerValue(setting)); |
| 1290 } | |
| 1294 } | 1291 } |
| 1295 | 1292 |
| 1296 | 1293 |
| 1297 } // namespace | 1294 } // namespace |
| 1298 | 1295 |
| 1299 | 1296 |
| 1300 // ConfigurationPolicyHandler implementation ----------------------------------- | 1297 // ConfigurationPolicyHandler implementation ----------------------------------- |
| 1301 | 1298 |
| 1302 // static | 1299 // static |
| 1303 ConfigurationPolicyHandler::HandlerList* | 1300 ConfigurationPolicyHandler::HandlerList* |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 1321 list->push_back(new SyncPolicyHandler()); | 1318 list->push_back(new SyncPolicyHandler()); |
| 1322 | 1319 |
| 1323 #if !defined(OS_CHROMEOS) | 1320 #if !defined(OS_CHROMEOS) |
| 1324 list->push_back(new DownloadDirPolicyHandler()); | 1321 list->push_back(new DownloadDirPolicyHandler()); |
| 1325 #endif // !defined(OS_CHROME0S) | 1322 #endif // !defined(OS_CHROME0S) |
| 1326 | 1323 |
| 1327 return list; | 1324 return list; |
| 1328 } | 1325 } |
| 1329 | 1326 |
| 1330 } // namespace policy | 1327 } // namespace policy |
| OLD | NEW |