| 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/mock_settings_observer.h" | 10 #include "chrome/browser/content_settings/mock_settings_observer.h" |
| 10 #include "chrome/browser/prefs/pref_service.h" | 11 #include "chrome/browser/prefs/pref_service.h" |
| 11 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
| 12 #include "chrome/common/pref_names.h" | 13 #include "chrome/common/pref_names.h" |
| 13 #include "chrome/common/url_constants.h" | 14 #include "chrome/common/url_constants.h" |
| 14 #include "chrome/test/testing_browser_process_test.h" | 15 #include "chrome/test/testing_browser_process_test.h" |
| 15 #include "chrome/test/testing_pref_service.h" | 16 #include "chrome/test/testing_pref_service.h" |
| 16 #include "chrome/test/testing_profile.h" | 17 #include "chrome/test/testing_profile.h" |
| 17 #include "content/browser/browser_thread.h" | 18 #include "content/browser/browser_thread.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 103 |
| 103 TEST_F(PolicyProviderTest, Default) { | 104 TEST_F(PolicyProviderTest, Default) { |
| 104 TestingProfile profile; | 105 TestingProfile profile; |
| 105 TestingPrefService* prefs = profile.GetTestingPrefService(); | 106 TestingPrefService* prefs = profile.GetTestingPrefService(); |
| 106 | 107 |
| 107 ListValue* value = new ListValue(); | 108 ListValue* value = new ListValue(); |
| 108 value->Append(Value::CreateStringValue("[*.]google.com")); | 109 value->Append(Value::CreateStringValue("[*.]google.com")); |
| 109 prefs->SetManagedPref(prefs::kManagedImagesBlockedForUrls, | 110 prefs->SetManagedPref(prefs::kManagedImagesBlockedForUrls, |
| 110 value); | 111 value); |
| 111 | 112 |
| 112 PolicyProvider provider(profile.GetHostContentSettingsMap(), prefs, NULL); | 113 |
| 114 content_settings::MockObserver mock_observer; |
| 115 PolicyProvider provider(&mock_observer, prefs, NULL); |
| 113 | 116 |
| 114 ContentSettingsPattern yt_url_pattern = | 117 ContentSettingsPattern yt_url_pattern = |
| 115 ContentSettingsPattern::FromString("www.youtube.com"); | 118 ContentSettingsPattern::FromString("www.youtube.com"); |
| 116 GURL youtube_url("http://www.youtube.com"); | 119 GURL youtube_url("http://www.youtube.com"); |
| 117 GURL google_url("http://mail.google.com"); | 120 GURL google_url("http://mail.google.com"); |
| 118 | 121 |
| 119 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 122 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 120 provider.GetContentSetting( | 123 provider.GetContentSetting( |
| 121 youtube_url, youtube_url, CONTENT_SETTINGS_TYPE_COOKIES, "")); | 124 youtube_url, youtube_url, CONTENT_SETTINGS_TYPE_COOKIES, "")); |
| 122 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 125 EXPECT_EQ(CONTENT_SETTING_BLOCK, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 142 cmd->AppendSwitch(switches::kEnableResourceContentSettings); | 145 cmd->AppendSwitch(switches::kEnableResourceContentSettings); |
| 143 | 146 |
| 144 TestingProfile profile; | 147 TestingProfile profile; |
| 145 TestingPrefService* prefs = profile.GetTestingPrefService(); | 148 TestingPrefService* prefs = profile.GetTestingPrefService(); |
| 146 | 149 |
| 147 ListValue* value = new ListValue(); | 150 ListValue* value = new ListValue(); |
| 148 value->Append(Value::CreateStringValue("[*.]google.com")); | 151 value->Append(Value::CreateStringValue("[*.]google.com")); |
| 149 prefs->SetManagedPref(prefs::kManagedPluginsAllowedForUrls, | 152 prefs->SetManagedPref(prefs::kManagedPluginsAllowedForUrls, |
| 150 value); | 153 value); |
| 151 | 154 |
| 152 PolicyProvider provider(profile.GetHostContentSettingsMap(), prefs, NULL); | 155 content_settings::MockObserver mock_observer; |
| 156 PolicyProvider provider(&mock_observer, prefs, NULL); |
| 153 | 157 |
| 154 GURL youtube_url("http://www.youtube.com"); | 158 GURL youtube_url("http://www.youtube.com"); |
| 155 GURL google_url("http://mail.google.com"); | 159 GURL google_url("http://mail.google.com"); |
| 156 | 160 |
| 157 EXPECT_EQ(CONTENT_SETTING_DEFAULT, | 161 EXPECT_EQ(CONTENT_SETTING_DEFAULT, |
| 158 provider.GetContentSetting( | 162 provider.GetContentSetting( |
| 159 youtube_url, | 163 youtube_url, |
| 160 youtube_url, | 164 youtube_url, |
| 161 CONTENT_SETTINGS_TYPE_PLUGINS, | 165 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 162 "someplugin")); | 166 "someplugin")); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 175 provider.GetContentSetting( | 179 provider.GetContentSetting( |
| 176 google_url, | 180 google_url, |
| 177 google_url, | 181 google_url, |
| 178 CONTENT_SETTINGS_TYPE_PLUGINS, | 182 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 179 "someplugin")); | 183 "someplugin")); |
| 180 | 184 |
| 181 provider.ShutdownOnUIThread(); | 185 provider.ShutdownOnUIThread(); |
| 182 } | 186 } |
| 183 | 187 |
| 184 } // namespace content_settings | 188 } // namespace content_settings |
| OLD | NEW |