Chromium Code Reviews| 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 // | |
|
Bernhard Bauer
2011/07/15 13:31:44
Nit: Why the empty comment?
markusheintz_
2011/07/15 16:21:50
Sry. Removed
| |
| 73 prefs->SetInteger(prefs::kGeolocationDefaultContentSetting, | |
| 74 CONTENT_SETTING_ALLOW); | |
| 75 EXPECT_FALSE( | |
| 76 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | |
| 77 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | |
| 78 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | |
| 79 | |
| 80 // | |
| 81 prefs->SetManagedPref(prefs::kGeolocationDefaultContentSetting, | |
| 82 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); | |
| 83 EXPECT_FALSE( | |
| 84 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | |
| 85 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | |
| 86 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | |
| 87 | |
| 88 // Change the managed value of the default geolocation setting | |
| 89 prefs->SetManagedPref(prefs::kManagedDefaultGeolocationSetting, | |
| 90 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); | |
| 91 | |
| 92 EXPECT_TRUE( | |
| 93 provider.DefaultSettingIsManaged(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | |
| 94 EXPECT_EQ(CONTENT_SETTING_BLOCK, | |
| 95 provider.ProvideDefaultSetting(CONTENT_SETTINGS_TYPE_GEOLOCATION)); | |
| 96 | |
| 97 provider.ShutdownOnUIThread(); | |
| 98 } | |
| 99 | |
| 61 // When a default-content-setting is set to a managed setting a | 100 // When a default-content-setting is set to a managed setting a |
| 62 // CONTENT_SETTINGS_CHANGED notification should be fired. The same should happen | 101 // CONTENT_SETTINGS_CHANGED notification should be fired. The same should happen |
| 63 // if the managed setting is removed. | 102 // if the managed setting is removed. |
| 64 TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) { | 103 TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) { |
| 65 TestingProfile profile; | 104 TestingProfile profile; |
| 66 TestingPrefService* prefs = profile.GetTestingPrefService(); | 105 TestingPrefService* prefs = profile.GetTestingPrefService(); |
| 67 PolicyDefaultProvider provider(prefs); | 106 PolicyDefaultProvider provider(prefs); |
| 68 | 107 |
| 69 MockObserver mock_observer; | 108 MockObserver mock_observer; |
| 70 EXPECT_CALL(mock_observer, | 109 EXPECT_CALL(mock_observer, |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 179 provider.GetContentSetting( | 218 provider.GetContentSetting( |
| 180 google_url, | 219 google_url, |
| 181 google_url, | 220 google_url, |
| 182 CONTENT_SETTINGS_TYPE_PLUGINS, | 221 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 183 "someplugin")); | 222 "someplugin")); |
| 184 | 223 |
| 185 provider.ShutdownOnUIThread(); | 224 provider.ShutdownOnUIThread(); |
| 186 } | 225 } |
| 187 | 226 |
| 188 } // namespace content_settings | 227 } // namespace content_settings |
| OLD | NEW |