| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/auto_reset.h" | 8 #include "base/auto_reset.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/json/json_reader.h" | 10 #include "base/json/json_reader.h" |
| (...skipping 1430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 host_content_settings_map->GetContentSetting( | 1441 host_content_settings_map->GetContentSetting( |
| 1442 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 1442 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1443 host_content_settings_map->SetContentSettingCustomScope( | 1443 host_content_settings_map->SetContentSettingCustomScope( |
| 1444 ContentSettingsPattern::FromURL(http_host), | 1444 ContentSettingsPattern::FromURL(http_host), |
| 1445 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES, | 1445 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES, |
| 1446 std::string(), CONTENT_SETTING_ALLOW); | 1446 std::string(), CONTENT_SETTING_ALLOW); |
| 1447 EXPECT_EQ( | 1447 EXPECT_EQ( |
| 1448 CONTENT_SETTING_ALLOW, | 1448 CONTENT_SETTING_ALLOW, |
| 1449 host_content_settings_map->GetContentSetting( | 1449 host_content_settings_map->GetContentSetting( |
| 1450 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 1450 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1451 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
| 1452 host_content_settings_map->GetContentSetting( | |
| 1453 http_host_narrower, http_host_narrower, | |
| 1454 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | |
| 1455 host_content_settings_map->SetContentSettingCustomScope( | 1451 host_content_settings_map->SetContentSettingCustomScope( |
| 1456 ContentSettingsPattern::FromURL(https_host), | 1452 ContentSettingsPattern::FromURL(https_host), |
| 1457 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES, | 1453 ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_COOKIES, |
| 1458 std::string(), CONTENT_SETTING_ALLOW); | 1454 std::string(), CONTENT_SETTING_ALLOW); |
| 1459 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1455 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1460 host_content_settings_map->GetContentSetting( | 1456 host_content_settings_map->GetContentSetting( |
| 1461 https_host, https_host, CONTENT_SETTINGS_TYPE_COOKIES, | 1457 https_host, https_host, CONTENT_SETTINGS_TYPE_COOKIES, |
| 1462 std::string())); | 1458 std::string())); |
| 1463 // Settings also apply to subdomains. | 1459 // Settings also apply to subdomains. |
| 1464 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1460 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1465 host_content_settings_map->GetContentSetting( | 1461 host_content_settings_map->GetContentSetting( |
| 1462 http_host_narrower, http_host_narrower, |
| 1463 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1464 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1465 host_content_settings_map->GetContentSetting( |
| 1466 https_host_narrower, https_host_narrower, | 1466 https_host_narrower, https_host_narrower, |
| 1467 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 1467 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1468 | 1468 |
| 1469 host_content_settings_map->MigrateDomainScopedSettings(false); | 1469 host_content_settings_map->MigrateDomainScopedSettings(false); |
| 1470 | 1470 |
| 1471 // After migration, settings only affect origins. | 1471 // After migration, settings only affect origins. |
| 1472 EXPECT_EQ( | 1472 EXPECT_EQ( |
| 1473 CONTENT_SETTING_ALLOW, | 1473 CONTENT_SETTING_ALLOW, |
| 1474 host_content_settings_map->GetContentSetting( | 1474 host_content_settings_map->GetContentSetting( |
| 1475 http_host, http_host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); | 1475 http_host, http_host, CONTENT_SETTINGS_TYPE_POPUPS, std::string())); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1496 CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); | 1496 CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string())); |
| 1497 host_content_settings_map->GetSettingsForOneType( | 1497 host_content_settings_map->GetSettingsForOneType( |
| 1498 CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string(), &settings); | 1498 CONTENT_SETTINGS_TYPE_JAVASCRIPT, std::string(), &settings); |
| 1499 // |host_content_settings_map| contains default setting and a origin scoped | 1499 // |host_content_settings_map| contains default setting and a origin scoped |
| 1500 // setting. | 1500 // setting. |
| 1501 EXPECT_EQ(2U, settings.size()); | 1501 EXPECT_EQ(2U, settings.size()); |
| 1502 EXPECT_TRUE(settings[0].primary_pattern.ToString() == | 1502 EXPECT_TRUE(settings[0].primary_pattern.ToString() == |
| 1503 "https://example.com:443"); | 1503 "https://example.com:443"); |
| 1504 EXPECT_TRUE(settings[1].primary_pattern.ToString() == "*"); | 1504 EXPECT_TRUE(settings[1].primary_pattern.ToString() == "*"); |
| 1505 | 1505 |
| 1506 // Cookie settings didn't get migrated. | |
| 1507 EXPECT_EQ( | 1506 EXPECT_EQ( |
| 1508 CONTENT_SETTING_ALLOW, | 1507 CONTENT_SETTING_ALLOW, |
| 1509 host_content_settings_map->GetContentSetting( | 1508 host_content_settings_map->GetContentSetting( |
| 1510 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 1509 http_host, http_host, CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1511 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1510 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1512 host_content_settings_map->GetContentSetting( | 1511 host_content_settings_map->GetContentSetting( |
| 1512 https_host, https_host, CONTENT_SETTINGS_TYPE_COOKIES, |
| 1513 std::string())); |
| 1514 // Settings still apply to subdomains. Cookie settings didn't get migrated. |
| 1515 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1516 host_content_settings_map->GetContentSetting( |
| 1513 http_host_narrower, http_host_narrower, | 1517 http_host_narrower, http_host_narrower, |
| 1514 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 1518 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1515 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1519 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 1516 host_content_settings_map->GetContentSetting( | 1520 host_content_settings_map->GetContentSetting( |
| 1517 https_host, https_host, CONTENT_SETTINGS_TYPE_COOKIES, | |
| 1518 std::string())); | |
| 1519 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
| 1520 host_content_settings_map->GetContentSetting( | |
| 1521 https_host_narrower, https_host_narrower, | 1521 https_host_narrower, https_host_narrower, |
| 1522 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); | 1522 CONTENT_SETTINGS_TYPE_COOKIES, std::string())); |
| 1523 } | 1523 } |
| 1524 | 1524 |
| 1525 // Ensure that migration only happens once upon construction of the HCSM and | 1525 // Ensure that migration only happens once upon construction of the HCSM and |
| 1526 // once after syncing (even when these events occur multiple times). | 1526 // once after syncing (even when these events occur multiple times). |
| 1527 TEST_F(HostContentSettingsMapTest, DomainToOriginMigrationStatus) { | 1527 TEST_F(HostContentSettingsMapTest, DomainToOriginMigrationStatus) { |
| 1528 TestingProfile profile; | 1528 TestingProfile profile; |
| 1529 PrefService* prefs = profile.GetPrefs(); | 1529 PrefService* prefs = profile.GetPrefs(); |
| 1530 | 1530 |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1641 base::DictionaryValue test_value; | 1641 base::DictionaryValue test_value; |
| 1642 test_value.SetString("test", "value"); | 1642 test_value.SetString("test", "value"); |
| 1643 host_content_settings_map->SetWebsiteSettingDefaultScope( | 1643 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 1644 unsupported_url, unsupported_url, CONTENT_SETTINGS_TYPE_APP_BANNER, | 1644 unsupported_url, unsupported_url, CONTENT_SETTINGS_TYPE_APP_BANNER, |
| 1645 std::string(), base::WrapUnique(test_value.DeepCopy())); | 1645 std::string(), base::WrapUnique(test_value.DeepCopy())); |
| 1646 EXPECT_EQ(nullptr, | 1646 EXPECT_EQ(nullptr, |
| 1647 host_content_settings_map->GetWebsiteSetting( | 1647 host_content_settings_map->GetWebsiteSetting( |
| 1648 unsupported_url, unsupported_url, | 1648 unsupported_url, unsupported_url, |
| 1649 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), nullptr)); | 1649 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), nullptr)); |
| 1650 } | 1650 } |
| OLD | NEW |