| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/configuration_policy_pref_store.h" | 5 #include "chrome/browser/configuration_policy_pref_store.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 // If the policy was a proxy policy, cleanup |value|. | 279 // If the policy was a proxy policy, cleanup |value|. |
| 280 if (result && value) | 280 if (result && value) |
| 281 delete value; | 281 delete value; |
| 282 return result; | 282 return result; |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool ConfigurationPolicyPrefStore::ApplyPluginPolicy(PolicyType policy, | 285 bool ConfigurationPolicyPrefStore::ApplyPluginPolicy(PolicyType policy, |
| 286 Value* value) { | 286 Value* value) { |
| 287 if (policy == kPolicyDisabledPlugins) { | 287 if (policy == kPolicyDisabledPlugins) { |
| 288 string16 plugin_list; | 288 string16 plugin_list; |
| 289 if (value->GetAsUTF16(&plugin_list)) { | 289 if (value->GetAsString(&plugin_list)) { |
| 290 std::vector<string16> plugin_names; | 290 std::vector<string16> plugin_names; |
| 291 // Change commas into tabs so that we can change escaped | 291 // Change commas into tabs so that we can change escaped |
| 292 // tabs back into commas, leaving non-escaped commas as tabs | 292 // tabs back into commas, leaving non-escaped commas as tabs |
| 293 // that can be used for splitting the string. Note that plugin | 293 // that can be used for splitting the string. Note that plugin |
| 294 // names must not contain backslashes, since a trailing backslash | 294 // names must not contain backslashes, since a trailing backslash |
| 295 // in a plugin name before a comma would get swallowed during the | 295 // in a plugin name before a comma would get swallowed during the |
| 296 // splitting. | 296 // splitting. |
| 297 std::replace(plugin_list.begin(), plugin_list.end(), L',', L'\t'); | 297 std::replace(plugin_list.begin(), plugin_list.end(), L',', L'\t'); |
| 298 ReplaceSubstringsAfterOffset(&plugin_list, 0, | 298 ReplaceSubstringsAfterOffset(&plugin_list, 0, |
| 299 ASCIIToUTF16("\\\t"), ASCIIToUTF16(",")); | 299 ASCIIToUTF16("\\\t"), ASCIIToUTF16(",")); |
| 300 SplitString(plugin_list, L'\t', &plugin_names); | 300 SplitString(plugin_list, L'\t', &plugin_names); |
| 301 bool added_plugin = false; | 301 bool added_plugin = false; |
| 302 scoped_ptr<ListValue> list(new ListValue()); | 302 scoped_ptr<ListValue> list(new ListValue()); |
| 303 for (std::vector<string16>::const_iterator i(plugin_names.begin()); | 303 for (std::vector<string16>::const_iterator i(plugin_names.begin()); |
| 304 i != plugin_names.end(); ++i) { | 304 i != plugin_names.end(); ++i) { |
| 305 if (!i->empty()) { | 305 if (!i->empty()) { |
| 306 list->Append(Value::CreateStringValueFromUTF16(*i)); | 306 list->Append(Value::CreateStringValue(*i)); |
| 307 added_plugin = true; | 307 added_plugin = true; |
| 308 } | 308 } |
| 309 } | 309 } |
| 310 if (added_plugin) { | 310 if (added_plugin) { |
| 311 prefs_->Set(prefs::kPluginsPluginsBlacklist, list.release()); | 311 prefs_->Set(prefs::kPluginsPluginsBlacklist, list.release()); |
| 312 delete value; | 312 delete value; |
| 313 return true; | 313 return true; |
| 314 } | 314 } |
| 315 } | 315 } |
| 316 } | 316 } |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 355 return; | 355 return; |
| 356 | 356 |
| 357 if (ApplyPolicyFromMap(policy, value, simple_policy_map_, | 357 if (ApplyPolicyFromMap(policy, value, simple_policy_map_, |
| 358 arraysize(simple_policy_map_))) | 358 arraysize(simple_policy_map_))) |
| 359 return; | 359 return; |
| 360 | 360 |
| 361 // Other policy implementations go here. | 361 // Other policy implementations go here. |
| 362 NOTIMPLEMENTED(); | 362 NOTIMPLEMENTED(); |
| 363 delete value; | 363 delete value; |
| 364 } | 364 } |
| OLD | NEW |