| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_COOKIES)); | 51 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_COOKIES)); |
| 52 | 52 |
| 53 // Remove managed-default-content-settings-preferences. | 53 // Remove managed-default-content-settings-preferences. |
| 54 prefs->RemoveManagedPref(prefs::kManagedDefaultCookiesSetting); | 54 prefs->RemoveManagedPref(prefs::kManagedDefaultCookiesSetting); |
| 55 ASSERT_FALSE( | 55 ASSERT_FALSE( |
| 56 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_COOKIES)); | 56 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_COOKIES)); |
| 57 | 57 |
| 58 provider.ShutdownOnUIThread(); | 58 provider.ShutdownOnUIThread(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 TEST_F(PolicyDefaultProviderTest, DefaultGeolocationContentSetting) { |
| 62 TestingProfile profile; |
| 63 TestingPrefService* prefs = profile.GetTestingPrefService(); |
| 64 PolicyDefaultProvider provider(prefs); |
| 65 |
| 66 // By default, policies should be off. |
| 67 EXPECT_FALSE( |
| 68 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 69 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 70 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 71 |
| 72 prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, |
| 73 CONTENT_SETTING_ALLOW); |
| 74 EXPECT_FALSE( |
| 75 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 76 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 77 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 78 |
| 79 // |
| 80 prefs->SetManagedPref(prefs::kGeolocationDefaultContentSetting, |
| 81 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); |
| 82 EXPECT_FALSE( |
| 83 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 84 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 85 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 86 |
| 87 // Change the managed value of the default geolocation setting |
| 88 prefs->SetManagedPref(prefs::kManagedDefaultGeolocationSetting, |
| 89 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); |
| 90 |
| 91 EXPECT_TRUE( |
| 92 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 93 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| 94 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); |
| 95 |
| 96 provider.ShutdownOnUIThread(); |
| 97 } |
| 98 |
| 61 // When a default-content-setting is set to a managed setting a | 99 // When a default-content-setting is set to a managed setting a |
| 62 // CONTENT_SETTINGS_CHANGED notification should be fired. The same should happen | 100 // CONTENT_SETTINGS_CHANGED notification should be fired. The same should happen |
| 63 // if the managed setting is removed. | 101 // if the managed setting is removed. |
| 64 TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) { | 102 TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) { |
| 65 TestingProfile profile; | 103 TestingProfile profile; |
| 66 TestingPrefService* prefs = profile.GetTestingPrefService(); | 104 TestingPrefService* prefs = profile.GetTestingPrefService(); |
| 67 PolicyDefaultProvider provider(prefs); | 105 PolicyDefaultProvider provider(prefs); |
| 68 | 106 |
| 69 MockObserver mock_observer; | 107 MockObserver mock_observer; |
| 70 EXPECT_CALL(mock_observer, | 108 EXPECT_CALL(mock_observer, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 provider.GetContentSetting( | 217 provider.GetContentSetting( |
| 180 google_url, | 218 google_url, |
| 181 google_url, | 219 google_url, |
| 182 CONTENT_SETTINGS_TYPE_PLUGINS, | 220 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 183 "someplugin")); | 221 "someplugin")); |
| 184 | 222 |
| 185 provider.ShutdownOnUIThread(); | 223 provider.ShutdownOnUIThread(); |
| 186 } | 224 } |
| 187 | 225 |
| 188 } // namespace content_settings | 226 } // namespace content_settings |
| OLD | NEW |