OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <algorithm> | 5 #include <algorithm> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1011 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { | 1011 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPlugins) { |
1012 // Verifies that plugins can be forced to be disabled by policy. | 1012 // Verifies that plugins can be forced to be disabled by policy. |
1013 | 1013 |
1014 // Verify that the Flash plugin exists and that it can be enabled and disabled | 1014 // Verify that the Flash plugin exists and that it can be enabled and disabled |
1015 // by the user. | 1015 // by the user. |
1016 std::vector<webkit::WebPluginInfo> plugins; | 1016 std::vector<webkit::WebPluginInfo> plugins; |
1017 GetPluginList(&plugins); | 1017 GetPluginList(&plugins); |
1018 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1018 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1019 if (!flash) | 1019 if (!flash) |
1020 return; | 1020 return; |
1021 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser()->profile()); | 1021 PluginPrefs* plugin_prefs = |
| 1022 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1022 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1023 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1023 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1024 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1024 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1025 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1025 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | 1026 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); |
1026 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1027 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1027 | 1028 |
1028 // Now disable it with a policy. | 1029 // Now disable it with a policy. |
1029 base::ListValue disabled_plugins; | 1030 base::ListValue disabled_plugins; |
1030 disabled_plugins.Append(base::Value::CreateStringValue("*Flash*")); | 1031 disabled_plugins.Append(base::Value::CreateStringValue("*Flash*")); |
1031 PolicyMap policies; | 1032 PolicyMap policies; |
1032 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, | 1033 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, |
1033 POLICY_SCOPE_USER, disabled_plugins.DeepCopy()); | 1034 POLICY_SCOPE_USER, disabled_plugins.DeepCopy()); |
1034 UpdateProviderPolicy(policies); | 1035 UpdateProviderPolicy(policies); |
1035 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1036 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1036 // The user shouldn't be able to enable it. | 1037 // The user shouldn't be able to enable it. |
1037 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | 1038 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); |
1038 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1039 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1039 } | 1040 } |
1040 | 1041 |
1041 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { | 1042 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { |
1042 // Verifies that plugins with an exception in the blacklist can be enabled. | 1043 // Verifies that plugins with an exception in the blacklist can be enabled. |
1043 | 1044 |
1044 // Verify that the Flash plugin exists and that it can be enabled and disabled | 1045 // Verify that the Flash plugin exists and that it can be enabled and disabled |
1045 // by the user. | 1046 // by the user. |
1046 std::vector<webkit::WebPluginInfo> plugins; | 1047 std::vector<webkit::WebPluginInfo> plugins; |
1047 GetPluginList(&plugins); | 1048 GetPluginList(&plugins); |
1048 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1049 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1049 if (!flash) | 1050 if (!flash) |
1050 return; | 1051 return; |
1051 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser()->profile()); | 1052 PluginPrefs* plugin_prefs = |
| 1053 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1052 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1054 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1053 | 1055 |
1054 // Disable all plugins. | 1056 // Disable all plugins. |
1055 base::ListValue disabled_plugins; | 1057 base::ListValue disabled_plugins; |
1056 disabled_plugins.Append(base::Value::CreateStringValue("*")); | 1058 disabled_plugins.Append(base::Value::CreateStringValue("*")); |
1057 PolicyMap policies; | 1059 PolicyMap policies; |
1058 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, | 1060 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, |
1059 POLICY_SCOPE_USER, disabled_plugins.DeepCopy()); | 1061 POLICY_SCOPE_USER, disabled_plugins.DeepCopy()); |
1060 UpdateProviderPolicy(policies); | 1062 UpdateProviderPolicy(policies); |
1061 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1063 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
(...skipping 17 matching lines...) Expand all Loading... |
1079 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1081 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1080 } | 1082 } |
1081 | 1083 |
1082 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { | 1084 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { |
1083 // Verifies that a plugin can be force-installed with a policy. | 1085 // Verifies that a plugin can be force-installed with a policy. |
1084 std::vector<webkit::WebPluginInfo> plugins; | 1086 std::vector<webkit::WebPluginInfo> plugins; |
1085 GetPluginList(&plugins); | 1087 GetPluginList(&plugins); |
1086 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1088 const webkit::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1087 if (!flash) | 1089 if (!flash) |
1088 return; | 1090 return; |
1089 PluginPrefs* plugin_prefs = PluginPrefs::GetForProfile(browser()->profile()); | 1091 PluginPrefs* plugin_prefs = |
| 1092 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1090 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1093 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1091 | 1094 |
1092 // The user disables it and then a policy forces it to be enabled. | 1095 // The user disables it and then a policy forces it to be enabled. |
1093 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1096 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1094 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1097 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1095 base::ListValue plugin_list; | 1098 base::ListValue plugin_list; |
1096 plugin_list.Append(base::Value::CreateStringValue(kFlashPluginName)); | 1099 plugin_list.Append(base::Value::CreateStringValue(kFlashPluginName)); |
1097 PolicyMap policies; | 1100 PolicyMap policies; |
1098 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, | 1101 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, |
1099 POLICY_SCOPE_USER, plugin_list.DeepCopy()); | 1102 POLICY_SCOPE_USER, plugin_list.DeepCopy()); |
(...skipping 1357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2457 chrome_variations::VariationsService::GetVariationsServerURL( | 2460 chrome_variations::VariationsService::GetVariationsServerURL( |
2458 g_browser_process->local_state()); | 2461 g_browser_process->local_state()); |
2459 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); | 2462 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); |
2460 std::string value; | 2463 std::string value; |
2461 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 2464 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
2462 EXPECT_EQ("restricted", value); | 2465 EXPECT_EQ("restricted", value); |
2463 } | 2466 } |
2464 #endif | 2467 #endif |
2465 | 2468 |
2466 } // namespace policy | 2469 } // namespace policy |
OLD | NEW |