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 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 | 744 |
745 // Sets the locale policy before the browser is started. | 745 // Sets the locale policy before the browser is started. |
746 class LocalePolicyTest : public PolicyTest { | 746 class LocalePolicyTest : public PolicyTest { |
747 public: | 747 public: |
748 LocalePolicyTest() {} | 748 LocalePolicyTest() {} |
749 virtual ~LocalePolicyTest() {} | 749 virtual ~LocalePolicyTest() {} |
750 | 750 |
751 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 751 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
752 PolicyTest::SetUpInProcessBrowserTestFixture(); | 752 PolicyTest::SetUpInProcessBrowserTestFixture(); |
753 PolicyMap policies; | 753 PolicyMap policies; |
754 policies.Set( | 754 policies.Set(key::kApplicationLocaleValue, |
755 key::kApplicationLocaleValue, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 755 POLICY_LEVEL_MANDATORY, |
756 base::Value::CreateStringValue("fr"), NULL); | 756 POLICY_SCOPE_USER, |
| 757 new base::StringValue("fr"), |
| 758 NULL); |
757 provider_.UpdateChromePolicy(policies); | 759 provider_.UpdateChromePolicy(policies); |
758 // The "en-US" ResourceBundle is always loaded before this step for tests, | 760 // The "en-US" ResourceBundle is always loaded before this step for tests, |
759 // but in this test we want the browser to load the bundle as it | 761 // but in this test we want the browser to load the bundle as it |
760 // normally would. | 762 // normally would. |
761 ResourceBundle::CleanupSharedInstance(); | 763 ResourceBundle::CleanupSharedInstance(); |
762 } | 764 } |
763 }; | 765 }; |
764 | 766 |
765 IN_PROC_BROWSER_TEST_F(LocalePolicyTest, ApplicationLocaleValue) { | 767 IN_PROC_BROWSER_TEST_F(LocalePolicyTest, ApplicationLocaleValue) { |
766 // Verifies that the default locale can be overridden with policy. | 768 // Verifies that the default locale can be overridden with policy. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 kSearchTermsReplacementKey && | 886 kSearchTermsReplacementKey && |
885 default_search->image_url() == kImageURL && | 887 default_search->image_url() == kImageURL && |
886 default_search->image_url_post_params() == kImageURLPostParams && | 888 default_search->image_url_post_params() == kImageURLPostParams && |
887 default_search->new_tab_url() == kNewTabURL); | 889 default_search->new_tab_url() == kNewTabURL); |
888 | 890 |
889 // Override the default search provider using policies. | 891 // Override the default search provider using policies. |
890 PolicyMap policies; | 892 PolicyMap policies; |
891 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, | 893 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
892 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); | 894 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); |
893 policies.Set(key::kDefaultSearchProviderKeyword, | 895 policies.Set(key::kDefaultSearchProviderKeyword, |
894 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 896 POLICY_LEVEL_MANDATORY, |
895 base::Value::CreateStringValue(kKeyword), NULL); | 897 POLICY_SCOPE_USER, |
| 898 new base::StringValue(kKeyword), |
| 899 NULL); |
896 policies.Set(key::kDefaultSearchProviderSearchURL, | 900 policies.Set(key::kDefaultSearchProviderSearchURL, |
897 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 901 POLICY_LEVEL_MANDATORY, |
898 base::Value::CreateStringValue(kSearchURL), NULL); | 902 POLICY_SCOPE_USER, |
| 903 new base::StringValue(kSearchURL), |
| 904 NULL); |
899 base::ListValue* alternate_urls = new base::ListValue(); | 905 base::ListValue* alternate_urls = new base::ListValue(); |
900 alternate_urls->AppendString(kAlternateURL0); | 906 alternate_urls->AppendString(kAlternateURL0); |
901 alternate_urls->AppendString(kAlternateURL1); | 907 alternate_urls->AppendString(kAlternateURL1); |
902 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, | 908 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, |
903 POLICY_SCOPE_USER, alternate_urls, NULL); | 909 POLICY_SCOPE_USER, alternate_urls, NULL); |
904 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, | 910 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, |
905 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 911 POLICY_LEVEL_MANDATORY, |
906 base::Value::CreateStringValue(kSearchTermsReplacementKey), | 912 POLICY_SCOPE_USER, |
| 913 new base::StringValue(kSearchTermsReplacementKey), |
907 NULL); | 914 NULL); |
908 policies.Set(key::kDefaultSearchProviderImageURL, | 915 policies.Set(key::kDefaultSearchProviderImageURL, |
909 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 916 POLICY_LEVEL_MANDATORY, |
910 base::Value::CreateStringValue(kImageURL), | 917 POLICY_SCOPE_USER, |
| 918 new base::StringValue(kImageURL), |
911 NULL); | 919 NULL); |
912 policies.Set(key::kDefaultSearchProviderImageURLPostParams, | 920 policies.Set(key::kDefaultSearchProviderImageURLPostParams, |
913 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 921 POLICY_LEVEL_MANDATORY, |
914 base::Value::CreateStringValue(kImageURLPostParams), | 922 POLICY_SCOPE_USER, |
| 923 new base::StringValue(kImageURLPostParams), |
915 NULL); | 924 NULL); |
916 policies.Set(key::kDefaultSearchProviderNewTabURL, | 925 policies.Set(key::kDefaultSearchProviderNewTabURL, |
917 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 926 POLICY_LEVEL_MANDATORY, |
918 base::Value::CreateStringValue(kNewTabURL), | 927 POLICY_SCOPE_USER, |
| 928 new base::StringValue(kNewTabURL), |
919 NULL); | 929 NULL); |
920 UpdateProviderPolicy(policies); | 930 UpdateProviderPolicy(policies); |
921 default_search = service->GetDefaultSearchProvider(); | 931 default_search = service->GetDefaultSearchProvider(); |
922 ASSERT_TRUE(default_search); | 932 ASSERT_TRUE(default_search); |
923 EXPECT_EQ(kKeyword, default_search->keyword()); | 933 EXPECT_EQ(kKeyword, default_search->keyword()); |
924 EXPECT_EQ(kSearchURL, default_search->url()); | 934 EXPECT_EQ(kSearchURL, default_search->url()); |
925 EXPECT_EQ(2U, default_search->alternate_urls().size()); | 935 EXPECT_EQ(2U, default_search->alternate_urls().size()); |
926 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); | 936 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); |
927 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); | 937 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); |
928 EXPECT_EQ(kSearchTermsReplacementKey, | 938 EXPECT_EQ(kSearchTermsReplacementKey, |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1069 EXPECT_FALSE( | 1079 EXPECT_FALSE( |
1070 default_search->alternate_urls().size() == 2 && | 1080 default_search->alternate_urls().size() == 2 && |
1071 default_search->alternate_urls()[0] == kAlternateURL0 && | 1081 default_search->alternate_urls()[0] == kAlternateURL0 && |
1072 default_search->alternate_urls()[1] == kAlternateURL1); | 1082 default_search->alternate_urls()[1] == kAlternateURL1); |
1073 | 1083 |
1074 // Override the default search provider using policies. | 1084 // Override the default search provider using policies. |
1075 PolicyMap policies; | 1085 PolicyMap policies; |
1076 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, | 1086 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, |
1077 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); | 1087 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); |
1078 policies.Set(key::kDefaultSearchProviderKeyword, | 1088 policies.Set(key::kDefaultSearchProviderKeyword, |
1079 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1089 POLICY_LEVEL_MANDATORY, |
1080 base::Value::CreateStringValue(kKeyword), NULL); | 1090 POLICY_SCOPE_USER, |
| 1091 new base::StringValue(kKeyword), |
| 1092 NULL); |
1081 policies.Set(key::kDefaultSearchProviderSearchURL, | 1093 policies.Set(key::kDefaultSearchProviderSearchURL, |
1082 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1094 POLICY_LEVEL_MANDATORY, |
1083 base::Value::CreateStringValue(kSearchURL), NULL); | 1095 POLICY_SCOPE_USER, |
| 1096 new base::StringValue(kSearchURL), |
| 1097 NULL); |
1084 policies.Set(key::kDefaultSearchProviderInstantURL, | 1098 policies.Set(key::kDefaultSearchProviderInstantURL, |
1085 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1099 POLICY_LEVEL_MANDATORY, |
1086 base::Value::CreateStringValue(kInstantURL), NULL); | 1100 POLICY_SCOPE_USER, |
| 1101 new base::StringValue(kInstantURL), |
| 1102 NULL); |
1087 base::ListValue* alternate_urls = new base::ListValue(); | 1103 base::ListValue* alternate_urls = new base::ListValue(); |
1088 alternate_urls->AppendString(kAlternateURL0); | 1104 alternate_urls->AppendString(kAlternateURL0); |
1089 alternate_urls->AppendString(kAlternateURL1); | 1105 alternate_urls->AppendString(kAlternateURL1); |
1090 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, | 1106 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, |
1091 POLICY_SCOPE_USER, alternate_urls, NULL); | 1107 POLICY_SCOPE_USER, alternate_urls, NULL); |
1092 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, | 1108 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, |
1093 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 1109 POLICY_LEVEL_MANDATORY, |
1094 base::Value::CreateStringValue(kSearchTermsReplacementKey), | 1110 POLICY_SCOPE_USER, |
| 1111 new base::StringValue(kSearchTermsReplacementKey), |
1095 NULL); | 1112 NULL); |
1096 UpdateProviderPolicy(policies); | 1113 UpdateProviderPolicy(policies); |
1097 default_search = service->GetDefaultSearchProvider(); | 1114 default_search = service->GetDefaultSearchProvider(); |
1098 ASSERT_TRUE(default_search); | 1115 ASSERT_TRUE(default_search); |
1099 EXPECT_EQ(kKeyword, default_search->keyword()); | 1116 EXPECT_EQ(kKeyword, default_search->keyword()); |
1100 EXPECT_EQ(kSearchURL, default_search->url()); | 1117 EXPECT_EQ(kSearchURL, default_search->url()); |
1101 EXPECT_EQ(kInstantURL, default_search->instant_url()); | 1118 EXPECT_EQ(kInstantURL, default_search->instant_url()); |
1102 EXPECT_EQ(2U, default_search->alternate_urls().size()); | 1119 EXPECT_EQ(2U, default_search->alternate_urls().size()); |
1103 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); | 1120 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); |
1104 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); | 1121 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 PluginPrefs* plugin_prefs = | 1233 PluginPrefs* plugin_prefs = |
1217 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1234 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1218 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1235 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1219 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1236 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1220 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1237 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1221 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | 1238 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); |
1222 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1239 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1223 | 1240 |
1224 // Now disable it with a policy. | 1241 // Now disable it with a policy. |
1225 base::ListValue disabled_plugins; | 1242 base::ListValue disabled_plugins; |
1226 disabled_plugins.Append(base::Value::CreateStringValue("*Flash*")); | 1243 disabled_plugins.Append(new base::StringValue("*Flash*")); |
1227 PolicyMap policies; | 1244 PolicyMap policies; |
1228 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, | 1245 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, |
1229 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); | 1246 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); |
1230 UpdateProviderPolicy(policies); | 1247 UpdateProviderPolicy(policies); |
1231 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1248 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1232 // The user shouldn't be able to enable it. | 1249 // The user shouldn't be able to enable it. |
1233 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | 1250 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); |
1234 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1251 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1235 } | 1252 } |
1236 | 1253 |
1237 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { | 1254 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { |
1238 // Verifies that plugins with an exception in the blacklist can be enabled. | 1255 // Verifies that plugins with an exception in the blacklist can be enabled. |
1239 | 1256 |
1240 // Verify that the Flash plugin exists and that it can be enabled and disabled | 1257 // Verify that the Flash plugin exists and that it can be enabled and disabled |
1241 // by the user. | 1258 // by the user. |
1242 std::vector<content::WebPluginInfo> plugins; | 1259 std::vector<content::WebPluginInfo> plugins; |
1243 GetPluginList(&plugins); | 1260 GetPluginList(&plugins); |
1244 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1261 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1245 if (!flash) | 1262 if (!flash) |
1246 return; | 1263 return; |
1247 PluginPrefs* plugin_prefs = | 1264 PluginPrefs* plugin_prefs = |
1248 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1265 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1249 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1266 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1250 | 1267 |
1251 // Disable all plugins. | 1268 // Disable all plugins. |
1252 base::ListValue disabled_plugins; | 1269 base::ListValue disabled_plugins; |
1253 disabled_plugins.Append(base::Value::CreateStringValue("*")); | 1270 disabled_plugins.Append(new base::StringValue("*")); |
1254 PolicyMap policies; | 1271 PolicyMap policies; |
1255 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, | 1272 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, |
1256 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); | 1273 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); |
1257 UpdateProviderPolicy(policies); | 1274 UpdateProviderPolicy(policies); |
1258 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1275 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1259 // The user shouldn't be able to enable it. | 1276 // The user shouldn't be able to enable it. |
1260 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); | 1277 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); |
1261 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1278 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1262 | 1279 |
1263 // Now open an exception for flash. | 1280 // Now open an exception for flash. |
1264 base::ListValue disabled_plugins_exceptions; | 1281 base::ListValue disabled_plugins_exceptions; |
1265 disabled_plugins_exceptions.Append( | 1282 disabled_plugins_exceptions.Append(new base::StringValue("*Flash*")); |
1266 base::Value::CreateStringValue("*Flash*")); | |
1267 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, | 1283 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, |
1268 POLICY_SCOPE_USER, disabled_plugins_exceptions.DeepCopy(), NULL); | 1284 POLICY_SCOPE_USER, disabled_plugins_exceptions.DeepCopy(), NULL); |
1269 UpdateProviderPolicy(policies); | 1285 UpdateProviderPolicy(policies); |
1270 // It should revert to the user's preference automatically. | 1286 // It should revert to the user's preference automatically. |
1271 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1287 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1272 // And the user should be able to disable and enable again. | 1288 // And the user should be able to disable and enable again. |
1273 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1289 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1274 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1290 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1275 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); | 1291 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); |
1276 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1292 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1277 } | 1293 } |
1278 | 1294 |
1279 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { | 1295 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { |
1280 // Verifies that a plugin can be force-installed with a policy. | 1296 // Verifies that a plugin can be force-installed with a policy. |
1281 std::vector<content::WebPluginInfo> plugins; | 1297 std::vector<content::WebPluginInfo> plugins; |
1282 GetPluginList(&plugins); | 1298 GetPluginList(&plugins); |
1283 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); | 1299 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); |
1284 if (!flash) | 1300 if (!flash) |
1285 return; | 1301 return; |
1286 PluginPrefs* plugin_prefs = | 1302 PluginPrefs* plugin_prefs = |
1287 PluginPrefs::GetForProfile(browser()->profile()).get(); | 1303 PluginPrefs::GetForProfile(browser()->profile()).get(); |
1288 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1304 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1289 | 1305 |
1290 // The user disables it and then a policy forces it to be enabled. | 1306 // The user disables it and then a policy forces it to be enabled. |
1291 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); | 1307 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); |
1292 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); | 1308 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); |
1293 base::ListValue plugin_list; | 1309 base::ListValue plugin_list; |
1294 plugin_list.Append(base::Value::CreateStringValue(content::kFlashPluginName)); | 1310 plugin_list.Append(new base::StringValue(content::kFlashPluginName)); |
1295 PolicyMap policies; | 1311 PolicyMap policies; |
1296 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, | 1312 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, |
1297 POLICY_SCOPE_USER, plugin_list.DeepCopy(), NULL); | 1313 POLICY_SCOPE_USER, plugin_list.DeepCopy(), NULL); |
1298 UpdateProviderPolicy(policies); | 1314 UpdateProviderPolicy(policies); |
1299 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1315 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1300 // The user can't disable it anymore. | 1316 // The user can't disable it anymore. |
1301 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); | 1317 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); |
1302 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); | 1318 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); |
1303 | 1319 |
1304 // When a plugin is both enabled and disabled, the whitelist takes precedence. | 1320 // When a plugin is both enabled and disabled, the whitelist takes precedence. |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1436 | 1452 |
1437 // Verify that downloads end up on the default directory. | 1453 // Verify that downloads end up on the default directory. |
1438 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); | 1454 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); |
1439 DownloadAndVerifyFile(browser(), initial_dir.path(), file); | 1455 DownloadAndVerifyFile(browser(), initial_dir.path(), file); |
1440 base::DieFileDie(initial_dir.path().Append(file), false); | 1456 base::DieFileDie(initial_dir.path().Append(file), false); |
1441 | 1457 |
1442 // Override the download directory with the policy and verify a download. | 1458 // Override the download directory with the policy and verify a download. |
1443 base::ScopedTempDir forced_dir; | 1459 base::ScopedTempDir forced_dir; |
1444 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); | 1460 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); |
1445 PolicyMap policies; | 1461 PolicyMap policies; |
1446 policies.Set(key::kDownloadDirectory, POLICY_LEVEL_MANDATORY, | 1462 policies.Set(key::kDownloadDirectory, |
| 1463 POLICY_LEVEL_MANDATORY, |
1447 POLICY_SCOPE_USER, | 1464 POLICY_SCOPE_USER, |
1448 base::Value::CreateStringValue(forced_dir.path().value()), NULL); | 1465 new base::StringValue(forced_dir.path().value()), |
| 1466 NULL); |
1449 UpdateProviderPolicy(policies); | 1467 UpdateProviderPolicy(policies); |
1450 DownloadAndVerifyFile(browser(), forced_dir.path(), file); | 1468 DownloadAndVerifyFile(browser(), forced_dir.path(), file); |
1451 // Verify that the first download location wasn't affected. | 1469 // Verify that the first download location wasn't affected. |
1452 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); | 1470 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); |
1453 } | 1471 } |
1454 | 1472 |
1455 // Flaky: http://crbug.com/388340 | 1473 // Flaky: http://crbug.com/388340 |
1456 IN_PROC_BROWSER_TEST_F(PolicyTest, | 1474 IN_PROC_BROWSER_TEST_F(PolicyTest, |
1457 DISABLED_ExtensionInstallBlacklistSelective) { | 1475 DISABLED_ExtensionInstallBlacklistSelective) { |
1458 // Verifies that blacklisted extensions can't be installed. | 1476 // Verifies that blacklisted extensions can't be installed. |
1459 ExtensionService* service = extension_service(); | 1477 ExtensionService* service = extension_service(); |
1460 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1478 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1461 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1479 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1462 base::ListValue blacklist; | 1480 base::ListValue blacklist; |
1463 blacklist.Append(base::Value::CreateStringValue(kGoodCrxId)); | 1481 blacklist.Append(new base::StringValue(kGoodCrxId)); |
1464 PolicyMap policies; | 1482 PolicyMap policies; |
1465 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1483 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1466 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 1484 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
1467 UpdateProviderPolicy(policies); | 1485 UpdateProviderPolicy(policies); |
1468 | 1486 |
1469 // "good.crx" is blacklisted. | 1487 // "good.crx" is blacklisted. |
1470 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1488 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
1471 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1489 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1472 | 1490 |
1473 // "adblock.crx" is not. | 1491 // "adblock.crx" is not. |
(...skipping 10 matching lines...) Expand all Loading... |
1484 #else | 1502 #else |
1485 #define MAYBE_ExtensionInstallBlacklistWildcard ExtensionInstallBlacklistWildcar
d | 1503 #define MAYBE_ExtensionInstallBlacklistWildcard ExtensionInstallBlacklistWildcar
d |
1486 #endif | 1504 #endif |
1487 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) { | 1505 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) { |
1488 // Verify that a wildcard blacklist takes effect. | 1506 // Verify that a wildcard blacklist takes effect. |
1489 EXPECT_TRUE(InstallExtension(kAdBlockCrxName)); | 1507 EXPECT_TRUE(InstallExtension(kAdBlockCrxName)); |
1490 ExtensionService* service = extension_service(); | 1508 ExtensionService* service = extension_service(); |
1491 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1509 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1492 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true)); | 1510 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true)); |
1493 base::ListValue blacklist; | 1511 base::ListValue blacklist; |
1494 blacklist.Append(base::Value::CreateStringValue("*")); | 1512 blacklist.Append(new base::StringValue("*")); |
1495 PolicyMap policies; | 1513 PolicyMap policies; |
1496 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1514 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1497 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 1515 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
1498 UpdateProviderPolicy(policies); | 1516 UpdateProviderPolicy(policies); |
1499 | 1517 |
1500 // AdBlock was automatically removed. | 1518 // AdBlock was automatically removed. |
1501 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1519 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1502 | 1520 |
1503 // And can't be installed again, nor can good.crx. | 1521 // And can't be installed again, nor can good.crx. |
1504 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); | 1522 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); |
1505 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1523 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1506 EXPECT_FALSE(InstallExtension(kGoodCrxName)); | 1524 EXPECT_FALSE(InstallExtension(kGoodCrxName)); |
1507 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1525 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1508 } | 1526 } |
1509 | 1527 |
1510 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) { | 1528 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) { |
1511 // Verifies that the whitelist can open exceptions to the blacklist. | 1529 // Verifies that the whitelist can open exceptions to the blacklist. |
1512 ExtensionService* service = extension_service(); | 1530 ExtensionService* service = extension_service(); |
1513 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); | 1531 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); |
1514 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1532 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1515 base::ListValue blacklist; | 1533 base::ListValue blacklist; |
1516 blacklist.Append(base::Value::CreateStringValue("*")); | 1534 blacklist.Append(new base::StringValue("*")); |
1517 base::ListValue whitelist; | 1535 base::ListValue whitelist; |
1518 whitelist.Append(base::Value::CreateStringValue(kGoodCrxId)); | 1536 whitelist.Append(new base::StringValue(kGoodCrxId)); |
1519 PolicyMap policies; | 1537 PolicyMap policies; |
1520 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, | 1538 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, |
1521 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 1539 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
1522 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY, | 1540 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY, |
1523 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); | 1541 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); |
1524 UpdateProviderPolicy(policies); | 1542 UpdateProviderPolicy(policies); |
1525 // "adblock.crx" is blacklisted. | 1543 // "adblock.crx" is blacklisted. |
1526 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); | 1544 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); |
1527 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); | 1545 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); |
1528 // "good.crx" has a whitelist exception. | 1546 // "good.crx" has a whitelist exception. |
(...skipping 13 matching lines...) Expand all Loading... |
1542 | 1560 |
1543 // Extensions that are force-installed come from an update URL, which defaults | 1561 // Extensions that are force-installed come from an update URL, which defaults |
1544 // to the webstore. Use a mock URL for this test with an update manifest | 1562 // to the webstore. Use a mock URL for this test with an update manifest |
1545 // that includes "good_v1.crx". | 1563 // that includes "good_v1.crx". |
1546 base::FilePath path = | 1564 base::FilePath path = |
1547 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); | 1565 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); |
1548 GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); | 1566 GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); |
1549 | 1567 |
1550 // Setting the forcelist extension should install "good_v1.crx". | 1568 // Setting the forcelist extension should install "good_v1.crx". |
1551 base::ListValue forcelist; | 1569 base::ListValue forcelist; |
1552 forcelist.Append(base::Value::CreateStringValue(base::StringPrintf( | 1570 forcelist.Append(new base::StringValue( |
1553 "%s;%s", kGoodCrxId, url.spec().c_str()))); | 1571 base::StringPrintf("%s;%s", kGoodCrxId, url.spec().c_str()))); |
1554 PolicyMap policies; | 1572 PolicyMap policies; |
1555 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, | 1573 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, |
1556 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); | 1574 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); |
1557 content::WindowedNotificationObserver observer( | 1575 content::WindowedNotificationObserver observer( |
1558 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, | 1576 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, |
1559 content::NotificationService::AllSources()); | 1577 content::NotificationService::AllSources()); |
1560 UpdateProviderPolicy(policies); | 1578 UpdateProviderPolicy(policies); |
1561 observer.Wait(); | 1579 observer.Wait(); |
1562 // Note: Cannot check that the notification details match the expected | 1580 // Note: Cannot check that the notification details match the expected |
1563 // exception, since the details object has already been freed prior to | 1581 // exception, since the details object has already been freed prior to |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1752 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), | 1770 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), |
1753 browser()->profile()->GetHomePage()); | 1771 browser()->profile()->GetHomePage()); |
1754 content::WebContents* contents = | 1772 content::WebContents* contents = |
1755 browser()->tab_strip_model()->GetActiveWebContents(); | 1773 browser()->tab_strip_model()->GetActiveWebContents(); |
1756 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); | 1774 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); |
1757 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1775 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
1758 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); | 1776 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); |
1759 | 1777 |
1760 // Now override with policy. | 1778 // Now override with policy. |
1761 PolicyMap policies; | 1779 PolicyMap policies; |
1762 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, | 1780 policies.Set(key::kHomepageLocation, |
| 1781 POLICY_LEVEL_MANDATORY, |
1763 POLICY_SCOPE_USER, | 1782 POLICY_SCOPE_USER, |
1764 base::Value::CreateStringValue(chrome::kChromeUICreditsURL), | 1783 new base::StringValue(chrome::kChromeUICreditsURL), |
1765 NULL); | 1784 NULL); |
1766 UpdateProviderPolicy(policies); | 1785 UpdateProviderPolicy(policies); |
1767 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1786 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
1768 content::WaitForLoadStop(contents); | 1787 content::WaitForLoadStop(contents); |
1769 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); | 1788 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); |
1770 | 1789 |
1771 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, | 1790 policies.Set(key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, |
1772 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); | 1791 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); |
1773 UpdateProviderPolicy(policies); | 1792 UpdateProviderPolicy(policies); |
1774 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); | 1793 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1958 base::Bind(RedirectHostsToTestData, kURLS, arraysize(kURLS)), | 1977 base::Bind(RedirectHostsToTestData, kURLS, arraysize(kURLS)), |
1959 loop.QuitClosure()); | 1978 loop.QuitClosure()); |
1960 loop.Run(); | 1979 loop.Run(); |
1961 } | 1980 } |
1962 | 1981 |
1963 // Verify that "bbb.com" opens before applying the blacklist. | 1982 // Verify that "bbb.com" opens before applying the blacklist. |
1964 CheckCanOpenURL(browser(), kURLS[1]); | 1983 CheckCanOpenURL(browser(), kURLS[1]); |
1965 | 1984 |
1966 // Set a blacklist. | 1985 // Set a blacklist. |
1967 base::ListValue blacklist; | 1986 base::ListValue blacklist; |
1968 blacklist.Append(base::Value::CreateStringValue("bbb.com")); | 1987 blacklist.Append(new base::StringValue("bbb.com")); |
1969 PolicyMap policies; | 1988 PolicyMap policies; |
1970 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 1989 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
1971 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 1990 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
1972 UpdateProviderPolicy(policies); | 1991 UpdateProviderPolicy(policies); |
1973 FlushBlacklistPolicy(); | 1992 FlushBlacklistPolicy(); |
1974 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked. | 1993 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked. |
1975 CheckCanOpenURL(browser(), kURLS[0]); | 1994 CheckCanOpenURL(browser(), kURLS[0]); |
1976 for (size_t i = 1; i < arraysize(kURLS); ++i) | 1995 for (size_t i = 1; i < arraysize(kURLS); ++i) |
1977 CheckURLIsBlocked(browser(), kURLS[i]); | 1996 CheckURLIsBlocked(browser(), kURLS[i]); |
1978 | 1997 |
1979 // Whitelist some sites of bbb.com. | 1998 // Whitelist some sites of bbb.com. |
1980 base::ListValue whitelist; | 1999 base::ListValue whitelist; |
1981 whitelist.Append(base::Value::CreateStringValue("sub.bbb.com")); | 2000 whitelist.Append(new base::StringValue("sub.bbb.com")); |
1982 whitelist.Append(base::Value::CreateStringValue("bbb.com/policy")); | 2001 whitelist.Append(new base::StringValue("bbb.com/policy")); |
1983 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, | 2002 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, |
1984 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); | 2003 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); |
1985 UpdateProviderPolicy(policies); | 2004 UpdateProviderPolicy(policies); |
1986 FlushBlacklistPolicy(); | 2005 FlushBlacklistPolicy(); |
1987 CheckURLIsBlocked(browser(), kURLS[1]); | 2006 CheckURLIsBlocked(browser(), kURLS[1]); |
1988 CheckCanOpenURL(browser(), kURLS[2]); | 2007 CheckCanOpenURL(browser(), kURLS[2]); |
1989 CheckCanOpenURL(browser(), kURLS[3]); | 2008 CheckCanOpenURL(browser(), kURLS[3]); |
1990 | 2009 |
1991 { | 2010 { |
1992 base::RunLoop loop; | 2011 base::RunLoop loop; |
(...skipping 15 matching lines...) Expand all Loading... |
2008 const std::string base_path = "file://" + test_path.AsUTF8Unsafe() +"/"; | 2027 const std::string base_path = "file://" + test_path.AsUTF8Unsafe() +"/"; |
2009 const std::string folder_path = base_path + "apptest/"; | 2028 const std::string folder_path = base_path + "apptest/"; |
2010 const std::string file_path1 = base_path + "title1.html"; | 2029 const std::string file_path1 = base_path + "title1.html"; |
2011 const std::string file_path2 = folder_path + "basic.html"; | 2030 const std::string file_path2 = folder_path + "basic.html"; |
2012 | 2031 |
2013 CheckCanOpenURL(browser(), file_path1.c_str()); | 2032 CheckCanOpenURL(browser(), file_path1.c_str()); |
2014 CheckCanOpenURL(browser(), file_path2.c_str()); | 2033 CheckCanOpenURL(browser(), file_path2.c_str()); |
2015 | 2034 |
2016 // Set a blacklist for all the files. | 2035 // Set a blacklist for all the files. |
2017 base::ListValue blacklist; | 2036 base::ListValue blacklist; |
2018 blacklist.Append(base::Value::CreateStringValue("file://*")); | 2037 blacklist.Append(new base::StringValue("file://*")); |
2019 PolicyMap policies; | 2038 PolicyMap policies; |
2020 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2039 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
2021 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2040 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
2022 UpdateProviderPolicy(policies); | 2041 UpdateProviderPolicy(policies); |
2023 FlushBlacklistPolicy(); | 2042 FlushBlacklistPolicy(); |
2024 | 2043 |
2025 CheckURLIsBlocked(browser(), file_path1.c_str()); | 2044 CheckURLIsBlocked(browser(), file_path1.c_str()); |
2026 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2045 CheckURLIsBlocked(browser(), file_path2.c_str()); |
2027 | 2046 |
2028 // Replace the URLblacklist with disabling the file scheme. | 2047 // Replace the URLblacklist with disabling the file scheme. |
2029 blacklist.Remove(base::StringValue("file://*"), NULL); | 2048 blacklist.Remove(base::StringValue("file://*"), NULL); |
2030 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2049 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
2031 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2050 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
2032 UpdateProviderPolicy(policies); | 2051 UpdateProviderPolicy(policies); |
2033 FlushBlacklistPolicy(); | 2052 FlushBlacklistPolicy(); |
2034 | 2053 |
2035 PrefService* prefs = browser()->profile()->GetPrefs(); | 2054 PrefService* prefs = browser()->profile()->GetPrefs(); |
2036 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist); | 2055 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist); |
2037 EXPECT_EQ(list_url->Find(base::StringValue("file://*")), | 2056 EXPECT_EQ(list_url->Find(base::StringValue("file://*")), |
2038 list_url->end()); | 2057 list_url->end()); |
2039 | 2058 |
2040 base::ListValue disabledscheme; | 2059 base::ListValue disabledscheme; |
2041 disabledscheme.Append(base::Value::CreateStringValue("file")); | 2060 disabledscheme.Append(new base::StringValue("file")); |
2042 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY, | 2061 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY, |
2043 POLICY_SCOPE_USER, disabledscheme.DeepCopy(), NULL); | 2062 POLICY_SCOPE_USER, disabledscheme.DeepCopy(), NULL); |
2044 UpdateProviderPolicy(policies); | 2063 UpdateProviderPolicy(policies); |
2045 FlushBlacklistPolicy(); | 2064 FlushBlacklistPolicy(); |
2046 | 2065 |
2047 list_url = prefs->GetList(policy_prefs::kUrlBlacklist); | 2066 list_url = prefs->GetList(policy_prefs::kUrlBlacklist); |
2048 EXPECT_NE(list_url->Find(base::StringValue("file://*")), | 2067 EXPECT_NE(list_url->Find(base::StringValue("file://*")), |
2049 list_url->end()); | 2068 list_url->end()); |
2050 | 2069 |
2051 // Whitelist one folder and blacklist an another just inside. | 2070 // Whitelist one folder and blacklist an another just inside. |
2052 base::ListValue whitelist; | 2071 base::ListValue whitelist; |
2053 whitelist.Append(base::Value::CreateStringValue(base_path)); | 2072 whitelist.Append(new base::StringValue(base_path)); |
2054 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, | 2073 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, |
2055 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); | 2074 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); |
2056 blacklist.Append(base::Value::CreateStringValue(folder_path)); | 2075 blacklist.Append(new base::StringValue(folder_path)); |
2057 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, | 2076 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, |
2058 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2077 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
2059 UpdateProviderPolicy(policies); | 2078 UpdateProviderPolicy(policies); |
2060 FlushBlacklistPolicy(); | 2079 FlushBlacklistPolicy(); |
2061 | 2080 |
2062 CheckCanOpenURL(browser(), file_path1.c_str()); | 2081 CheckCanOpenURL(browser(), file_path1.c_str()); |
2063 CheckURLIsBlocked(browser(), file_path2.c_str()); | 2082 CheckURLIsBlocked(browser(), file_path2.c_str()); |
2064 } | 2083 } |
2065 | 2084 |
2066 #if !defined(OS_MACOSX) | 2085 #if !defined(OS_MACOSX) |
(...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2536 // the homepage is not the NTP. | 2555 // the homepage is not the NTP. |
2537 PolicyMap policies; | 2556 PolicyMap policies; |
2538 policies.Set( | 2557 policies.Set( |
2539 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2558 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2540 base::Value::CreateIntegerValue( | 2559 base::Value::CreateIntegerValue( |
2541 SessionStartupPref::kPrefValueHomePage), | 2560 SessionStartupPref::kPrefValueHomePage), |
2542 NULL); | 2561 NULL); |
2543 policies.Set( | 2562 policies.Set( |
2544 key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2563 key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2545 base::Value::CreateBooleanValue(false), NULL); | 2564 base::Value::CreateBooleanValue(false), NULL); |
2546 policies.Set( | 2565 policies.Set(key::kHomepageLocation, |
2547 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2566 POLICY_LEVEL_MANDATORY, |
2548 base::Value::CreateStringValue(kRestoredURLs[1]), NULL); | 2567 POLICY_SCOPE_USER, |
| 2568 new base::StringValue(kRestoredURLs[1]), |
| 2569 NULL); |
2549 provider_.UpdateChromePolicy(policies); | 2570 provider_.UpdateChromePolicy(policies); |
2550 | 2571 |
2551 expected_urls_.push_back(GURL(kRestoredURLs[1])); | 2572 expected_urls_.push_back(GURL(kRestoredURLs[1])); |
2552 } | 2573 } |
2553 | 2574 |
2554 void HomepageIsNTP() { | 2575 void HomepageIsNTP() { |
2555 // Verifies that policy can set the startup pages to the homepage, when | 2576 // Verifies that policy can set the startup pages to the homepage, when |
2556 // the homepage is the NTP. | 2577 // the homepage is the NTP. |
2557 PolicyMap policies; | 2578 PolicyMap policies; |
2558 policies.Set( | 2579 policies.Set( |
2559 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2580 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2560 base::Value::CreateIntegerValue( | 2581 base::Value::CreateIntegerValue( |
2561 SessionStartupPref::kPrefValueHomePage), | 2582 SessionStartupPref::kPrefValueHomePage), |
2562 NULL); | 2583 NULL); |
2563 policies.Set( | 2584 policies.Set( |
2564 key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2585 key::kHomepageIsNewTabPage, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2565 base::Value::CreateBooleanValue(true), NULL); | 2586 base::Value::CreateBooleanValue(true), NULL); |
2566 provider_.UpdateChromePolicy(policies); | 2587 provider_.UpdateChromePolicy(policies); |
2567 | 2588 |
2568 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); | 2589 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); |
2569 } | 2590 } |
2570 | 2591 |
2571 void ListOfURLs() { | 2592 void ListOfURLs() { |
2572 // Verifies that policy can set the startup pages to a list of URLs. | 2593 // Verifies that policy can set the startup pages to a list of URLs. |
2573 base::ListValue urls; | 2594 base::ListValue urls; |
2574 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { | 2595 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { |
2575 urls.Append(base::Value::CreateStringValue(kRestoredURLs[i])); | 2596 urls.Append(new base::StringValue(kRestoredURLs[i])); |
2576 expected_urls_.push_back(GURL(kRestoredURLs[i])); | 2597 expected_urls_.push_back(GURL(kRestoredURLs[i])); |
2577 } | 2598 } |
2578 PolicyMap policies; | 2599 PolicyMap policies; |
2579 policies.Set( | 2600 policies.Set( |
2580 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2601 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2581 base::Value::CreateIntegerValue(SessionStartupPref::kPrefValueURLs), | 2602 base::Value::CreateIntegerValue(SessionStartupPref::kPrefValueURLs), |
2582 NULL); | 2603 NULL); |
2583 policies.Set( | 2604 policies.Set( |
2584 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2605 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2585 urls.DeepCopy(), NULL); | 2606 urls.DeepCopy(), NULL); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2661 | 2682 |
2662 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 2683 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
2663 PolicyTest::SetUpInProcessBrowserTestFixture(); | 2684 PolicyTest::SetUpInProcessBrowserTestFixture(); |
2664 PolicyMap policies; | 2685 PolicyMap policies; |
2665 policies.Set( | 2686 policies.Set( |
2666 key::kShowHomeButton, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2687 key::kShowHomeButton, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2667 base::Value::CreateBooleanValue(true), NULL); | 2688 base::Value::CreateBooleanValue(true), NULL); |
2668 policies.Set( | 2689 policies.Set( |
2669 key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2690 key::kBookmarkBarEnabled, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, |
2670 base::Value::CreateBooleanValue(false), NULL); | 2691 base::Value::CreateBooleanValue(false), NULL); |
2671 policies.Set( | 2692 policies.Set(key::kHomepageLocation, |
2672 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, | 2693 POLICY_LEVEL_MANDATORY, |
2673 base::Value::CreateStringValue("http://chromium.org"), NULL); | 2694 POLICY_SCOPE_USER, |
| 2695 new base::StringValue("http://chromium.org"), |
| 2696 NULL); |
2674 provider_.UpdateChromePolicy(policies); | 2697 provider_.UpdateChromePolicy(policies); |
2675 } | 2698 } |
2676 }; | 2699 }; |
2677 | 2700 |
2678 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { | 2701 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { |
2679 // Verifies that policy usage histograms are collected at startup. | 2702 // Verifies that policy usage histograms are collected at startup. |
2680 | 2703 |
2681 // BrowserPolicyConnector::Init() has already been called. Make sure the | 2704 // BrowserPolicyConnector::Init() has already been called. Make sure the |
2682 // CompleteInitialization() task has executed as well. | 2705 // CompleteInitialization() task has executed as well. |
2683 content::RunAllPendingInMessageLoop(); | 2706 content::RunAllPendingInMessageLoop(); |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2936 testing::Bool()); | 2959 testing::Bool()); |
2937 | 2960 |
2938 #if !defined(OS_CHROMEOS) | 2961 #if !defined(OS_CHROMEOS) |
2939 // Similar to PolicyTest but sets the proper policy before the browser is | 2962 // Similar to PolicyTest but sets the proper policy before the browser is |
2940 // started. | 2963 // started. |
2941 class PolicyVariationsServiceTest : public PolicyTest { | 2964 class PolicyVariationsServiceTest : public PolicyTest { |
2942 public: | 2965 public: |
2943 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 2966 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
2944 PolicyTest::SetUpInProcessBrowserTestFixture(); | 2967 PolicyTest::SetUpInProcessBrowserTestFixture(); |
2945 PolicyMap policies; | 2968 PolicyMap policies; |
2946 policies.Set( | 2969 policies.Set(key::kVariationsRestrictParameter, |
2947 key::kVariationsRestrictParameter, | 2970 POLICY_LEVEL_MANDATORY, |
2948 POLICY_LEVEL_MANDATORY, | 2971 POLICY_SCOPE_USER, |
2949 POLICY_SCOPE_USER, | 2972 new base::StringValue("restricted"), |
2950 base::Value::CreateStringValue("restricted"), | 2973 NULL); |
2951 NULL); | |
2952 provider_.UpdateChromePolicy(policies); | 2974 provider_.UpdateChromePolicy(policies); |
2953 } | 2975 } |
2954 }; | 2976 }; |
2955 | 2977 |
2956 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) { | 2978 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) { |
2957 const std::string default_variations_url = | 2979 const std::string default_variations_url = |
2958 chrome_variations::VariationsService:: | 2980 chrome_variations::VariationsService:: |
2959 GetDefaultVariationsServerURLForTesting(); | 2981 GetDefaultVariationsServerURLForTesting(); |
2960 | 2982 |
2961 const GURL url = | 2983 const GURL url = |
2962 chrome_variations::VariationsService::GetVariationsServerURL( | 2984 chrome_variations::VariationsService::GetVariationsServerURL( |
2963 g_browser_process->local_state()); | 2985 g_browser_process->local_state()); |
2964 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); | 2986 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); |
2965 std::string value; | 2987 std::string value; |
2966 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 2988 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
2967 EXPECT_EQ("restricted", value); | 2989 EXPECT_EQ("restricted", value); |
2968 } | 2990 } |
2969 | 2991 |
2970 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { | 2992 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { |
2971 base::ListValue blacklist; | 2993 base::ListValue blacklist; |
2972 blacklist.Append(base::Value::CreateStringValue("host.name")); | 2994 blacklist.Append(new base::StringValue("host.name")); |
2973 PolicyMap policies; | 2995 PolicyMap policies; |
2974 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 2996 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
2975 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 2997 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
2976 UpdateProviderPolicy(policies); | 2998 UpdateProviderPolicy(policies); |
2977 | 2999 |
2978 PrefService* prefs = browser()->profile()->GetPrefs(); | 3000 PrefService* prefs = browser()->profile()->GetPrefs(); |
2979 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( | 3001 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
2980 prefs, "host.name")); | 3002 prefs, "host.name")); |
2981 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( | 3003 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( |
2982 prefs, "other.host.name")); | 3004 prefs, "other.host.name")); |
2983 } | 3005 } |
2984 | 3006 |
2985 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { | 3007 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { |
2986 base::ListValue blacklist; | 3008 base::ListValue blacklist; |
2987 blacklist.Append(base::Value::CreateStringValue("*")); | 3009 blacklist.Append(new base::StringValue("*")); |
2988 PolicyMap policies; | 3010 PolicyMap policies; |
2989 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 3011 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
2990 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 3012 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
2991 UpdateProviderPolicy(policies); | 3013 UpdateProviderPolicy(policies); |
2992 | 3014 |
2993 PrefService* prefs = browser()->profile()->GetPrefs(); | 3015 PrefService* prefs = browser()->profile()->GetPrefs(); |
2994 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( | 3016 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
2995 prefs, "host.name")); | 3017 prefs, "host.name")); |
2996 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( | 3018 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( |
2997 prefs, "other.host.name")); | 3019 prefs, "other.host.name")); |
2998 } | 3020 } |
2999 | 3021 |
3000 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { | 3022 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { |
3001 base::ListValue blacklist; | 3023 base::ListValue blacklist; |
3002 blacklist.Append(base::Value::CreateStringValue("*")); | 3024 blacklist.Append(new base::StringValue("*")); |
3003 base::ListValue whitelist; | 3025 base::ListValue whitelist; |
3004 whitelist.Append(base::Value::CreateStringValue("host.name")); | 3026 whitelist.Append(new base::StringValue("host.name")); |
3005 PolicyMap policies; | 3027 PolicyMap policies; |
3006 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, | 3028 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, |
3007 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); | 3029 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); |
3008 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, | 3030 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, |
3009 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); | 3031 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); |
3010 UpdateProviderPolicy(policies); | 3032 UpdateProviderPolicy(policies); |
3011 | 3033 |
3012 PrefService* prefs = browser()->profile()->GetPrefs(); | 3034 PrefService* prefs = browser()->profile()->GetPrefs(); |
3013 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( | 3035 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( |
3014 prefs, "host.name")); | 3036 prefs, "host.name")); |
(...skipping 22 matching lines...) Expand all Loading... |
3037 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 3059 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
3038 browser2->tab_strip_model()->GetActiveWebContents(), | 3060 browser2->tab_strip_model()->GetActiveWebContents(), |
3039 "domAutomationController.send(window.showModalDialog !== undefined);", | 3061 "domAutomationController.send(window.showModalDialog !== undefined);", |
3040 &result)); | 3062 &result)); |
3041 EXPECT_TRUE(result); | 3063 EXPECT_TRUE(result); |
3042 } | 3064 } |
3043 | 3065 |
3044 #endif // !defined(CHROME_OS) | 3066 #endif // !defined(CHROME_OS) |
3045 | 3067 |
3046 } // namespace policy | 3068 } // namespace policy |
OLD | NEW |