Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(293)

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 388963002: Get rid of the rest of CreateStringValue (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bad rebase Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 746
747 // Sets the locale policy before the browser is started. 747 // Sets the locale policy before the browser is started.
748 class LocalePolicyTest : public PolicyTest { 748 class LocalePolicyTest : public PolicyTest {
749 public: 749 public:
750 LocalePolicyTest() {} 750 LocalePolicyTest() {}
751 virtual ~LocalePolicyTest() {} 751 virtual ~LocalePolicyTest() {}
752 752
753 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 753 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
754 PolicyTest::SetUpInProcessBrowserTestFixture(); 754 PolicyTest::SetUpInProcessBrowserTestFixture();
755 PolicyMap policies; 755 PolicyMap policies;
756 policies.Set( 756 policies.Set(key::kApplicationLocaleValue,
757 key::kApplicationLocaleValue, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 757 POLICY_LEVEL_MANDATORY,
758 base::Value::CreateStringValue("fr"), NULL); 758 POLICY_SCOPE_USER,
759 new base::StringValue("fr"),
760 NULL);
759 provider_.UpdateChromePolicy(policies); 761 provider_.UpdateChromePolicy(policies);
760 // The "en-US" ResourceBundle is always loaded before this step for tests, 762 // The "en-US" ResourceBundle is always loaded before this step for tests,
761 // but in this test we want the browser to load the bundle as it 763 // but in this test we want the browser to load the bundle as it
762 // normally would. 764 // normally would.
763 ResourceBundle::CleanupSharedInstance(); 765 ResourceBundle::CleanupSharedInstance();
764 } 766 }
765 }; 767 };
766 768
767 IN_PROC_BROWSER_TEST_F(LocalePolicyTest, ApplicationLocaleValue) { 769 IN_PROC_BROWSER_TEST_F(LocalePolicyTest, ApplicationLocaleValue) {
768 // Verifies that the default locale can be overridden with policy. 770 // Verifies that the default locale can be overridden with policy.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 default_search->new_tab_url() == kNewTabURL); 897 default_search->new_tab_url() == kNewTabURL);
896 898
897 // Override the default search provider using policies. 899 // Override the default search provider using policies.
898 PolicyMap policies; 900 PolicyMap policies;
899 policies.Set(key::kDefaultSearchProviderEnabled, 901 policies.Set(key::kDefaultSearchProviderEnabled,
900 POLICY_LEVEL_MANDATORY, 902 POLICY_LEVEL_MANDATORY,
901 POLICY_SCOPE_USER, 903 POLICY_SCOPE_USER,
902 new base::FundamentalValue(true), 904 new base::FundamentalValue(true),
903 NULL); 905 NULL);
904 policies.Set(key::kDefaultSearchProviderKeyword, 906 policies.Set(key::kDefaultSearchProviderKeyword,
905 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 907 POLICY_LEVEL_MANDATORY,
906 base::Value::CreateStringValue(kKeyword), NULL); 908 POLICY_SCOPE_USER,
909 new base::StringValue(kKeyword),
910 NULL);
907 policies.Set(key::kDefaultSearchProviderSearchURL, 911 policies.Set(key::kDefaultSearchProviderSearchURL,
908 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 912 POLICY_LEVEL_MANDATORY,
909 base::Value::CreateStringValue(kSearchURL), NULL); 913 POLICY_SCOPE_USER,
914 new base::StringValue(kSearchURL),
915 NULL);
910 base::ListValue* alternate_urls = new base::ListValue(); 916 base::ListValue* alternate_urls = new base::ListValue();
911 alternate_urls->AppendString(kAlternateURL0); 917 alternate_urls->AppendString(kAlternateURL0);
912 alternate_urls->AppendString(kAlternateURL1); 918 alternate_urls->AppendString(kAlternateURL1);
913 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, 919 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
914 POLICY_SCOPE_USER, alternate_urls, NULL); 920 POLICY_SCOPE_USER, alternate_urls, NULL);
915 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, 921 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey,
916 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 922 POLICY_LEVEL_MANDATORY,
917 base::Value::CreateStringValue(kSearchTermsReplacementKey), 923 POLICY_SCOPE_USER,
924 new base::StringValue(kSearchTermsReplacementKey),
918 NULL); 925 NULL);
919 policies.Set(key::kDefaultSearchProviderImageURL, 926 policies.Set(key::kDefaultSearchProviderImageURL,
920 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 927 POLICY_LEVEL_MANDATORY,
921 base::Value::CreateStringValue(kImageURL), 928 POLICY_SCOPE_USER,
929 new base::StringValue(kImageURL),
922 NULL); 930 NULL);
923 policies.Set(key::kDefaultSearchProviderImageURLPostParams, 931 policies.Set(key::kDefaultSearchProviderImageURLPostParams,
924 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 932 POLICY_LEVEL_MANDATORY,
925 base::Value::CreateStringValue(kImageURLPostParams), 933 POLICY_SCOPE_USER,
934 new base::StringValue(kImageURLPostParams),
926 NULL); 935 NULL);
927 policies.Set(key::kDefaultSearchProviderNewTabURL, 936 policies.Set(key::kDefaultSearchProviderNewTabURL,
928 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 937 POLICY_LEVEL_MANDATORY,
929 base::Value::CreateStringValue(kNewTabURL), 938 POLICY_SCOPE_USER,
939 new base::StringValue(kNewTabURL),
930 NULL); 940 NULL);
931 UpdateProviderPolicy(policies); 941 UpdateProviderPolicy(policies);
932 default_search = service->GetDefaultSearchProvider(); 942 default_search = service->GetDefaultSearchProvider();
933 ASSERT_TRUE(default_search); 943 ASSERT_TRUE(default_search);
934 EXPECT_EQ(kKeyword, default_search->keyword()); 944 EXPECT_EQ(kKeyword, default_search->keyword());
935 EXPECT_EQ(kSearchURL, default_search->url()); 945 EXPECT_EQ(kSearchURL, default_search->url());
936 EXPECT_EQ(2U, default_search->alternate_urls().size()); 946 EXPECT_EQ(2U, default_search->alternate_urls().size());
937 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); 947 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]);
938 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); 948 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]);
939 EXPECT_EQ(kSearchTermsReplacementKey, 949 EXPECT_EQ(kSearchTermsReplacementKey,
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1089 default_search->alternate_urls()[1] == kAlternateURL1); 1099 default_search->alternate_urls()[1] == kAlternateURL1);
1090 1100
1091 // Override the default search provider using policies. 1101 // Override the default search provider using policies.
1092 PolicyMap policies; 1102 PolicyMap policies;
1093 policies.Set(key::kDefaultSearchProviderEnabled, 1103 policies.Set(key::kDefaultSearchProviderEnabled,
1094 POLICY_LEVEL_MANDATORY, 1104 POLICY_LEVEL_MANDATORY,
1095 POLICY_SCOPE_USER, 1105 POLICY_SCOPE_USER,
1096 new base::FundamentalValue(true), 1106 new base::FundamentalValue(true),
1097 NULL); 1107 NULL);
1098 policies.Set(key::kDefaultSearchProviderKeyword, 1108 policies.Set(key::kDefaultSearchProviderKeyword,
1099 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 1109 POLICY_LEVEL_MANDATORY,
1100 base::Value::CreateStringValue(kKeyword), NULL); 1110 POLICY_SCOPE_USER,
1111 new base::StringValue(kKeyword),
1112 NULL);
1101 policies.Set(key::kDefaultSearchProviderSearchURL, 1113 policies.Set(key::kDefaultSearchProviderSearchURL,
1102 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 1114 POLICY_LEVEL_MANDATORY,
1103 base::Value::CreateStringValue(kSearchURL), NULL); 1115 POLICY_SCOPE_USER,
1116 new base::StringValue(kSearchURL),
1117 NULL);
1104 policies.Set(key::kDefaultSearchProviderInstantURL, 1118 policies.Set(key::kDefaultSearchProviderInstantURL,
1105 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 1119 POLICY_LEVEL_MANDATORY,
1106 base::Value::CreateStringValue(kInstantURL), NULL); 1120 POLICY_SCOPE_USER,
1121 new base::StringValue(kInstantURL),
1122 NULL);
1107 base::ListValue* alternate_urls = new base::ListValue(); 1123 base::ListValue* alternate_urls = new base::ListValue();
1108 alternate_urls->AppendString(kAlternateURL0); 1124 alternate_urls->AppendString(kAlternateURL0);
1109 alternate_urls->AppendString(kAlternateURL1); 1125 alternate_urls->AppendString(kAlternateURL1);
1110 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY, 1126 policies.Set(key::kDefaultSearchProviderAlternateURLs, POLICY_LEVEL_MANDATORY,
1111 POLICY_SCOPE_USER, alternate_urls, NULL); 1127 POLICY_SCOPE_USER, alternate_urls, NULL);
1112 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey, 1128 policies.Set(key::kDefaultSearchProviderSearchTermsReplacementKey,
1113 POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 1129 POLICY_LEVEL_MANDATORY,
1114 base::Value::CreateStringValue(kSearchTermsReplacementKey), 1130 POLICY_SCOPE_USER,
1131 new base::StringValue(kSearchTermsReplacementKey),
1115 NULL); 1132 NULL);
1116 UpdateProviderPolicy(policies); 1133 UpdateProviderPolicy(policies);
1117 default_search = service->GetDefaultSearchProvider(); 1134 default_search = service->GetDefaultSearchProvider();
1118 ASSERT_TRUE(default_search); 1135 ASSERT_TRUE(default_search);
1119 EXPECT_EQ(kKeyword, default_search->keyword()); 1136 EXPECT_EQ(kKeyword, default_search->keyword());
1120 EXPECT_EQ(kSearchURL, default_search->url()); 1137 EXPECT_EQ(kSearchURL, default_search->url());
1121 EXPECT_EQ(kInstantURL, default_search->instant_url()); 1138 EXPECT_EQ(kInstantURL, default_search->instant_url());
1122 EXPECT_EQ(2U, default_search->alternate_urls().size()); 1139 EXPECT_EQ(2U, default_search->alternate_urls().size());
1123 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]); 1140 EXPECT_EQ(kAlternateURL0, default_search->alternate_urls()[0]);
1124 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]); 1141 EXPECT_EQ(kAlternateURL1, default_search->alternate_urls()[1]);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
1248 PluginPrefs* plugin_prefs = 1265 PluginPrefs* plugin_prefs =
1249 PluginPrefs::GetForProfile(browser()->profile()).get(); 1266 PluginPrefs::GetForProfile(browser()->profile()).get();
1250 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1267 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1251 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); 1268 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false));
1252 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1269 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1253 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); 1270 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true));
1254 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1271 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1255 1272
1256 // Now disable it with a policy. 1273 // Now disable it with a policy.
1257 base::ListValue disabled_plugins; 1274 base::ListValue disabled_plugins;
1258 disabled_plugins.Append(base::Value::CreateStringValue("*Flash*")); 1275 disabled_plugins.Append(new base::StringValue("*Flash*"));
1259 PolicyMap policies; 1276 PolicyMap policies;
1260 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, 1277 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY,
1261 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); 1278 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL);
1262 UpdateProviderPolicy(policies); 1279 UpdateProviderPolicy(policies);
1263 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1280 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1264 // The user shouldn't be able to enable it. 1281 // The user shouldn't be able to enable it.
1265 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); 1282 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true));
1266 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1283 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1267 } 1284 }
1268 1285
1269 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) { 1286 IN_PROC_BROWSER_TEST_F(PolicyTest, DisabledPluginsExceptions) {
1270 // Verifies that plugins with an exception in the blacklist can be enabled. 1287 // Verifies that plugins with an exception in the blacklist can be enabled.
1271 1288
1272 // Verify that the Flash plugin exists and that it can be enabled and disabled 1289 // Verify that the Flash plugin exists and that it can be enabled and disabled
1273 // by the user. 1290 // by the user.
1274 std::vector<content::WebPluginInfo> plugins; 1291 std::vector<content::WebPluginInfo> plugins;
1275 GetPluginList(&plugins); 1292 GetPluginList(&plugins);
1276 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); 1293 const content::WebPluginInfo* flash = GetFlashPlugin(plugins);
1277 if (!flash) 1294 if (!flash)
1278 return; 1295 return;
1279 PluginPrefs* plugin_prefs = 1296 PluginPrefs* plugin_prefs =
1280 PluginPrefs::GetForProfile(browser()->profile()).get(); 1297 PluginPrefs::GetForProfile(browser()->profile()).get();
1281 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1298 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1282 1299
1283 // Disable all plugins. 1300 // Disable all plugins.
1284 base::ListValue disabled_plugins; 1301 base::ListValue disabled_plugins;
1285 disabled_plugins.Append(base::Value::CreateStringValue("*")); 1302 disabled_plugins.Append(new base::StringValue("*"));
1286 PolicyMap policies; 1303 PolicyMap policies;
1287 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY, 1304 policies.Set(key::kDisabledPlugins, POLICY_LEVEL_MANDATORY,
1288 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL); 1305 POLICY_SCOPE_USER, disabled_plugins.DeepCopy(), NULL);
1289 UpdateProviderPolicy(policies); 1306 UpdateProviderPolicy(policies);
1290 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1307 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1291 // The user shouldn't be able to enable it. 1308 // The user shouldn't be able to enable it.
1292 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true)); 1309 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, true));
1293 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1310 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1294 1311
1295 // Now open an exception for flash. 1312 // Now open an exception for flash.
1296 base::ListValue disabled_plugins_exceptions; 1313 base::ListValue disabled_plugins_exceptions;
1297 disabled_plugins_exceptions.Append( 1314 disabled_plugins_exceptions.Append(new base::StringValue("*Flash*"));
1298 base::Value::CreateStringValue("*Flash*"));
1299 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY, 1315 policies.Set(key::kDisabledPluginsExceptions, POLICY_LEVEL_MANDATORY,
1300 POLICY_SCOPE_USER, disabled_plugins_exceptions.DeepCopy(), NULL); 1316 POLICY_SCOPE_USER, disabled_plugins_exceptions.DeepCopy(), NULL);
1301 UpdateProviderPolicy(policies); 1317 UpdateProviderPolicy(policies);
1302 // It should revert to the user's preference automatically. 1318 // It should revert to the user's preference automatically.
1303 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1319 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1304 // And the user should be able to disable and enable again. 1320 // And the user should be able to disable and enable again.
1305 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); 1321 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false));
1306 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1322 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1307 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true)); 1323 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, true));
1308 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1324 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1309 } 1325 }
1310 1326
1311 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) { 1327 IN_PROC_BROWSER_TEST_F(PolicyTest, EnabledPlugins) {
1312 // Verifies that a plugin can be force-installed with a policy. 1328 // Verifies that a plugin can be force-installed with a policy.
1313 std::vector<content::WebPluginInfo> plugins; 1329 std::vector<content::WebPluginInfo> plugins;
1314 GetPluginList(&plugins); 1330 GetPluginList(&plugins);
1315 const content::WebPluginInfo* flash = GetFlashPlugin(plugins); 1331 const content::WebPluginInfo* flash = GetFlashPlugin(plugins);
1316 if (!flash) 1332 if (!flash)
1317 return; 1333 return;
1318 PluginPrefs* plugin_prefs = 1334 PluginPrefs* plugin_prefs =
1319 PluginPrefs::GetForProfile(browser()->profile()).get(); 1335 PluginPrefs::GetForProfile(browser()->profile()).get();
1320 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1336 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1321 1337
1322 // The user disables it and then a policy forces it to be enabled. 1338 // The user disables it and then a policy forces it to be enabled.
1323 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false)); 1339 EXPECT_TRUE(SetPluginEnabled(plugin_prefs, flash, false));
1324 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash)); 1340 EXPECT_FALSE(plugin_prefs->IsPluginEnabled(*flash));
1325 base::ListValue plugin_list; 1341 base::ListValue plugin_list;
1326 plugin_list.Append(base::Value::CreateStringValue(content::kFlashPluginName)); 1342 plugin_list.Append(new base::StringValue(content::kFlashPluginName));
1327 PolicyMap policies; 1343 PolicyMap policies;
1328 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY, 1344 policies.Set(key::kEnabledPlugins, POLICY_LEVEL_MANDATORY,
1329 POLICY_SCOPE_USER, plugin_list.DeepCopy(), NULL); 1345 POLICY_SCOPE_USER, plugin_list.DeepCopy(), NULL);
1330 UpdateProviderPolicy(policies); 1346 UpdateProviderPolicy(policies);
1331 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1347 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1332 // The user can't disable it anymore. 1348 // The user can't disable it anymore.
1333 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false)); 1349 EXPECT_FALSE(SetPluginEnabled(plugin_prefs, flash, false));
1334 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash)); 1350 EXPECT_TRUE(plugin_prefs->IsPluginEnabled(*flash));
1335 1351
1336 // When a plugin is both enabled and disabled, the whitelist takes precedence. 1352 // When a plugin is both enabled and disabled, the whitelist takes precedence.
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 1493
1478 // Verify that downloads end up on the default directory. 1494 // Verify that downloads end up on the default directory.
1479 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1495 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1480 DownloadAndVerifyFile(browser(), initial_dir.path(), file); 1496 DownloadAndVerifyFile(browser(), initial_dir.path(), file);
1481 base::DieFileDie(initial_dir.path().Append(file), false); 1497 base::DieFileDie(initial_dir.path().Append(file), false);
1482 1498
1483 // Override the download directory with the policy and verify a download. 1499 // Override the download directory with the policy and verify a download.
1484 base::ScopedTempDir forced_dir; 1500 base::ScopedTempDir forced_dir;
1485 ASSERT_TRUE(forced_dir.CreateUniqueTempDir()); 1501 ASSERT_TRUE(forced_dir.CreateUniqueTempDir());
1486 PolicyMap policies; 1502 PolicyMap policies;
1487 policies.Set(key::kDownloadDirectory, POLICY_LEVEL_MANDATORY, 1503 policies.Set(key::kDownloadDirectory,
1504 POLICY_LEVEL_MANDATORY,
1488 POLICY_SCOPE_USER, 1505 POLICY_SCOPE_USER,
1489 base::Value::CreateStringValue(forced_dir.path().value()), NULL); 1506 new base::StringValue(forced_dir.path().value()),
1507 NULL);
1490 UpdateProviderPolicy(policies); 1508 UpdateProviderPolicy(policies);
1491 DownloadAndVerifyFile(browser(), forced_dir.path(), file); 1509 DownloadAndVerifyFile(browser(), forced_dir.path(), file);
1492 // Verify that the first download location wasn't affected. 1510 // Verify that the first download location wasn't affected.
1493 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file))); 1511 EXPECT_FALSE(base::PathExists(initial_dir.path().Append(file)));
1494 } 1512 }
1495 1513
1496 // Flaky: http://crbug.com/388340 1514 // Flaky: http://crbug.com/388340
1497 IN_PROC_BROWSER_TEST_F(PolicyTest, 1515 IN_PROC_BROWSER_TEST_F(PolicyTest,
1498 DISABLED_ExtensionInstallBlacklistSelective) { 1516 DISABLED_ExtensionInstallBlacklistSelective) {
1499 // Verifies that blacklisted extensions can't be installed. 1517 // Verifies that blacklisted extensions can't be installed.
1500 ExtensionService* service = extension_service(); 1518 ExtensionService* service = extension_service();
1501 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1519 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1502 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1520 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1503 base::ListValue blacklist; 1521 base::ListValue blacklist;
1504 blacklist.Append(base::Value::CreateStringValue(kGoodCrxId)); 1522 blacklist.Append(new base::StringValue(kGoodCrxId));
1505 PolicyMap policies; 1523 PolicyMap policies;
1506 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, 1524 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
1507 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 1525 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
1508 UpdateProviderPolicy(policies); 1526 UpdateProviderPolicy(policies);
1509 1527
1510 // "good.crx" is blacklisted. 1528 // "good.crx" is blacklisted.
1511 EXPECT_FALSE(InstallExtension(kGoodCrxName)); 1529 EXPECT_FALSE(InstallExtension(kGoodCrxName));
1512 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1530 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1513 1531
1514 // "adblock.crx" is not. 1532 // "adblock.crx" is not.
(...skipping 10 matching lines...) Expand all
1525 #else 1543 #else
1526 #define MAYBE_ExtensionInstallBlacklistWildcard ExtensionInstallBlacklistWildcar d 1544 #define MAYBE_ExtensionInstallBlacklistWildcard ExtensionInstallBlacklistWildcar d
1527 #endif 1545 #endif
1528 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) { 1546 IN_PROC_BROWSER_TEST_F(PolicyTest, MAYBE_ExtensionInstallBlacklistWildcard) {
1529 // Verify that a wildcard blacklist takes effect. 1547 // Verify that a wildcard blacklist takes effect.
1530 EXPECT_TRUE(InstallExtension(kAdBlockCrxName)); 1548 EXPECT_TRUE(InstallExtension(kAdBlockCrxName));
1531 ExtensionService* service = extension_service(); 1549 ExtensionService* service = extension_service();
1532 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1550 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1533 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true)); 1551 ASSERT_TRUE(service->GetExtensionById(kAdBlockCrxId, true));
1534 base::ListValue blacklist; 1552 base::ListValue blacklist;
1535 blacklist.Append(base::Value::CreateStringValue("*")); 1553 blacklist.Append(new base::StringValue("*"));
1536 PolicyMap policies; 1554 PolicyMap policies;
1537 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, 1555 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
1538 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 1556 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
1539 UpdateProviderPolicy(policies); 1557 UpdateProviderPolicy(policies);
1540 1558
1541 // AdBlock was automatically removed. 1559 // AdBlock was automatically removed.
1542 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1560 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1543 1561
1544 // And can't be installed again, nor can good.crx. 1562 // And can't be installed again, nor can good.crx.
1545 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); 1563 EXPECT_FALSE(InstallExtension(kAdBlockCrxName));
1546 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1564 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1547 EXPECT_FALSE(InstallExtension(kGoodCrxName)); 1565 EXPECT_FALSE(InstallExtension(kGoodCrxName));
1548 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1566 EXPECT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1549 } 1567 }
1550 1568
1551 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) { 1569 IN_PROC_BROWSER_TEST_F(PolicyTest, ExtensionInstallWhitelist) {
1552 // Verifies that the whitelist can open exceptions to the blacklist. 1570 // Verifies that the whitelist can open exceptions to the blacklist.
1553 ExtensionService* service = extension_service(); 1571 ExtensionService* service = extension_service();
1554 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true)); 1572 ASSERT_FALSE(service->GetExtensionById(kGoodCrxId, true));
1555 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1573 ASSERT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1556 base::ListValue blacklist; 1574 base::ListValue blacklist;
1557 blacklist.Append(base::Value::CreateStringValue("*")); 1575 blacklist.Append(new base::StringValue("*"));
1558 base::ListValue whitelist; 1576 base::ListValue whitelist;
1559 whitelist.Append(base::Value::CreateStringValue(kGoodCrxId)); 1577 whitelist.Append(new base::StringValue(kGoodCrxId));
1560 PolicyMap policies; 1578 PolicyMap policies;
1561 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY, 1579 policies.Set(key::kExtensionInstallBlacklist, POLICY_LEVEL_MANDATORY,
1562 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 1580 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
1563 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY, 1581 policies.Set(key::kExtensionInstallWhitelist, POLICY_LEVEL_MANDATORY,
1564 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); 1582 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL);
1565 UpdateProviderPolicy(policies); 1583 UpdateProviderPolicy(policies);
1566 // "adblock.crx" is blacklisted. 1584 // "adblock.crx" is blacklisted.
1567 EXPECT_FALSE(InstallExtension(kAdBlockCrxName)); 1585 EXPECT_FALSE(InstallExtension(kAdBlockCrxName));
1568 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true)); 1586 EXPECT_FALSE(service->GetExtensionById(kAdBlockCrxId, true));
1569 // "good.crx" has a whitelist exception. 1587 // "good.crx" has a whitelist exception.
(...skipping 13 matching lines...) Expand all
1583 1601
1584 // Extensions that are force-installed come from an update URL, which defaults 1602 // Extensions that are force-installed come from an update URL, which defaults
1585 // to the webstore. Use a mock URL for this test with an update manifest 1603 // to the webstore. Use a mock URL for this test with an update manifest
1586 // that includes "good_v1.crx". 1604 // that includes "good_v1.crx".
1587 base::FilePath path = 1605 base::FilePath path =
1588 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName); 1606 base::FilePath(kTestExtensionsDir).Append(kGoodV1CrxManifestName);
1589 GURL url(URLRequestMockHTTPJob::GetMockUrl(path)); 1607 GURL url(URLRequestMockHTTPJob::GetMockUrl(path));
1590 1608
1591 // Setting the forcelist extension should install "good_v1.crx". 1609 // Setting the forcelist extension should install "good_v1.crx".
1592 base::ListValue forcelist; 1610 base::ListValue forcelist;
1593 forcelist.Append(base::Value::CreateStringValue(base::StringPrintf( 1611 forcelist.Append(new base::StringValue(
1594 "%s;%s", kGoodCrxId, url.spec().c_str()))); 1612 base::StringPrintf("%s;%s", kGoodCrxId, url.spec().c_str())));
1595 PolicyMap policies; 1613 PolicyMap policies;
1596 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY, 1614 policies.Set(key::kExtensionInstallForcelist, POLICY_LEVEL_MANDATORY,
1597 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL); 1615 POLICY_SCOPE_USER, forcelist.DeepCopy(), NULL);
1598 content::WindowedNotificationObserver observer( 1616 content::WindowedNotificationObserver observer(
1599 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED, 1617 chrome::NOTIFICATION_EXTENSION_WILL_BE_INSTALLED_DEPRECATED,
1600 content::NotificationService::AllSources()); 1618 content::NotificationService::AllSources());
1601 UpdateProviderPolicy(policies); 1619 UpdateProviderPolicy(policies);
1602 observer.Wait(); 1620 observer.Wait();
1603 // Note: Cannot check that the notification details match the expected 1621 // Note: Cannot check that the notification details match the expected
1604 // exception, since the details object has already been freed prior to 1622 // exception, since the details object has already been freed prior to
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
1793 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), 1811 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL),
1794 browser()->profile()->GetHomePage()); 1812 browser()->profile()->GetHomePage());
1795 content::WebContents* contents = 1813 content::WebContents* contents =
1796 browser()->tab_strip_model()->GetActiveWebContents(); 1814 browser()->tab_strip_model()->GetActiveWebContents();
1797 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL()); 1815 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL());
1798 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); 1816 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME));
1799 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); 1817 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL());
1800 1818
1801 // Now override with policy. 1819 // Now override with policy.
1802 PolicyMap policies; 1820 PolicyMap policies;
1803 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, 1821 policies.Set(key::kHomepageLocation,
1822 POLICY_LEVEL_MANDATORY,
1804 POLICY_SCOPE_USER, 1823 POLICY_SCOPE_USER,
1805 base::Value::CreateStringValue(chrome::kChromeUICreditsURL), 1824 new base::StringValue(chrome::kChromeUICreditsURL),
1806 NULL); 1825 NULL);
1807 UpdateProviderPolicy(policies); 1826 UpdateProviderPolicy(policies);
1808 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); 1827 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME));
1809 content::WaitForLoadStop(contents); 1828 content::WaitForLoadStop(contents);
1810 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL()); 1829 EXPECT_EQ(GURL(chrome::kChromeUICreditsURL), contents->GetURL());
1811 1830
1812 policies.Set(key::kHomepageIsNewTabPage, 1831 policies.Set(key::kHomepageIsNewTabPage,
1813 POLICY_LEVEL_MANDATORY, 1832 POLICY_LEVEL_MANDATORY,
1814 POLICY_SCOPE_USER, 1833 POLICY_SCOPE_USER,
1815 new base::FundamentalValue(true), 1834 new base::FundamentalValue(true),
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
2023 base::Bind(RedirectHostsToTestData, kURLS, arraysize(kURLS)), 2042 base::Bind(RedirectHostsToTestData, kURLS, arraysize(kURLS)),
2024 loop.QuitClosure()); 2043 loop.QuitClosure());
2025 loop.Run(); 2044 loop.Run();
2026 } 2045 }
2027 2046
2028 // Verify that "bbb.com" opens before applying the blacklist. 2047 // Verify that "bbb.com" opens before applying the blacklist.
2029 CheckCanOpenURL(browser(), kURLS[1]); 2048 CheckCanOpenURL(browser(), kURLS[1]);
2030 2049
2031 // Set a blacklist. 2050 // Set a blacklist.
2032 base::ListValue blacklist; 2051 base::ListValue blacklist;
2033 blacklist.Append(base::Value::CreateStringValue("bbb.com")); 2052 blacklist.Append(new base::StringValue("bbb.com"));
2034 PolicyMap policies; 2053 PolicyMap policies;
2035 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2054 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2036 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2055 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
2037 UpdateProviderPolicy(policies); 2056 UpdateProviderPolicy(policies);
2038 FlushBlacklistPolicy(); 2057 FlushBlacklistPolicy();
2039 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked. 2058 // All bbb.com URLs are blocked, and "aaa.com" is still unblocked.
2040 CheckCanOpenURL(browser(), kURLS[0]); 2059 CheckCanOpenURL(browser(), kURLS[0]);
2041 for (size_t i = 1; i < arraysize(kURLS); ++i) 2060 for (size_t i = 1; i < arraysize(kURLS); ++i)
2042 CheckURLIsBlocked(browser(), kURLS[i]); 2061 CheckURLIsBlocked(browser(), kURLS[i]);
2043 2062
2044 // Whitelist some sites of bbb.com. 2063 // Whitelist some sites of bbb.com.
2045 base::ListValue whitelist; 2064 base::ListValue whitelist;
2046 whitelist.Append(base::Value::CreateStringValue("sub.bbb.com")); 2065 whitelist.Append(new base::StringValue("sub.bbb.com"));
2047 whitelist.Append(base::Value::CreateStringValue("bbb.com/policy")); 2066 whitelist.Append(new base::StringValue("bbb.com/policy"));
2048 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, 2067 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY,
2049 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); 2068 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL);
2050 UpdateProviderPolicy(policies); 2069 UpdateProviderPolicy(policies);
2051 FlushBlacklistPolicy(); 2070 FlushBlacklistPolicy();
2052 CheckURLIsBlocked(browser(), kURLS[1]); 2071 CheckURLIsBlocked(browser(), kURLS[1]);
2053 CheckCanOpenURL(browser(), kURLS[2]); 2072 CheckCanOpenURL(browser(), kURLS[2]);
2054 CheckCanOpenURL(browser(), kURLS[3]); 2073 CheckCanOpenURL(browser(), kURLS[3]);
2055 2074
2056 { 2075 {
2057 base::RunLoop loop; 2076 base::RunLoop loop;
(...skipping 15 matching lines...) Expand all
2073 const std::string base_path = "file://" + test_path.AsUTF8Unsafe() +"/"; 2092 const std::string base_path = "file://" + test_path.AsUTF8Unsafe() +"/";
2074 const std::string folder_path = base_path + "apptest/"; 2093 const std::string folder_path = base_path + "apptest/";
2075 const std::string file_path1 = base_path + "title1.html"; 2094 const std::string file_path1 = base_path + "title1.html";
2076 const std::string file_path2 = folder_path + "basic.html"; 2095 const std::string file_path2 = folder_path + "basic.html";
2077 2096
2078 CheckCanOpenURL(browser(), file_path1.c_str()); 2097 CheckCanOpenURL(browser(), file_path1.c_str());
2079 CheckCanOpenURL(browser(), file_path2.c_str()); 2098 CheckCanOpenURL(browser(), file_path2.c_str());
2080 2099
2081 // Set a blacklist for all the files. 2100 // Set a blacklist for all the files.
2082 base::ListValue blacklist; 2101 base::ListValue blacklist;
2083 blacklist.Append(base::Value::CreateStringValue("file://*")); 2102 blacklist.Append(new base::StringValue("file://*"));
2084 PolicyMap policies; 2103 PolicyMap policies;
2085 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2104 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2086 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2105 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
2087 UpdateProviderPolicy(policies); 2106 UpdateProviderPolicy(policies);
2088 FlushBlacklistPolicy(); 2107 FlushBlacklistPolicy();
2089 2108
2090 CheckURLIsBlocked(browser(), file_path1.c_str()); 2109 CheckURLIsBlocked(browser(), file_path1.c_str());
2091 CheckURLIsBlocked(browser(), file_path2.c_str()); 2110 CheckURLIsBlocked(browser(), file_path2.c_str());
2092 2111
2093 // Replace the URLblacklist with disabling the file scheme. 2112 // Replace the URLblacklist with disabling the file scheme.
2094 blacklist.Remove(base::StringValue("file://*"), NULL); 2113 blacklist.Remove(base::StringValue("file://*"), NULL);
2095 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2114 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2096 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2115 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
2097 UpdateProviderPolicy(policies); 2116 UpdateProviderPolicy(policies);
2098 FlushBlacklistPolicy(); 2117 FlushBlacklistPolicy();
2099 2118
2100 PrefService* prefs = browser()->profile()->GetPrefs(); 2119 PrefService* prefs = browser()->profile()->GetPrefs();
2101 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist); 2120 const base::ListValue* list_url = prefs->GetList(policy_prefs::kUrlBlacklist);
2102 EXPECT_EQ(list_url->Find(base::StringValue("file://*")), 2121 EXPECT_EQ(list_url->Find(base::StringValue("file://*")),
2103 list_url->end()); 2122 list_url->end());
2104 2123
2105 base::ListValue disabledscheme; 2124 base::ListValue disabledscheme;
2106 disabledscheme.Append(base::Value::CreateStringValue("file")); 2125 disabledscheme.Append(new base::StringValue("file"));
2107 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY, 2126 policies.Set(key::kDisabledSchemes, POLICY_LEVEL_MANDATORY,
2108 POLICY_SCOPE_USER, disabledscheme.DeepCopy(), NULL); 2127 POLICY_SCOPE_USER, disabledscheme.DeepCopy(), NULL);
2109 UpdateProviderPolicy(policies); 2128 UpdateProviderPolicy(policies);
2110 FlushBlacklistPolicy(); 2129 FlushBlacklistPolicy();
2111 2130
2112 list_url = prefs->GetList(policy_prefs::kUrlBlacklist); 2131 list_url = prefs->GetList(policy_prefs::kUrlBlacklist);
2113 EXPECT_NE(list_url->Find(base::StringValue("file://*")), 2132 EXPECT_NE(list_url->Find(base::StringValue("file://*")),
2114 list_url->end()); 2133 list_url->end());
2115 2134
2116 // Whitelist one folder and blacklist an another just inside. 2135 // Whitelist one folder and blacklist an another just inside.
2117 base::ListValue whitelist; 2136 base::ListValue whitelist;
2118 whitelist.Append(base::Value::CreateStringValue(base_path)); 2137 whitelist.Append(new base::StringValue(base_path));
2119 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY, 2138 policies.Set(key::kURLWhitelist, POLICY_LEVEL_MANDATORY,
2120 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); 2139 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL);
2121 blacklist.Append(base::Value::CreateStringValue(folder_path)); 2140 blacklist.Append(new base::StringValue(folder_path));
2122 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY, 2141 policies.Set(key::kURLBlacklist, POLICY_LEVEL_MANDATORY,
2123 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 2142 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
2124 UpdateProviderPolicy(policies); 2143 UpdateProviderPolicy(policies);
2125 FlushBlacklistPolicy(); 2144 FlushBlacklistPolicy();
2126 2145
2127 CheckCanOpenURL(browser(), file_path1.c_str()); 2146 CheckCanOpenURL(browser(), file_path1.c_str());
2128 CheckURLIsBlocked(browser(), file_path2.c_str()); 2147 CheckURLIsBlocked(browser(), file_path2.c_str());
2129 } 2148 }
2130 2149
2131 #if !defined(OS_MACOSX) 2150 #if !defined(OS_MACOSX)
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
2621 policies.Set( 2640 policies.Set(
2622 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2641 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2623 base::Value::CreateIntegerValue( 2642 base::Value::CreateIntegerValue(
2624 SessionStartupPref::kPrefValueHomePage), 2643 SessionStartupPref::kPrefValueHomePage),
2625 NULL); 2644 NULL);
2626 policies.Set(key::kHomepageIsNewTabPage, 2645 policies.Set(key::kHomepageIsNewTabPage,
2627 POLICY_LEVEL_MANDATORY, 2646 POLICY_LEVEL_MANDATORY,
2628 POLICY_SCOPE_USER, 2647 POLICY_SCOPE_USER,
2629 new base::FundamentalValue(false), 2648 new base::FundamentalValue(false),
2630 NULL); 2649 NULL);
2631 policies.Set( 2650 policies.Set(key::kHomepageLocation,
2632 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2651 POLICY_LEVEL_MANDATORY,
2633 base::Value::CreateStringValue(kRestoredURLs[1]), NULL); 2652 POLICY_SCOPE_USER,
2653 new base::StringValue(kRestoredURLs[1]),
2654 NULL);
2634 provider_.UpdateChromePolicy(policies); 2655 provider_.UpdateChromePolicy(policies);
2635 2656
2636 expected_urls_.push_back(GURL(kRestoredURLs[1])); 2657 expected_urls_.push_back(GURL(kRestoredURLs[1]));
2637 } 2658 }
2638 2659
2639 void HomepageIsNTP() { 2660 void HomepageIsNTP() {
2640 // Verifies that policy can set the startup pages to the homepage, when 2661 // Verifies that policy can set the startup pages to the homepage, when
2641 // the homepage is the NTP. 2662 // the homepage is the NTP.
2642 PolicyMap policies; 2663 PolicyMap policies;
2643 policies.Set( 2664 policies.Set(
2644 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2665 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2645 base::Value::CreateIntegerValue( 2666 base::Value::CreateIntegerValue(
2646 SessionStartupPref::kPrefValueHomePage), 2667 SessionStartupPref::kPrefValueHomePage),
2647 NULL); 2668 NULL);
2648 policies.Set(key::kHomepageIsNewTabPage, 2669 policies.Set(key::kHomepageIsNewTabPage,
2649 POLICY_LEVEL_MANDATORY, 2670 POLICY_LEVEL_MANDATORY,
2650 POLICY_SCOPE_USER, 2671 POLICY_SCOPE_USER,
2651 new base::FundamentalValue(true), 2672 new base::FundamentalValue(true),
2652 NULL); 2673 NULL);
2653 provider_.UpdateChromePolicy(policies); 2674 provider_.UpdateChromePolicy(policies);
2654 2675
2655 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL)); 2676 expected_urls_.push_back(GURL(chrome::kChromeUINewTabURL));
2656 } 2677 }
2657 2678
2658 void ListOfURLs() { 2679 void ListOfURLs() {
2659 // Verifies that policy can set the startup pages to a list of URLs. 2680 // Verifies that policy can set the startup pages to a list of URLs.
2660 base::ListValue urls; 2681 base::ListValue urls;
2661 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) { 2682 for (size_t i = 0; i < arraysize(kRestoredURLs); ++i) {
2662 urls.Append(base::Value::CreateStringValue(kRestoredURLs[i])); 2683 urls.Append(new base::StringValue(kRestoredURLs[i]));
2663 expected_urls_.push_back(GURL(kRestoredURLs[i])); 2684 expected_urls_.push_back(GURL(kRestoredURLs[i]));
2664 } 2685 }
2665 PolicyMap policies; 2686 PolicyMap policies;
2666 policies.Set( 2687 policies.Set(
2667 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2688 key::kRestoreOnStartup, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2668 base::Value::CreateIntegerValue(SessionStartupPref::kPrefValueURLs), 2689 base::Value::CreateIntegerValue(SessionStartupPref::kPrefValueURLs),
2669 NULL); 2690 NULL);
2670 policies.Set( 2691 policies.Set(
2671 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2692 key::kRestoreOnStartupURLs, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER,
2672 urls.DeepCopy(), NULL); 2693 urls.DeepCopy(), NULL);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 policies.Set(key::kShowHomeButton, 2773 policies.Set(key::kShowHomeButton,
2753 POLICY_LEVEL_MANDATORY, 2774 POLICY_LEVEL_MANDATORY,
2754 POLICY_SCOPE_USER, 2775 POLICY_SCOPE_USER,
2755 new base::FundamentalValue(true), 2776 new base::FundamentalValue(true),
2756 NULL); 2777 NULL);
2757 policies.Set(key::kBookmarkBarEnabled, 2778 policies.Set(key::kBookmarkBarEnabled,
2758 POLICY_LEVEL_MANDATORY, 2779 POLICY_LEVEL_MANDATORY,
2759 POLICY_SCOPE_USER, 2780 POLICY_SCOPE_USER,
2760 new base::FundamentalValue(false), 2781 new base::FundamentalValue(false),
2761 NULL); 2782 NULL);
2762 policies.Set( 2783 policies.Set(key::kHomepageLocation,
2763 key::kHomepageLocation, POLICY_LEVEL_MANDATORY, POLICY_SCOPE_USER, 2784 POLICY_LEVEL_MANDATORY,
2764 base::Value::CreateStringValue("http://chromium.org"), NULL); 2785 POLICY_SCOPE_USER,
2786 new base::StringValue("http://chromium.org"),
2787 NULL);
2765 provider_.UpdateChromePolicy(policies); 2788 provider_.UpdateChromePolicy(policies);
2766 } 2789 }
2767 }; 2790 };
2768 2791
2769 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { 2792 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) {
2770 // Verifies that policy usage histograms are collected at startup. 2793 // Verifies that policy usage histograms are collected at startup.
2771 2794
2772 // BrowserPolicyConnector::Init() has already been called. Make sure the 2795 // BrowserPolicyConnector::Init() has already been called. Make sure the
2773 // CompleteInitialization() task has executed as well. 2796 // CompleteInitialization() task has executed as well.
2774 content::RunAllPendingInMessageLoop(); 2797 content::RunAllPendingInMessageLoop();
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
3030 testing::Bool()); 3053 testing::Bool());
3031 3054
3032 #if !defined(OS_CHROMEOS) 3055 #if !defined(OS_CHROMEOS)
3033 // Similar to PolicyTest but sets the proper policy before the browser is 3056 // Similar to PolicyTest but sets the proper policy before the browser is
3034 // started. 3057 // started.
3035 class PolicyVariationsServiceTest : public PolicyTest { 3058 class PolicyVariationsServiceTest : public PolicyTest {
3036 public: 3059 public:
3037 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { 3060 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE {
3038 PolicyTest::SetUpInProcessBrowserTestFixture(); 3061 PolicyTest::SetUpInProcessBrowserTestFixture();
3039 PolicyMap policies; 3062 PolicyMap policies;
3040 policies.Set( 3063 policies.Set(key::kVariationsRestrictParameter,
3041 key::kVariationsRestrictParameter, 3064 POLICY_LEVEL_MANDATORY,
3042 POLICY_LEVEL_MANDATORY, 3065 POLICY_SCOPE_USER,
3043 POLICY_SCOPE_USER, 3066 new base::StringValue("restricted"),
3044 base::Value::CreateStringValue("restricted"), 3067 NULL);
3045 NULL);
3046 provider_.UpdateChromePolicy(policies); 3068 provider_.UpdateChromePolicy(policies);
3047 } 3069 }
3048 }; 3070 };
3049 3071
3050 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) { 3072 IN_PROC_BROWSER_TEST_F(PolicyVariationsServiceTest, VariationsURLIsValid) {
3051 const std::string default_variations_url = 3073 const std::string default_variations_url =
3052 chrome_variations::VariationsService:: 3074 chrome_variations::VariationsService::
3053 GetDefaultVariationsServerURLForTesting(); 3075 GetDefaultVariationsServerURLForTesting();
3054 3076
3055 const GURL url = 3077 const GURL url =
3056 chrome_variations::VariationsService::GetVariationsServerURL( 3078 chrome_variations::VariationsService::GetVariationsServerURL(
3057 g_browser_process->local_state()); 3079 g_browser_process->local_state());
3058 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); 3080 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true));
3059 std::string value; 3081 std::string value;
3060 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); 3082 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value));
3061 EXPECT_EQ("restricted", value); 3083 EXPECT_EQ("restricted", value);
3062 } 3084 }
3063 3085
3064 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) { 3086 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistSelective) {
3065 base::ListValue blacklist; 3087 base::ListValue blacklist;
3066 blacklist.Append(base::Value::CreateStringValue("host.name")); 3088 blacklist.Append(new base::StringValue("host.name"));
3067 PolicyMap policies; 3089 PolicyMap policies;
3068 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, 3090 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
3069 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 3091 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
3070 UpdateProviderPolicy(policies); 3092 UpdateProviderPolicy(policies);
3071 3093
3072 PrefService* prefs = browser()->profile()->GetPrefs(); 3094 PrefService* prefs = browser()->profile()->GetPrefs();
3073 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( 3095 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed(
3074 prefs, "host.name")); 3096 prefs, "host.name"));
3075 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( 3097 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed(
3076 prefs, "other.host.name")); 3098 prefs, "other.host.name"));
3077 } 3099 }
3078 3100
3079 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) { 3101 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingBlacklistWildcard) {
3080 base::ListValue blacklist; 3102 base::ListValue blacklist;
3081 blacklist.Append(base::Value::CreateStringValue("*")); 3103 blacklist.Append(new base::StringValue("*"));
3082 PolicyMap policies; 3104 PolicyMap policies;
3083 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, 3105 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
3084 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 3106 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
3085 UpdateProviderPolicy(policies); 3107 UpdateProviderPolicy(policies);
3086 3108
3087 PrefService* prefs = browser()->profile()->GetPrefs(); 3109 PrefService* prefs = browser()->profile()->GetPrefs();
3088 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( 3110 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed(
3089 prefs, "host.name")); 3111 prefs, "host.name"));
3090 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( 3112 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed(
3091 prefs, "other.host.name")); 3113 prefs, "other.host.name"));
3092 } 3114 }
3093 3115
3094 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) { 3116 IN_PROC_BROWSER_TEST_F(PolicyTest, NativeMessagingWhitelist) {
3095 base::ListValue blacklist; 3117 base::ListValue blacklist;
3096 blacklist.Append(base::Value::CreateStringValue("*")); 3118 blacklist.Append(new base::StringValue("*"));
3097 base::ListValue whitelist; 3119 base::ListValue whitelist;
3098 whitelist.Append(base::Value::CreateStringValue("host.name")); 3120 whitelist.Append(new base::StringValue("host.name"));
3099 PolicyMap policies; 3121 PolicyMap policies;
3100 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY, 3122 policies.Set(key::kNativeMessagingBlacklist, POLICY_LEVEL_MANDATORY,
3101 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL); 3123 POLICY_SCOPE_USER, blacklist.DeepCopy(), NULL);
3102 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY, 3124 policies.Set(key::kNativeMessagingWhitelist, POLICY_LEVEL_MANDATORY,
3103 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL); 3125 POLICY_SCOPE_USER, whitelist.DeepCopy(), NULL);
3104 UpdateProviderPolicy(policies); 3126 UpdateProviderPolicy(policies);
3105 3127
3106 PrefService* prefs = browser()->profile()->GetPrefs(); 3128 PrefService* prefs = browser()->profile()->GetPrefs();
3107 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( 3129 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed(
3108 prefs, "host.name")); 3130 prefs, "host.name"));
(...skipping 22 matching lines...) Expand all
3131 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 3153 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
3132 browser2->tab_strip_model()->GetActiveWebContents(), 3154 browser2->tab_strip_model()->GetActiveWebContents(),
3133 "domAutomationController.send(window.showModalDialog !== undefined);", 3155 "domAutomationController.send(window.showModalDialog !== undefined);",
3134 &result)); 3156 &result));
3135 EXPECT_TRUE(result); 3157 EXPECT_TRUE(result);
3136 } 3158 }
3137 3159
3138 #endif // !defined(CHROME_OS) 3160 #endif // !defined(CHROME_OS)
3139 3161
3140 } // namespace policy 3162 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/cloud/cloud_policy_browsertest.cc ('k') | chrome/browser/prefs/chrome_pref_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698