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 <string> | |
8 | |
7 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
8 #include "base/command_line.h" | 10 #include "base/command_line.h" |
9 #include "chrome/browser/content_settings/content_settings_mock_observer.h" | 11 #include "chrome/browser/content_settings/content_settings_mock_observer.h" |
10 #include "chrome/browser/prefs/pref_service.h" | 12 #include "chrome/browser/prefs/pref_service.h" |
11 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
12 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
13 #include "chrome/common/url_constants.h" | 15 #include "chrome/common/url_constants.h" |
14 #include "chrome/test/base/testing_browser_process_test.h" | 16 #include "chrome/test/base/testing_browser_process_test.h" |
15 #include "chrome/test/base/testing_pref_service.h" | 17 #include "chrome/test/base/testing_pref_service.h" |
16 #include "chrome/test/base/testing_profile.h" | 18 #include "chrome/test/base/testing_profile.h" |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
120 EXPECT_CALL(mock_observer, | 122 EXPECT_CALL(mock_observer, |
121 OnContentSettingChanged(_, | 123 OnContentSettingChanged(_, |
122 _, | 124 _, |
123 CONTENT_SETTINGS_TYPE_DEFAULT, | 125 CONTENT_SETTINGS_TYPE_DEFAULT, |
124 "")); | 126 "")); |
125 // Remove the managed default-content-setting. | 127 // Remove the managed default-content-setting. |
126 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting); | 128 prefs->RemoveManagedPref(prefs::kManagedDefaultImagesSetting); |
127 provider.ShutdownOnUIThread(); | 129 provider.ShutdownOnUIThread(); |
128 } | 130 } |
129 | 131 |
132 TEST_F(PolicyDefaultProviderTest, AutoSelectCertificate) { | |
133 TestingProfile profile; | |
134 TestingPrefService* prefs = profile.GetTestingPrefService(); | |
135 PolicyDefaultProvider provider(prefs); | |
136 | |
137 EXPECT_EQ(CONTENT_SETTING_ASK, | |
138 provider.ProvideDefaultSetting( | |
139 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE)); | |
140 | |
141 provider.ShutdownOnUIThread(); | |
142 } | |
143 | |
130 class PolicyProviderTest : public TestingBrowserProcessTest { | 144 class PolicyProviderTest : public TestingBrowserProcessTest { |
131 public: | 145 public: |
132 PolicyProviderTest() | 146 PolicyProviderTest() |
133 : ui_thread_(BrowserThread::UI, &message_loop_) { | 147 : ui_thread_(BrowserThread::UI, &message_loop_) { |
134 } | 148 } |
135 | 149 |
136 protected: | 150 protected: |
137 // TODO(markusheintz): Check if it's possible to derive the provider class | 151 // TODO(markusheintz): Check if it's possible to derive the provider class |
138 // from NonThreadSafe and to use native thread identifiers instead of | 152 // 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 | 153 // 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, | 230 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
217 provider.GetContentSetting( | 231 provider.GetContentSetting( |
218 google_url, | 232 google_url, |
219 google_url, | 233 google_url, |
220 CONTENT_SETTINGS_TYPE_PLUGINS, | 234 CONTENT_SETTINGS_TYPE_PLUGINS, |
221 "someplugin")); | 235 "someplugin")); |
222 | 236 |
223 provider.ShutdownOnUIThread(); | 237 provider.ShutdownOnUIThread(); |
224 } | 238 } |
225 | 239 |
240 TEST_F(PolicyProviderTest, AutoSelectCertificateList) { | |
241 TestingProfile profile; | |
242 TestingPrefService* prefs = profile.GetTestingPrefService(); | |
243 | |
244 PolicyProvider provider(prefs, NULL); | |
245 GURL google_url("https://mail.google.com"); | |
246 // Tests the default setting for auto selecting certificates | |
247 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | |
248 provider.GetContentSetting( | |
249 google_url, | |
250 google_url, | |
251 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | |
252 std::string())); | |
253 | |
254 // Set the content settings pattern list for origins to auto select | |
255 // certificates. | |
256 ListValue* value = new ListValue(); | |
257 value->Append(Value::CreateStringValue("[*.]google.com")); | |
258 prefs->SetManagedPref(prefs::kManagedAutoSelectCertificateForUrls, | |
259 value); | |
260 GURL youtube_url("https://www.youtube.com"); | |
261 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | |
262 provider.GetContentSetting( | |
263 youtube_url, | |
264 youtube_url, | |
265 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | |
266 std::string())); | |
267 EXPECT_EQ(CONTENT_SETTING_ALLOW, | |
268 provider.GetContentSetting( | |
269 google_url, | |
270 google_url, | |
271 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, | |
272 std::string())); | |
273 | |
274 provider.ShutdownOnUIThread(); | |
275 } | |
226 } // namespace content_settings | 276 } // namespace content_settings |
wtc
2011/08/22 23:58:53
Add a blank line before this line.
| |
OLD | NEW |