OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/content_settings_policy_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_policy_provider.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 "chrome/browser/content_settings/content_settings_mock_observer.h" |
9 #include "chrome/browser/content_settings/mock_settings_observer.h" | 10 #include "chrome/browser/content_settings/mock_settings_observer.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/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/testing_browser_process_test.h" | 15 #include "chrome/test/testing_browser_process_test.h" |
15 #include "chrome/test/testing_pref_service.h" | 16 #include "chrome/test/testing_pref_service.h" |
16 #include "chrome/test/testing_profile.h" | 17 #include "chrome/test/testing_profile.h" |
17 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 | 103 |
103 TEST_F(PolicyProviderTest, Default) { | 104 TEST_F(PolicyProviderTest, Default) { |
104 TestingProfile profile; | 105 TestingProfile profile; |
105 TestingPrefService* prefs = profile.GetTestingPrefService(); | 106 TestingPrefService* prefs = profile.GetTestingPrefService(); |
106 | 107 |
107 ListValue* value = new ListValue(); | 108 ListValue* value = new ListValue(); |
108 value->Append(Value::CreateStringValue("[*.]google.com")); | 109 value->Append(Value::CreateStringValue("[*.]google.com")); |
109 prefs->SetManagedPref(prefs::kManagedImagesBlockedForUrls, | 110 prefs->SetManagedPref(prefs::kManagedImagesBlockedForUrls, |
110 value); | 111 value); |
111 | 112 |
112 PolicyProvider provider(profile.GetHostContentSettingsMap(), prefs, NULL); | 113 PolicyProvider provider(prefs, NULL); |
113 | 114 |
114 ContentSettingsPattern yt_url_pattern = | 115 ContentSettingsPattern yt_url_pattern = |
115 ContentSettingsPattern::FromString("www.youtube.com"); | 116 ContentSettingsPattern::FromString("www.youtube.com"); |
116 GURL youtube_url("http://www.youtube.com"); | 117 GURL youtube_url("http://www.youtube.com"); |
117 GURL google_url("http://mail.google.com"); | 118 GURL google_url("http://mail.google.com"); |
118 | 119 |
119 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 120 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
120 provider.GetContentSetting( | 121 provider.GetContentSetting( |
121 youtube_url, youtube_url, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 122 youtube_url, youtube_url, CONTENT_SETTINGS_TYPE_COOKIES, "")); |
122 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 123 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
(...skipping 19 matching lines...) Expand all Loading... |
142 cmd->AppendSwitch(switches::kEnableResourceContentSettings); | 143 cmd->AppendSwitch(switches::kEnableResourceContentSettings); |
143 | 144 |
144 TestingProfile profile; | 145 TestingProfile profile; |
145 TestingPrefService* prefs = profile.GetTestingPrefService(); | 146 TestingPrefService* prefs = profile.GetTestingPrefService(); |
146 | 147 |
147 ListValue* value = new ListValue(); | 148 ListValue* value = new ListValue(); |
148 value->Append(Value::CreateStringValue("[*.]google.com")); | 149 value->Append(Value::CreateStringValue("[*.]google.com")); |
149 prefs->SetManagedPref(prefs::kManagedPluginsAllowedForUrls, | 150 prefs->SetManagedPref(prefs::kManagedPluginsAllowedForUrls, |
150 value); | 151 value); |
151 | 152 |
152 PolicyProvider provider(profile.GetHostContentSettingsMap(), prefs, NULL); | 153 PolicyProvider provider(prefs, NULL); |
153 | 154 |
154 GURL youtube_url("http://www.youtube.com"); | 155 GURL youtube_url("http://www.youtube.com"); |
155 GURL google_url("http://mail.google.com"); | 156 GURL google_url("http://mail.google.com"); |
156 | 157 |
157 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 158 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
158 provider.GetContentSetting( | 159 provider.GetContentSetting( |
159 youtube_url, | 160 youtube_url, |
160 youtube_url, | 161 youtube_url, |
161 CONTENT_SETTINGS_TYPE_PLUGINS, | 162 CONTENT_SETTINGS_TYPE_PLUGINS, |
162 "someplugin")); | 163 "someplugin")); |
(...skipping 12 matching lines...) Expand all Loading... |
175 provider.GetContentSetting( | 176 provider.GetContentSetting( |
176 google_url, | 177 google_url, |
177 google_url, | 178 google_url, |
178 CONTENT_SETTINGS_TYPE_PLUGINS, | 179 CONTENT_SETTINGS_TYPE_PLUGINS, |
179 "someplugin")); | 180 "someplugin")); |
180 | 181 |
181 provider.ShutdownOnUIThread(); | 182 provider.ShutdownOnUIThread(); |
182 } | 183 } |
183 | 184 |
184 } // namespace content_settings | 185 } // namespace content_settings |
OLD | NEW |