| Index: chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
|
| diff --git a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
|
| index e9cc6ccad0a4bfe55a5f232a42b03bee97a3d511..39c2342dcbb3ac5fd29e5b136095e08428c341ad 100644
|
| --- a/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
|
| +++ b/chrome/browser/content_settings/content_settings_policy_provider_unittest.cc
|
| @@ -4,16 +4,19 @@
|
|
|
| #include "chrome/browser/content_settings/content_settings_policy_provider.h"
|
|
|
| +#include "base/auto_reset.h"
|
| +#include "base/command_line.h"
|
| #include "chrome/browser/browser_thread.h"
|
| #include "chrome/browser/content_settings/stub_settings_observer.h"
|
| #include "chrome/browser/prefs/pref_service.h"
|
| +#include "chrome/common/chrome_switches.h"
|
| #include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/test/testing_browser_process_test.h"
|
| #include "chrome/test/testing_pref_service.h"
|
| #include "chrome/test/testing_profile.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
| -
|
| +#include "googleurl/src/gurl.h"
|
|
|
| namespace content_settings {
|
|
|
| @@ -81,4 +84,98 @@ TEST_F(PolicyDefaultProviderTest, ObserveManagedSettingsChange) {
|
| EXPECT_EQ(2, observer.counter);
|
| }
|
|
|
| +class PolicyProviderTest : public testing::Test {
|
| + public:
|
| + PolicyProviderTest()
|
| + : ui_thread_(BrowserThread::UI, &message_loop_) {
|
| + }
|
| +
|
| + protected:
|
| + MessageLoop message_loop_;
|
| + BrowserThread ui_thread_;
|
| +};
|
| +
|
| +TEST_F(PolicyProviderTest, Default) {
|
| + TestingProfile profile;
|
| + TestingPrefService* prefs = profile.GetTestingPrefService();
|
| +
|
| + ListValue* value = new ListValue();
|
| + value->Append(Value::CreateStringValue("[*.]google.com"));
|
| + prefs->SetManagedPref(prefs::kManagedImagesBlockedForUrls,
|
| + value);
|
| +
|
| + PolicyProvider provider(static_cast<Profile*>(&profile));
|
| +
|
| + ContentSettingsPattern yt_url_pattern("www.youtube.com");
|
| + GURL youtube_url("http://www.youtube.com");
|
| + GURL google_url("http://mail.google.com");
|
| +
|
| + EXPECT_EQ(CONTENT_SETTING_DEFAULT,
|
| + provider.GetContentSetting(
|
| + youtube_url, youtube_url, CONTENT_SETTINGS_TYPE_COOKIES, ""));
|
| + EXPECT_EQ(CONTENT_SETTING_BLOCK,
|
| + provider.GetContentSetting(
|
| + google_url, google_url, CONTENT_SETTINGS_TYPE_IMAGES, ""));
|
| +
|
| + provider.SetContentSetting(
|
| + yt_url_pattern,
|
| + yt_url_pattern,
|
| + CONTENT_SETTINGS_TYPE_COOKIES,
|
| + "",
|
| + CONTENT_SETTING_BLOCK);
|
| + EXPECT_EQ(CONTENT_SETTING_DEFAULT,
|
| + provider.GetContentSetting(
|
| + youtube_url, youtube_url, CONTENT_SETTINGS_TYPE_COOKIES, ""));
|
| +}
|
| +
|
| +TEST_F(PolicyProviderTest, ResourceIdentifier) {
|
| + CommandLine* cmd = CommandLine::ForCurrentProcess();
|
| + AutoReset<CommandLine> auto_reset(cmd, *cmd);
|
| + cmd->AppendSwitch(switches::kEnableResourceContentSettings);
|
| +
|
| + TestingProfile profile;
|
| + TestingPrefService* prefs = profile.GetTestingPrefService();
|
| +
|
| + ListValue* value = new ListValue();
|
| + value->Append(Value::CreateStringValue("[*.]google.com"));
|
| + prefs->SetManagedPref(prefs::kManagedPluginsAllowedForUrls,
|
| + value);
|
| +
|
| + PolicyProvider provider(static_cast<Profile*>(&profile));
|
| +
|
| + GURL youtube_url("http://www.youtube.com");
|
| + GURL google_url("http://mail.google.com");
|
| +
|
| + EXPECT_EQ(CONTENT_SETTING_DEFAULT,
|
| + provider.GetContentSetting(
|
| + youtube_url,
|
| + youtube_url,
|
| + CONTENT_SETTINGS_TYPE_PLUGINS,
|
| + "someplugin"));
|
| +
|
| + // There is no policy support for resource content settings until the feature
|
| + // is enabled by default. Resource identifiers are simply ignored by the
|
| + // PolicyProvider.
|
| + EXPECT_EQ(CONTENT_SETTING_ALLOW,
|
| + provider.GetContentSetting(
|
| + google_url,
|
| + google_url,
|
| + CONTENT_SETTINGS_TYPE_PLUGINS,
|
| + ""));
|
| +
|
| + EXPECT_EQ(CONTENT_SETTING_ALLOW,
|
| + provider.GetContentSetting(
|
| + google_url,
|
| + google_url,
|
| + CONTENT_SETTINGS_TYPE_PLUGINS,
|
| + "someplugin"));
|
| +
|
| + EXPECT_EQ(CONTENT_SETTING_ALLOW,
|
| + provider.GetContentSetting(
|
| + google_url,
|
| + google_url,
|
| + CONTENT_SETTINGS_TYPE_PLUGINS,
|
| + "anotherplugin"));
|
| +}
|
| +
|
| } // namespace content_settings
|
|
|