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_pref_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_pref_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/browser_prefs.h" | 10 #include "chrome/browser/prefs/browser_prefs.h" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 | 179 |
180 // Change obsolete preference and test if it migrated correctly. | 180 // Change obsolete preference and test if it migrated correctly. |
181 prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, | 181 prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, |
182 CONTENT_SETTING_BLOCK); | 182 CONTENT_SETTING_BLOCK); |
183 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 183 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
184 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | 184 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
185 | 185 |
186 provider.ShutdownOnUIThread(); | 186 provider.ShutdownOnUIThread(); |
187 } | 187 } |
188 | 188 |
| 189 TEST_F(PrefDefaultProviderTest, AutoSubmitCertificateContentSetting) { |
| 190 TestingProfile profile; |
| 191 TestingPrefService* prefs = profile.GetTestingPrefService(); |
| 192 |
| 193 PrefDefaultProvider provider(prefs, false); |
| 194 |
| 195 EXPECT_EQ(CONTENT_SETTING_ASK, |
| 196 provider.ProvideDefaultSetting( |
| 197 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE)); |
| 198 provider.UpdateDefaultSetting( |
| 199 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, CONTENT_SETTING_ALLOW); |
| 200 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 201 provider.ProvideDefaultSetting( |
| 202 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE)); |
| 203 provider.ShutdownOnUIThread(); |
| 204 } |
| 205 |
189 // //////////////////////////////////////////////////////////////////////////// | 206 // //////////////////////////////////////////////////////////////////////////// |
190 // PrefProviderTest | 207 // PrefProviderTest |
191 // | 208 // |
192 | 209 |
193 bool SettingsEqual(const ContentSettings& settings1, | 210 bool SettingsEqual(const ContentSettings& settings1, |
194 const ContentSettings& settings2) { | 211 const ContentSettings& settings2) { |
195 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { | 212 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) { |
196 if (settings1.settings[i] != settings2.settings[i]) | 213 if (settings1.settings[i] != settings2.settings[i]) |
197 return false; | 214 return false; |
198 } | 215 } |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 secondary_url, | 698 secondary_url, |
682 CONTENT_SETTING_BLOCK); | 699 CONTENT_SETTING_BLOCK); |
683 ExpectObsoleteGeolocationSetting(*geo_settings_dictionary, | 700 ExpectObsoleteGeolocationSetting(*geo_settings_dictionary, |
684 primary_url_2, | 701 primary_url_2, |
685 secondary_url, | 702 secondary_url, |
686 CONTENT_SETTING_BLOCK); | 703 CONTENT_SETTING_BLOCK); |
687 | 704 |
688 provider.ShutdownOnUIThread(); | 705 provider.ShutdownOnUIThread(); |
689 } | 706 } |
690 | 707 |
| 708 TEST_F(PrefProviderTest, AutoSubmitCertificateContentSetting) { |
| 709 TestingProfile profile; |
| 710 TestingPrefService* prefs = profile.GetTestingPrefService(); |
| 711 GURL primary_url("https://www.example.com"); |
| 712 GURL secondary_url("https://www.sample.com"); |
| 713 |
| 714 PrefProvider provider(prefs, false); |
| 715 |
| 716 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 717 provider.GetContentSetting( |
| 718 primary_url, |
| 719 primary_url, |
| 720 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 721 std::string())); |
| 722 |
| 723 provider.SetContentSetting( |
| 724 ContentSettingsPattern::FromURL(primary_url), |
| 725 ContentSettingsPattern::Wildcard(), |
| 726 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 727 std::string(), |
| 728 CONTENT_SETTING_ALLOW); |
| 729 EXPECT_EQ(CONTENT_SETTING_ALLOW, |
| 730 provider.GetContentSetting( |
| 731 primary_url, |
| 732 secondary_url, |
| 733 CONTENT_SETTINGS_TYPE_AUTO_SELECT_CERTIFICATE, |
| 734 std::string())); |
| 735 provider.ShutdownOnUIThread(); |
| 736 } |
| 737 |
691 } // namespace content_settings | 738 } // namespace content_settings |
OLD | NEW |