Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/content_settings/host_content_settings_map_unittest.h" | 5 #include "chrome/browser/content_settings/host_content_settings_map_unittest.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 391 | 391 |
| 392 TEST_F(HostContentSettingsMapTest, NestedSettings) { | 392 TEST_F(HostContentSettingsMapTest, NestedSettings) { |
| 393 TestingProfile profile; | 393 TestingProfile profile; |
| 394 HostContentSettingsMap* host_content_settings_map = | 394 HostContentSettingsMap* host_content_settings_map = |
| 395 profile.GetHostContentSettingsMap(); | 395 profile.GetHostContentSettingsMap(); |
| 396 | 396 |
| 397 GURL host("http://a.b.example.com/"); | 397 GURL host("http://a.b.example.com/"); |
| 398 ContentSettingsPattern pattern1("[*.]example.com"); | 398 ContentSettingsPattern pattern1("[*.]example.com"); |
| 399 ContentSettingsPattern pattern2("[*.]b.example.com"); | 399 ContentSettingsPattern pattern2("[*.]b.example.com"); |
| 400 ContentSettingsPattern pattern3("a.b.example.com"); | 400 ContentSettingsPattern pattern3("a.b.example.com"); |
| 401 | |
|
jochen (gone - plz use gerrit)
2011/02/04 08:38:43
please don't remove this lines
markusheintz_
2011/02/04 10:08:03
Done.
| |
| 402 host_content_settings_map->SetContentSetting(pattern1, | 401 host_content_settings_map->SetContentSetting(pattern1, |
| 403 CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK); | 402 CONTENT_SETTINGS_TYPE_IMAGES, "", CONTENT_SETTING_BLOCK); |
| 404 host_content_settings_map->SetContentSetting(pattern2, | 403 host_content_settings_map->SetContentSetting(pattern2, |
| 405 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK); | 404 CONTENT_SETTINGS_TYPE_COOKIES, "", CONTENT_SETTING_BLOCK); |
| 406 host_content_settings_map->SetContentSetting(pattern3, | 405 host_content_settings_map->SetContentSetting(pattern3, |
| 407 CONTENT_SETTINGS_TYPE_PLUGINS, "", CONTENT_SETTING_BLOCK); | 406 CONTENT_SETTINGS_TYPE_PLUGINS, "", CONTENT_SETTING_BLOCK); |
| 408 host_content_settings_map->SetDefaultContentSetting( | 407 host_content_settings_map->SetDefaultContentSetting( |
| 409 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); | 408 CONTENT_SETTINGS_TYPE_JAVASCRIPT, CONTENT_SETTING_BLOCK); |
| 410 | |
| 411 ContentSettings desired_settings; | 409 ContentSettings desired_settings; |
| 412 desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES] = | 410 desired_settings.settings[CONTENT_SETTINGS_TYPE_COOKIES] = |
| 413 CONTENT_SETTING_BLOCK; | 411 CONTENT_SETTING_BLOCK; |
| 414 desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES] = | 412 desired_settings.settings[CONTENT_SETTINGS_TYPE_IMAGES] = |
| 415 CONTENT_SETTING_BLOCK; | 413 CONTENT_SETTING_BLOCK; |
| 416 desired_settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] = | 414 desired_settings.settings[CONTENT_SETTINGS_TYPE_JAVASCRIPT] = |
| 417 CONTENT_SETTING_BLOCK; | 415 CONTENT_SETTING_BLOCK; |
| 418 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = | 416 desired_settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = |
| 419 CONTENT_SETTING_BLOCK; | 417 CONTENT_SETTING_BLOCK; |
| 420 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] = | 418 desired_settings.settings[CONTENT_SETTINGS_TYPE_POPUPS] = |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 608 host_content_settings_map->GetContentSetting( | 606 host_content_settings_map->GetContentSetting( |
| 609 host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1)); | 607 host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1)); |
| 610 host_content_settings_map->SetContentSetting(pattern, | 608 host_content_settings_map->SetContentSetting(pattern, |
| 611 CONTENT_SETTINGS_TYPE_PLUGINS, resource1, CONTENT_SETTING_BLOCK); | 609 CONTENT_SETTINGS_TYPE_PLUGINS, resource1, CONTENT_SETTING_BLOCK); |
| 612 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 610 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 613 host_content_settings_map->GetContentSetting( | 611 host_content_settings_map->GetContentSetting( |
| 614 host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1)); | 612 host, CONTENT_SETTINGS_TYPE_PLUGINS, resource1)); |
| 615 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 613 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 616 host_content_settings_map->GetContentSetting( | 614 host_content_settings_map->GetContentSetting( |
| 617 host, CONTENT_SETTINGS_TYPE_PLUGINS, resource2)); | 615 host, CONTENT_SETTINGS_TYPE_PLUGINS, resource2)); |
| 616 | |
| 617 // If resource content settings are enable GetContentSettings should return | |
| 618 // CONTENT_SETTING_DEFAULT for content types that require resource | |
| 619 // identifiers. | |
| 620 ContentSettings settings = | |
| 621 host_content_settings_map->GetContentSettings(host); | |
| 622 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | |
| 623 settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS]); | |
| 618 } | 624 } |
| 619 | 625 |
| 620 TEST_F(HostContentSettingsMapTest, ResourceIdentifierPrefs) { | 626 TEST_F(HostContentSettingsMapTest, ResourceIdentifierPrefs) { |
| 621 // This feature is currently behind a flag. | 627 // This feature is currently behind a flag. |
| 622 CommandLine* cmd = CommandLine::ForCurrentProcess(); | 628 CommandLine* cmd = CommandLine::ForCurrentProcess(); |
| 623 AutoReset<CommandLine> auto_reset(cmd, *cmd); | 629 AutoReset<CommandLine> auto_reset(cmd, *cmd); |
| 624 cmd->AppendSwitch(switches::kEnableResourceContentSettings); | 630 cmd->AppendSwitch(switches::kEnableResourceContentSettings); |
| 625 | 631 |
| 626 TestingProfile profile; | 632 TestingProfile profile; |
| 627 scoped_ptr<Value> value(base::JSONReader::Read( | 633 scoped_ptr<Value> value(base::JSONReader::Read( |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 844 EXPECT_TRUE(host_content_settings_map->BlockThirdPartyCookies()); | 850 EXPECT_TRUE(host_content_settings_map->BlockThirdPartyCookies()); |
| 845 | 851 |
| 846 // After unsetting the managed value for the preference BlockThirdPartyCookies | 852 // After unsetting the managed value for the preference BlockThirdPartyCookies |
| 847 // the default value should be returned now. | 853 // the default value should be returned now. |
| 848 prefs->RemoveManagedPref(prefs::kBlockThirdPartyCookies); | 854 prefs->RemoveManagedPref(prefs::kBlockThirdPartyCookies); |
| 849 EXPECT_FALSE(host_content_settings_map->IsBlockThirdPartyCookiesManaged()); | 855 EXPECT_FALSE(host_content_settings_map->IsBlockThirdPartyCookiesManaged()); |
| 850 EXPECT_FALSE(host_content_settings_map->BlockThirdPartyCookies()); | 856 EXPECT_FALSE(host_content_settings_map->BlockThirdPartyCookies()); |
| 851 } | 857 } |
| 852 | 858 |
| 853 } // namespace | 859 } // namespace |
| OLD | NEW |