Index: chrome/browser/host_content_settings_map_unittest.cc |
=================================================================== |
--- chrome/browser/host_content_settings_map_unittest.cc (revision 66837) |
+++ chrome/browser/host_content_settings_map_unittest.cc (working copy) |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/host_content_settings_map.h" |
+#include "base/auto_reset.h" |
#include "base/command_line.h" |
#include "base/json/json_reader.h" |
#include "base/json/json_writer.h" |
@@ -89,12 +90,19 @@ |
EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( |
GURL(chrome::kChromeUINewTabURL), |
CONTENT_SETTINGS_TYPE_IMAGES, "")); |
+ { |
+ // Click-to-play needs to be enabled to set the content setting to ASK. |
+ CommandLine* cmd = CommandLine::ForCurrentProcess(); |
+ AutoReset<CommandLine> auto_reset(cmd, *cmd); |
+ cmd->AppendSwitch(switches::kEnableClickToPlay); |
+ |
+ host_content_settings_map->SetDefaultContentSetting( |
+ CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ASK); |
+ EXPECT_EQ(CONTENT_SETTING_ASK, |
+ host_content_settings_map->GetDefaultContentSetting( |
+ CONTENT_SETTINGS_TYPE_PLUGINS)); |
+ } |
host_content_settings_map->SetDefaultContentSetting( |
- CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ASK); |
- EXPECT_EQ(CONTENT_SETTING_ASK, |
- host_content_settings_map->GetDefaultContentSetting( |
- CONTENT_SETTINGS_TYPE_PLUGINS)); |
- host_content_settings_map->SetDefaultContentSetting( |
CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_ALLOW); |
EXPECT_EQ(CONTENT_SETTING_ALLOW, |
host_content_settings_map->GetDefaultContentSetting( |
@@ -553,9 +561,9 @@ |
TEST_F(HostContentSettingsMapTest, ResourceIdentifier) { |
// This feature is currently behind a flag. |
- CommandLine cl(*CommandLine::ForCurrentProcess()); |
- CommandLine::ForCurrentProcess()->AppendSwitch( |
- switches::kEnableResourceContentSettings); |
+ CommandLine* cmd = CommandLine::ForCurrentProcess(); |
+ AutoReset<CommandLine> auto_reset(cmd, *cmd); |
+ cmd->AppendSwitch(switches::kEnableResourceContentSettings); |
TestingProfile profile; |
HostContentSettingsMap* host_content_settings_map = |
@@ -577,14 +585,13 @@ |
EXPECT_EQ(CONTENT_SETTING_ALLOW, |
host_content_settings_map->GetContentSetting( |
host, CONTENT_SETTINGS_TYPE_PLUGINS, resource2)); |
- *CommandLine::ForCurrentProcess() = cl; |
} |
TEST_F(HostContentSettingsMapTest, ResourceIdentifierPrefs) { |
// This feature is currently behind a flag. |
- CommandLine cl(*CommandLine::ForCurrentProcess()); |
- CommandLine::ForCurrentProcess()->AppendSwitch( |
- switches::kEnableResourceContentSettings); |
+ CommandLine* cmd = CommandLine::ForCurrentProcess(); |
+ AutoReset<CommandLine> auto_reset(cmd, *cmd); |
+ cmd->AppendSwitch(switches::kEnableResourceContentSettings); |
TestingProfile profile; |
scoped_ptr<Value> value(base::JSONReader::Read( |
@@ -619,7 +626,6 @@ |
base::JSONWriter::Write(content_setting_prefs, false, &prefs_as_json); |
EXPECT_STREQ("{\"[*.]example.com\":{\"per_plugin\":{\"otherplugin\":2}}}", |
prefs_as_json.c_str()); |
- *CommandLine::ForCurrentProcess() = cl; |
} |
} // namespace |