diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-02 18:14:21 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-08-02 18:14:21 +0000 |
commit | 134efc37e03e2d8da955f855533fbb5c7c6177f1 (patch) | |
tree | 307f5bfe28028059dceede57b82a11c94c65258f /chrome | |
parent | 99180a976cf6abec822c07be852973d83519edd7 (diff) | |
download | chromium_src-134efc37e03e2d8da955f855533fbb5c7c6177f1.zip chromium_src-134efc37e03e2d8da955f855533fbb5c7c6177f1.tar.gz chromium_src-134efc37e03e2d8da955f855533fbb5c7c6177f1.tar.bz2 |
Don't reset blocked content for in-page navigations.
BUG=91335
TEST=see bug
Review URL: http://codereview.chromium.org/7551007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@95110 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/renderer/content_settings_observer.cc | 16 | ||||
-rw-r--r-- | chrome/renderer/content_settings_observer_browsertest.cc | 31 |
2 files changed, 41 insertions, 6 deletions
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc index b3df59f..59f58df 100644 --- a/chrome/renderer/content_settings_observer.cc +++ b/chrome/renderer/content_settings_observer.cc @@ -8,6 +8,7 @@ #include "chrome/common/url_constants.h" #include "content/common/database_messages.h" #include "content/common/view_messages.h" +#include "content/renderer/navigation_state.h" #include "content/renderer/render_view.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDataSource.h" #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" @@ -114,12 +115,15 @@ void ContentSettingsObserver::DidCommitProvisionalLoad( if (frame->parent()) return; // Not a top-level navigation. - // Clear "block" flags for the new page. This needs to happen before any of - // allowScripts(), allowImages(), allowPlugins() is called for the new page - // so that these functions can correctly detect that a piece of content - // flipped from "not blocked" to "blocked". - ClearBlockedContentSettings(); - plugins_temporarily_allowed_ = false; + NavigationState* state = NavigationState::FromDataSource(frame->dataSource()); + if (!state->was_within_same_page()) { + // Clear "block" flags for the new page. This needs to happen before any of + // allowScripts(), allowImages(), allowPlugins() is called for the new page + // so that these functions can correctly detect that a piece of content + // flipped from "not blocked" to "blocked". + ClearBlockedContentSettings(); + plugins_temporarily_allowed_ = false; + } GURL url = frame->document().url(); diff --git a/chrome/renderer/content_settings_observer_browsertest.cc b/chrome/renderer/content_settings_observer_browsertest.cc index 2f1dd54..8fbea14 100644 --- a/chrome/renderer/content_settings_observer_browsertest.cc +++ b/chrome/renderer/content_settings_observer_browsertest.cc @@ -138,3 +138,34 @@ TEST_F(RenderViewTest, JSBlockSentAfterPageLoad) { EXPECT_NE(-1, block_index); EXPECT_LT(navigation_index, block_index); } + +TEST_F(RenderViewTest, PluginsTemporarilyAllowed) { + // Load some HTML. + LoadHTML("<html>Foo</html>"); + + // Block plugins. + ContentSettings settings; + for (int i = 0; i < CONTENT_SETTINGS_NUM_TYPES; ++i) + settings.settings[i] = CONTENT_SETTING_ALLOW; + settings.settings[CONTENT_SETTINGS_TYPE_PLUGINS] = CONTENT_SETTING_BLOCK; + ContentSettingsObserver* observer = ContentSettingsObserver::Get(view_); + observer->SetContentSettings(settings); + ContentSettingsObserver::SetDefaultContentSettings(settings); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); + + // Temporarily allow plugins. + view_->OnMessageReceived(ViewMsg_LoadBlockedPlugins(MSG_ROUTING_NONE)); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); + + // Simulate a navigation within the page. + view_->didNavigateWithinPage(GetMainFrame(), true); + EXPECT_EQ(CONTENT_SETTING_ALLOW, + observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); + + // Navigate to a different page. + LoadHTML("<html>Bar</html>"); + EXPECT_EQ(CONTENT_SETTING_BLOCK, + observer->GetContentSetting(CONTENT_SETTINGS_TYPE_PLUGINS)); +} |