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/content_settings_mock_observer.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 10 #include "chrome/browser/prefs/pref_service.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 EXPECT_CALL(mock_observer, | 120 EXPECT_CALL(mock_observer, |
121 OnContentSettingChanged(_, | 121 OnContentSettingChanged(_, |
122 _, | 122 _, |
123 CONTENT_SETTINGS_TYPE_DEFAULT, | 123 CONTENT_SETTINGS_TYPE_DEFAULT, |
124 "")); | 124 "")); |
125 // Remove the managed default-content-setting. | 125 // Remove the managed default-content-setting. |
126 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting); | 126 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting); |
127 provider.ShutdownOnUIThread(); | 127 provider.ShutdownOnUIThread(); |
128 } | 128 } |
129 | 129 |
130 TEST_F(PolicyDefaultProviderTest, AutoSubmitCertificateList) { | |
131 TestingProfile profile; | |
132 TestingPrefService* prefs = profile.GetTestingPrefService(); | |
133 PolicyDefaultProvider provider(prefs); | |
134 | |
135 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
136 provider.ProvideDefaultSetting( | |
137 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE)); | |
138 | |
139 provider.ShutdownOnUIThread(); | |
140 } | |
141 | |
130 class PolicyProviderTest : public TestingBrowserProcessTest { | 142 class PolicyProviderTest : public TestingBrowserProcessTest { |
131 public: | 143 public: |
132 PolicyProviderTest() | 144 PolicyProviderTest() |
133 : ui_thread_(BrowserThread::UI, &message_loop_) { | 145 : ui_thread_(BrowserThread::UI, &message_loop_) { |
134 } | 146 } |
135 | 147 |
136 protected: | 148 protected: |
137 // TODO(markusheintz): Check if it's possible to derive the provider class | 149 // TODO(markusheintz): Check if it's possible to derive the provider class |
138 // from NonThreadSafe and to use native thread identifiers instead of | 150 // from NonThreadSafe and to use native thread identifiers instead of |
139 // BrowserThread IDs. Then we could get rid of the message_loop and ui_thread | 151 // BrowserThread IDs. Then we could get rid of the message_loop and ui_thread |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
216 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 228 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
217 provider.GetContentSetting( | 229 provider.GetContentSetting( |
218 google_url, | 230 google_url, |
219 google_url, | 231 google_url, |
220 CONTENT_SETTINGS_TYPE_PLUGINS, | 232 CONTENT_SETTINGS_TYPE_PLUGINS, |
221 "someplugin")); | 233 "someplugin")); |
222 | 234 |
223 provider.ShutdownOnUIThread(); | 235 provider.ShutdownOnUIThread(); |
224 } | 236 } |
225 | 237 |
238 TEST_F(PolicyProviderTest, AutoSubmitCertificateList) { | |
239 TestingProfile profile; | |
240 TestingPrefService* prefs = profile.GetTestingPrefService(); | |
Mattias Nissler (ping if slow)
2011/08/09 15:37:25
Are you actually using |profile|? If not, why not
markusheintz_
2011/08/15 19:09:04
If I use the TestingPrefService I can not set test
| |
241 | |
242 PolicyProvider provider(prefs, NULL); | |
243 GURL google_url("http://mail.google.com"); | |
244 // Tests the default setting for auto submitting certificates | |
245 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | |
246 provider.GetContentSetting( | |
247 google_url, | |
248 google_url, | |
249 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE, | |
250 "")); | |
wtc
2011/08/11 18:33:55
Nit: please pick either "" or std::string() for an
markusheintz_
2011/08/15 19:09:04
Done.
| |
251 | |
252 // Set the content settings pattern list for origins to auto submit | |
253 // certificates. | |
254 ListValue* value = new ListValue(); | |
255 value->Append(Value::CreateStringValue("[*.]google.com")); | |
256 prefs->SetManagedPref(prefs::kManagedAutoSubmitCertificateForUrls, | |
257 value); | |
258 GURL youtube_url("http://www.youtube.com"); | |
259 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | |
Mattias Nissler (ping if slow)
2011/08/09 15:37:25
indentation
markusheintz_
2011/08/15 19:09:04
Done.
| |
260 provider.GetContentSetting( | |
261 youtube_url, | |
262 youtube_url, | |
263 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE, | |
264 "")); | |
265 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
266 provider.GetContentSetting( | |
267 google_url, | |
268 google_url, | |
269 CONTENT_SETTINGS_TYPE_AUTO_SUBMIT_CERTIFICATE, | |
270 "")); | |
271 | |
272 provider.ShutdownOnUIThread(); | |
273 } | |
226 } // namespace content_settings | 274 } // namespace content_settings |
OLD | NEW |