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 "base/auto_reset.h" | 5 #include "base/auto_reset.h" |
6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
7 #include "base/json/json_reader.h" | 7 #include "base/json/json_reader.h" |
8 #include "base/json/json_writer.h" | 8 #include "base/json/json_writer.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 CONTENT_SETTING_ALLOW); | 719 CONTENT_SETTING_ALLOW); |
720 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 720 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
721 host_content_settings_map->GetContentSetting( | 721 host_content_settings_map->GetContentSetting( |
722 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 722 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
723 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 723 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
724 otr_map->GetContentSetting( | 724 otr_map->GetContentSetting( |
725 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 725 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
726 } | 726 } |
727 | 727 |
728 TEST_F(HostContentSettingsMapTest, OffTheRecordPartialInheritPref) { | 728 TEST_F(HostContentSettingsMapTest, OffTheRecordPartialInheritPref) { |
729 // Permissions marked INHERIT_IN_INCOGNITO_EXCEPT_ALLOW in | 729 // Permissions marked INHERIT_IN_INCOGNITO_EXCEPT_ALLOW or |
730 // ContentSettingsRegistry (e.g. push & notifications) only inherit BLOCK | 730 // DENY_IN_INCOGNITO_AFTER_DELAY in ContentSettingsRegistry (e.g. push & |
731 // settings from regular to incognito. | 731 // notifications) only inherit BLOCK settings from regular to incognito. |
732 TestingProfile profile; | 732 TestingProfile profile; |
733 Profile* otr_profile = profile.GetOffTheRecordProfile(); | 733 Profile* otr_profile = profile.GetOffTheRecordProfile(); |
734 HostContentSettingsMap* host_content_settings_map = | 734 HostContentSettingsMap* host_content_settings_map = |
735 HostContentSettingsMapFactory::GetForProfile(&profile); | 735 HostContentSettingsMapFactory::GetForProfile(&profile); |
736 HostContentSettingsMap* otr_map = | 736 HostContentSettingsMap* otr_map = |
737 HostContentSettingsMapFactory::GetForProfile(otr_profile); | 737 HostContentSettingsMapFactory::GetForProfile(otr_profile); |
738 | 738 |
739 GURL host("http://example.com/"); | 739 GURL host("http://example.com/"); |
740 ContentSettingsPattern pattern = | 740 ContentSettingsPattern pattern = |
741 ContentSettingsPattern::FromURLNoWildcard(host); | 741 ContentSettingsPattern::FromURLNoWildcard(host); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
777 CONTENT_SETTING_ALLOW, | 777 CONTENT_SETTING_ALLOW, |
778 host_content_settings_map->GetContentSetting( | 778 host_content_settings_map->GetContentSetting( |
779 host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); | 779 host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); |
780 EXPECT_EQ( | 780 EXPECT_EQ( |
781 CONTENT_SETTING_ASK, | 781 CONTENT_SETTING_ASK, |
782 otr_map->GetContentSetting( | 782 otr_map->GetContentSetting( |
783 host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); | 783 host, host, CONTENT_SETTINGS_TYPE_NOTIFICATIONS, std::string())); |
784 } | 784 } |
785 | 785 |
786 TEST_F(HostContentSettingsMapTest, OffTheRecordPartialInheritDefault) { | 786 TEST_F(HostContentSettingsMapTest, OffTheRecordPartialInheritDefault) { |
787 // Permissions marked INHERIT_IN_INCOGNITO_EXCEPT_ALLOW in | 787 // Permissions marked INHERIT_IN_INCOGNITO_EXCEPT_ALLOW or |
788 // ContentSettingsRegistry (e.g. push & notifications) only inherit BLOCK | 788 // DENY_IN_INCOGNITO_AFTER_DELAY in ContentSettingsRegistry (e.g. push & |
789 // default settings from regular to incognito. | 789 // notifications) only inherit BLOCK default settings from regular to |
| 790 // incognito. |
790 TestingProfile profile; | 791 TestingProfile profile; |
791 Profile* otr_profile = profile.GetOffTheRecordProfile(); | 792 Profile* otr_profile = profile.GetOffTheRecordProfile(); |
792 HostContentSettingsMap* host_content_settings_map = | 793 HostContentSettingsMap* host_content_settings_map = |
793 HostContentSettingsMapFactory::GetForProfile(&profile); | 794 HostContentSettingsMapFactory::GetForProfile(&profile); |
794 HostContentSettingsMap* otr_map = | 795 HostContentSettingsMap* otr_map = |
795 HostContentSettingsMapFactory::GetForProfile(otr_profile); | 796 HostContentSettingsMapFactory::GetForProfile(otr_profile); |
796 | 797 |
797 GURL host("http://example.com/"); | 798 GURL host("http://example.com/"); |
798 | 799 |
799 EXPECT_EQ(CONTENT_SETTING_ASK, | 800 EXPECT_EQ(CONTENT_SETTING_ASK, |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 1156 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
1156 host_content_settings_map->GetContentSetting( | 1157 host_content_settings_map->GetContentSetting( |
1157 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); | 1158 host, host, CONTENT_SETTINGS_TYPE_IMAGES, std::string())); |
1158 host_content_settings_map->SetContentSetting( | 1159 host_content_settings_map->SetContentSetting( |
1159 pattern, | 1160 pattern, |
1160 ContentSettingsPattern::Wildcard(), | 1161 ContentSettingsPattern::Wildcard(), |
1161 CONTENT_SETTINGS_TYPE_IMAGES, | 1162 CONTENT_SETTINGS_TYPE_IMAGES, |
1162 std::string(), | 1163 std::string(), |
1163 CONTENT_SETTING_DEFAULT); | 1164 CONTENT_SETTING_DEFAULT); |
1164 } | 1165 } |
OLD | NEW |