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

Side by Side Diff: chrome/browser/host_content_settings_map_unittest.cc

Issue 4643007: Move click-to-play to about:flags. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix tests Created 10 years, 1 month 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) 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/host_content_settings_map.h" 5 #include "chrome/browser/host_content_settings_map.h"
6 6
7 #include "base/auto_reset.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "base/json/json_reader.h" 9 #include "base/json/json_reader.h"
9 #include "base/json/json_writer.h" 10 #include "base/json/json_writer.h"
10 #include "chrome/browser/prefs/pref_service.h" 11 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/common/chrome_switches.h" 12 #include "chrome/common/chrome_switches.h"
12 #include "chrome/common/notification_registrar.h" 13 #include "chrome/common/notification_registrar.h"
13 #include "chrome/common/notification_service.h" 14 #include "chrome/common/notification_service.h"
14 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
15 #include "chrome/common/url_constants.h" 16 #include "chrome/common/url_constants.h"
16 #include "chrome/test/testing_profile.h" 17 #include "chrome/test/testing_profile.h"
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 host_content_settings_map->GetDefaultContentSetting( 84 host_content_settings_map->GetDefaultContentSetting(
84 CONTENT_SETTINGS_TYPE_JAVASCRIPT)); 85 CONTENT_SETTINGS_TYPE_JAVASCRIPT));
85 host_content_settings_map->SetDefaultContentSetting( 86 host_content_settings_map->SetDefaultContentSetting(
86 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK); 87 CONTENT_SETTINGS_TYPE_IMAGES, CONTENT_SETTING_BLOCK);
87 EXPECT_EQ(CONTENT_SETTING_BLOCK, 88 EXPECT_EQ(CONTENT_SETTING_BLOCK,
88 host_content_settings_map->GetDefaultContentSetting( 89 host_content_settings_map->GetDefaultContentSetting(
89 CONTENT_SETTINGS_TYPE_IMAGES)); 90 CONTENT_SETTINGS_TYPE_IMAGES));
90 EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting( 91 EXPECT_EQ(CONTENT_SETTING_ALLOW, host_content_settings_map->GetContentSetting(
91 GURL(chrome::kChromeUINewTabURL), 92 GURL(chrome::kChromeUINewTabURL),
92 CONTENT_SETTINGS_TYPE_IMAGES, "")); 93 CONTENT_SETTINGS_TYPE_IMAGES, ""));
93 host_content_settings_map->SetDefaultContentSetting( 94 {
94 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ASK); 95 // Click-to-play needs to be enabled to set the content setting to ASK.
95 EXPECT_EQ(CONTENT_SETTING_ASK, 96 CommandLine* cmd = CommandLine::ForCurrentProcess();
jochen (gone - plz use gerrit) 2010/11/12 13:38:05 can you make the other unit tests use this pattern
96 host_content_settings_map->GetDefaultContentSetting( 97 AutoReset<CommandLine> auto_reset(cmd, *cmd);
97 CONTENT_SETTINGS_TYPE_PLUGINS)); 98 cmd->AppendSwitch(switches::kEnableClickToPlay);
99
100 host_content_settings_map->SetDefaultContentSetting(
101 CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_ASK);
102 EXPECT_EQ(CONTENT_SETTING_ASK,
103 host_content_settings_map->GetDefaultContentSetting(
104 CONTENT_SETTINGS_TYPE_PLUGINS));
105 }
98 host_content_settings_map->SetDefaultContentSetting( 106 host_content_settings_map->SetDefaultContentSetting(
99 CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_ALLOW); 107 CONTENT_SETTINGS_TYPE_POPUPS, CONTENT_SETTING_ALLOW);
100 EXPECT_EQ(CONTENT_SETTING_ALLOW, 108 EXPECT_EQ(CONTENT_SETTING_ALLOW,
101 host_content_settings_map->GetDefaultContentSetting( 109 host_content_settings_map->GetDefaultContentSetting(
102 CONTENT_SETTINGS_TYPE_POPUPS)); 110 CONTENT_SETTINGS_TYPE_POPUPS));
103 host_content_settings_map->ResetToDefaults(); 111 host_content_settings_map->ResetToDefaults();
104 EXPECT_EQ(CONTENT_SETTING_ALLOW, 112 EXPECT_EQ(CONTENT_SETTING_ALLOW,
105 host_content_settings_map->GetDefaultContentSetting( 113 host_content_settings_map->GetDefaultContentSetting(
106 CONTENT_SETTINGS_TYPE_PLUGINS)); 114 CONTENT_SETTINGS_TYPE_PLUGINS));
107 115
(...skipping 631 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 747
740 content_setting_prefs = 748 content_setting_prefs =
741 profile.GetPrefs()->GetDictionary(prefs::kContentSettingsPatterns); 749 profile.GetPrefs()->GetDictionary(prefs::kContentSettingsPatterns);
742 base::JSONWriter::Write(content_setting_prefs, false, &prefs_as_json); 750 base::JSONWriter::Write(content_setting_prefs, false, &prefs_as_json);
743 EXPECT_STREQ("{\"[*.]example.com\":{\"per_plugin\":{\"otherplugin\":2}}}", 751 EXPECT_STREQ("{\"[*.]example.com\":{\"per_plugin\":{\"otherplugin\":2}}}",
744 prefs_as_json.c_str()); 752 prefs_as_json.c_str());
745 *CommandLine::ForCurrentProcess() = cl; 753 *CommandLine::ForCurrentProcess() = cl;
746 } 754 }
747 755
748 } // namespace 756 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698