| 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/common/content_settings.h" | 5 #include "chrome/common/content_settings.h" |
| 6 #include "chrome/common/render_messages.h" | 6 #include "chrome/common/render_messages.h" |
| 7 #include "chrome/renderer/content_settings_observer.h" | 7 #include "chrome/renderer/content_settings_observer.h" |
| 8 #include "chrome/test/base/chrome_render_view_test.h" | 8 #include "chrome/test/base/chrome_render_view_test.h" |
| 9 #include "content/public/renderer/render_view.h" | 9 #include "content/public/renderer/render_view.h" |
| 10 #include "ipc/ipc_message_macros.h" | 10 #include "ipc/ipc_message_macros.h" |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 LoadHTML("<html>Foo</html>"); | 141 LoadHTML("<html>Foo</html>"); |
| 142 | 142 |
| 143 // Block plugins. | 143 // Block plugins. |
| 144 ContentSettings settings; | 144 ContentSettings settings; |
| 145 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) | 145 for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) |
| 146 settings.settings[i] = CONTENT_SETTING_ALLOW; | 146 settings.settings[i] = CONTENT_SETTING_ALLOW; |
| 147 settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = CONTENT_SETTING_BLOCK; | 147 settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = CONTENT_SETTING_BLOCK; |
| 148 ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); | 148 ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); |
| 149 observer->SetContentSettings(settings); | 149 observer->SetContentSettings(settings); |
| 150 ContentSettingsObserver::SetDefaultContentSettings(settings); | 150 ContentSettingsObserver::SetDefaultContentSettings(settings); |
| 151 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 151 EXPECT_FALSE(observer->plugins_temporarily_allowed()); |
| 152 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); | |
| 153 | 152 |
| 154 // Temporarily allow plugins. | 153 // Temporarily allow plugins. |
| 155 OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE)); | 154 OnMessageReceived(ChromeViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE)); |
| 156 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 155 EXPECT_TRUE(observer->plugins_temporarily_allowed()); |
| 157 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); | |
| 158 | 156 |
| 159 // Simulate a navigation within the page. | 157 // Simulate a navigation within the page. |
| 160 DidNavigateWithinPage(GetMainFrame(), true); | 158 DidNavigateWithinPage(GetMainFrame(), true); |
| 161 EXPECT_EQ(CONTENT_SETTING_ALLOW, | 159 EXPECT_TRUE(observer->plugins_temporarily_allowed()); |
| 162 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); | |
| 163 | 160 |
| 164 // Navigate to a different page. | 161 // Navigate to a different page. |
| 165 LoadHTML("<html>Bar</html>"); | 162 LoadHTML("<html>Bar</html>"); |
| 166 EXPECT_EQ(CONTENT_SETTING_BLOCK, | 163 EXPECT_FALSE(observer->plugins_temporarily_allowed()); |
| 167 observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); | |
| 168 } | 164 } |
| OLD | NEW |