diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 17:09:33 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-05-13 17:09:33 +0000 |
commit | 3c30b80afe18c734beb1beca6ea5ef7b6fc490af (patch) | |
tree | 2c27b933b881dbc09115a967087fad7065d5041f | |
parent | 008ad53a782a8f5c8226f67734725f0d4652c7ff (diff) | |
download | chromium_src-3c30b80afe18c734beb1beca6ea5ef7b6fc490af.zip chromium_src-3c30b80afe18c734beb1beca6ea5ef7b6fc490af.tar.gz chromium_src-3c30b80afe18c734beb1beca6ea5ef7b6fc490af.tar.bz2 |
Revert 85278 - Move TabSpecificContentSettings to TabContentWrapper.
Review URL: http://codereview.chromium.org/7012033
TBR=jam@chromium.org
Review URL: http://codereview.chromium.org/7015047
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85285 0039d316-1c4b-4281-b951-d872f2087c98
22 files changed, 117 insertions, 137 deletions
diff --git a/chrome/browser/content_settings/content_settings_browsertest.cc b/chrome/browser/content_settings/content_settings_browsertest.cc deleted file mode 100644 index b1e5556..0000000 --- a/chrome/browser/content_settings/content_settings_browsertest.cc +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#include "base/utf_string_conversions.h" -#include "chrome/browser/content_settings/host_content_settings_map.h" -#include "chrome/browser/content_settings/tab_specific_content_settings.h" -#include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/browser.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/test/in_process_browser_test.h" -#include "chrome/test/ui_test_utils.h" -#include "net/test/test_server.h" - -// Regression test for http://crbug.com/63649. -IN_PROC_BROWSER_TEST_F(InProcessBrowserTest, RedirectLoopCookies) { - ASSERT_TRUE(test_server()->Start()); - - GURL test_url = test_server()->GetURL("files/redirect-loop.html"); - - browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( - CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); - - ui_test_utils::NavigateToURL(browser(), test_url); - - TabContentsWrapper* tab_contents = browser()->GetSelectedTabContentsWrapper(); - ASSERT_EQ(UTF8ToUTF16(test_url.spec() + " failed to load"), - tab_contents->tab_contents()->GetTitle()); - - EXPECT_TRUE(tab_contents->content_settings()->IsContentBlocked( - CONTENT_SETTINGS_TYPE_COOKIES)); -} diff --git a/chrome/browser/geolocation/geolocation_browsertest.cc b/chrome/browser/geolocation/geolocation_browsertest.cc index b730d83..38adc83 100644 --- a/chrome/browser/geolocation/geolocation_browsertest.cc +++ b/chrome/browser/geolocation/geolocation_browsertest.cc @@ -14,7 +14,6 @@ #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" #include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser_list.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/chrome_paths.h" #include "chrome/test/in_process_browser_test.h" #include "chrome/test/ui_test_utils.h" @@ -308,10 +307,8 @@ class GeolocationBrowserTest : public InProcessBrowserTest { void SetInfobarResponse(const GURL& requesting_url, bool allowed) { TabContents* tab_contents = current_browser_->GetSelectedTabContents(); - TabContentsWrapper* tab_contents_wrapper = - current_browser_->GetSelectedTabContentsWrapper(); TabSpecificContentSettings* content_settings = - tab_contents_wrapper->content_settings(); + tab_contents->GetTabSpecificContentSettings(); const GeolocationSettingsState& settings_state = content_settings->geolocation_settings_state(); size_t state_map_size = settings_state.state_map().size(); diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/geolocation_permission_context.cc index 6bb651f..7fe6c33 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.cc +++ b/chrome/browser/geolocation/geolocation_permission_context.cc @@ -579,10 +579,13 @@ void GeolocationPermissionContext::NotifyPermissionSet( bool allowed) { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); + TabContents* tab_contents = + tab_util::GetTabContentsByID(render_process_id, render_view_id); + // TabContents may have gone away (or not exists for extension). - TabSpecificContentSettings* content_settings = - TabSpecificContentSettings::Get(render_process_id, render_view_id); - if (content_settings) { + if (tab_contents) { + TabSpecificContentSettings* content_settings = + tab_contents->GetTabSpecificContentSettings(); content_settings->OnGeolocationPermissionSet(requesting_frame.GetOrigin(), allowed); } diff --git a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc index dbfd59c..3720310 100644 --- a/chrome/browser/geolocation/geolocation_permission_context_unittest.cc +++ b/chrome/browser/geolocation/geolocation_permission_context_unittest.cc @@ -6,8 +6,6 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" #include "chrome/browser/tab_contents/confirm_infobar_delegate.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/testing_profile.h" #include "content/browser/browser_thread.h" #include "content/browser/geolocation/arbitrator_dependency_factories_for_test.h" @@ -16,6 +14,7 @@ #include "content/browser/geolocation/location_provider.h" #include "content/browser/geolocation/mock_location_provider.h" #include "content/browser/renderer_host/mock_render_process_host.h" +#include "content/browser/renderer_host/test_render_view_host.h" #include "content/browser/tab_contents/test_tab_contents.h" #include "content/common/geolocation_messages.h" #include "content/common/notification_details.h" @@ -68,7 +67,7 @@ void TestTabContentsWithPendingInfoBar::Observe( // GeolocationPermissionContextTests ------------------------------------------ // This class sets up GeolocationArbitrator. -class GeolocationPermissionContextTests : public TabContentsWrapperTestHarness { +class GeolocationPermissionContextTests : public RenderViewHostTestHarness { public: GeolocationPermissionContextTests(); @@ -99,7 +98,7 @@ class GeolocationPermissionContextTests : public TabContentsWrapperTestHarness { ScopedVector<TestTabContentsWithPendingInfoBar> extra_tabs_; private: - // TabContentsWrapperTestHarness: + // RenderViewHostTestHarness: virtual void SetUp(); virtual void TearDown(); @@ -108,7 +107,8 @@ class GeolocationPermissionContextTests : public TabContentsWrapperTestHarness { }; GeolocationPermissionContextTests::GeolocationPermissionContextTests() - : tab_contents_with_pending_infobar_(NULL), + : RenderViewHostTestHarness(), + tab_contents_with_pending_infobar_(NULL), ui_thread_(BrowserThread::UI, MessageLoop::current()), dependency_factory_( new GeolocationArbitratorDependencyFactoryWithLocationProvider( @@ -161,7 +161,7 @@ void GeolocationPermissionContextTests::CheckTabContentsState( const GURL& requesting_frame, ContentSetting expected_content_setting) { TabSpecificContentSettings* content_settings = - contents_wrapper()->content_settings(); + contents()->GetTabSpecificContentSettings(); const GeolocationSettingsState::StateMap& state_map = content_settings->geolocation_settings_state().state_map(); EXPECT_EQ(1U, state_map.count(requesting_frame.GetOrigin())); @@ -174,7 +174,7 @@ void GeolocationPermissionContextTests::CheckTabContentsState( } void GeolocationPermissionContextTests::SetUp() { - TabContentsWrapperTestHarness::SetUp(); + RenderViewHostTestHarness::SetUp(); GeolocationArbitrator::SetDependencyFactoryForTest( dependency_factory_.get()); SiteInstance* site_instance = contents()->GetSiteInstance(); @@ -187,7 +187,7 @@ void GeolocationPermissionContextTests::SetUp() { void GeolocationPermissionContextTests::TearDown() { GeolocationArbitrator::SetDependencyFactoryForTest(NULL); - TabContentsWrapperTestHarness::TearDown(); + RenderViewHostTestHarness::TearDown(); } diff --git a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc index 6cf4a6d..fe472a6 100644 --- a/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc +++ b/chrome/browser/ui/blocked_content/blocked_content_tab_helper.cc @@ -43,7 +43,7 @@ void BlockedContentTabHelper::PopupNotificationVisibilityChanged( bool visible) { if (tab_contents()->is_being_destroyed()) return; - tab_contents_wrapper_->content_settings()->SetPopupsBlocked(visible); + tab_contents()->GetTabSpecificContentSettings()->SetPopupsBlocked(visible); } void BlockedContentTabHelper::SetAllContentsBlocked(bool value) { @@ -96,7 +96,7 @@ void BlockedContentTabHelper::AddPopup(TabContentsWrapper* new_contents, NEW_POPUP, initial_pos, true); // user_gesture - tab_contents_wrapper_->content_settings()->OnContentBlocked( + tab_contents()->GetTabSpecificContentSettings()->OnContentBlocked( CONTENT_SETTINGS_TYPE_POPUPS, std::string()); } } diff --git a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm index 43854cb..ff1c330 100644 --- a/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm +++ b/chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.mm @@ -14,7 +14,6 @@ #import "chrome/browser/ui/cocoa/content_settings/cookie_details_view_controller.h" #import "chrome/browser/ui/cocoa/vertical_gradient_view.h" #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/common/notification_details.h" #include "content/common/notification_source.h" @@ -82,8 +81,7 @@ CollectedCookiesMac::CollectedCookiesMac(NSWindow* parent, @selector(sheetDidEnd:returnCode:contextInfo:)), tab_contents_(tab_contents) { TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> - content_settings(); + tab_contents->GetTabSpecificContentSettings(); registrar_.Add(this, NotificationType::COLLECTED_COOKIES_SHOWN, Source<TabSpecificContentSettings>(content_settings)); @@ -111,6 +109,8 @@ void CollectedCookiesMac::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK(type == NotificationType::COLLECTED_COOKIES_SHOWN); + DCHECK_EQ(Source<TabSpecificContentSettings>(source).ptr(), + tab_contents_->GetTabSpecificContentSettings()); window_->CloseConstrainedWindow(); } @@ -355,8 +355,7 @@ void CollectedCookiesMac::OnSheetDidEnd(NSWindow* sheet) { // the |cocoaAllowedTreeModel_| and |cocoaBlockedTreeModel_|. - (void)loadTreeModelFromTabContents { TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tabContents_)-> - content_settings(); + tabContents_->GetTabSpecificContentSettings(); allowedTreeModel_.reset(content_settings->GetAllowedCookiesTreeModel()); blockedTreeModel_.reset(content_settings->GetBlockedCookiesTreeModel()); diff --git a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm index 1283bc0..e1f5775 100644 --- a/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm +++ b/chrome/browser/ui/cocoa/location_bar/content_setting_decoration.mm @@ -193,8 +193,7 @@ bool ContentSettingDecoration::UpdateFromTabContents( // Check if the animation has already run. TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> - content_settings(); + tab_contents->GetTabSpecificContentSettings(); ContentSettingsType content_type = content_setting_image_model_->get_content_settings_type(); bool ran_animation = content_settings->IsBlockageIndicated(content_type); diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc index d798a70..e57d243 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -44,7 +44,8 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { private: void SetBlockedResources() { - TabSpecificContentSettings* settings = tab_contents()->content_settings(); + TabSpecificContentSettings* settings = tab_contents()-> + tab_contents()->GetTabSpecificContentSettings(); const std::set<std::string>& resources = settings->BlockedResourcesForType( content_type()); for (std::set<std::string>::const_iterator it = resources.begin(); @@ -93,9 +94,11 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { CONTENT_SETTINGS_NUM_TYPES, Need_a_setting_for_every_content_settings_type); const int *title_ids = kBlockedTitleIDs; - if (tab_contents() && tab_contents()->content_settings()-> + if (tab_contents() && + tab_contents()->tab_contents()->GetTabSpecificContentSettings()-> IsContentAccessed(content_type()) && - !tab_contents()->content_settings()->IsContentBlocked(content_type())) { + !tab_contents()->tab_contents()->GetTabSpecificContentSettings()-> + IsContentBlocked(content_type())) { title_ids = kAccessedTitleIDs; } else if (!bubble_content().resource_identifiers.empty()) { title_ids = kResourceSpecificBlockedTitleIDs; @@ -331,14 +334,15 @@ class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { private: virtual void OnCustomLinkClicked() OVERRIDE { - if (!tab_contents()) - return; - NotificationService::current()->Notify( - NotificationType::COLLECTED_COOKIES_SHOWN, - Source<TabSpecificContentSettings>(tab_contents()->content_settings()), - NotificationService::NoDetails()); - tab_contents()->tab_contents()->delegate()-> - ShowCollectedCookiesDialog(tab_contents()->tab_contents()); + if (tab_contents()) { + NotificationService::current()->Notify( + NotificationType::COLLECTED_COOKIES_SHOWN, + Source<TabSpecificContentSettings>( + tab_contents()->tab_contents()->GetTabSpecificContentSettings()), + NotificationService::NoDetails()); + tab_contents()->tab_contents()->delegate()-> + ShowCollectedCookiesDialog(tab_contents()->tab_contents()); + } } }; @@ -349,8 +353,8 @@ class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { ContentSettingsType content_type) : ContentSettingSingleRadioGroup(tab_contents, profile, content_type) { DCHECK_EQ(content_type, CONTENT_SETTINGS_TYPE_PLUGINS); - set_custom_link_enabled(tab_contents && tab_contents->content_settings()-> - load_plugins_link_enabled()); + set_custom_link_enabled(tab_contents && tab_contents->tab_contents()-> + GetTabSpecificContentSettings()->load_plugins_link_enabled()); } virtual ~ContentSettingPluginBubbleModel() {} @@ -362,7 +366,8 @@ class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { RenderViewHost* host = tab_contents()->render_view_host(); host->Send(new ViewMsg_LoadBlockedPlugins(host->routing_id())); set_custom_link_enabled(false); - tab_contents()->content_settings()->set_load_plugins_link_enabled(false); + tab_contents()->tab_contents()->GetTabSpecificContentSettings()-> + set_load_plugins_link_enabled(false); } }; @@ -430,7 +435,7 @@ class ContentSettingDomainListBubbleModel } void SetDomainsAndCustomLink() { TabSpecificContentSettings* content_settings = - tab_contents()->content_settings(); + tab_contents()->tab_contents()->GetTabSpecificContentSettings(); const GeolocationSettingsState& settings = content_settings->geolocation_settings_state(); GeolocationSettingsState::FormattedHostsPerState formatted_hosts_per_state; @@ -461,7 +466,7 @@ class ContentSettingDomainListBubbleModel // origins currently on the page. const GURL& embedder_url = tab_contents()->tab_contents()->GetURL(); TabSpecificContentSettings* content_settings = - tab_contents()->content_settings(); + tab_contents()->tab_contents()->GetTabSpecificContentSettings(); const GeolocationSettingsState::StateMap& state_map = content_settings->geolocation_settings_state().state_map(); GeolocationContentSettingsMap* settings_map = diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc index 74c5fa5..4a8d606 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model_unittest.cc @@ -9,7 +9,6 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" #include "chrome/browser/ui/content_settings/content_setting_bubble_model.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/common/chrome_switches.h" #include "chrome/test/testing_profile.h" @@ -47,7 +46,7 @@ class ContentSettingBubbleModelTest : public TabContentsWrapperTestHarness { TEST_F(ContentSettingBubbleModelTest, ImageRadios) { TabSpecificContentSettings* content_settings = - contents_wrapper()->content_settings(); + contents()->GetTabSpecificContentSettings(); content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, std::string()); @@ -65,7 +64,7 @@ TEST_F(ContentSettingBubbleModelTest, ImageRadios) { TEST_F(ContentSettingBubbleModelTest, Cookies) { TabSpecificContentSettings* content_settings = - contents_wrapper()->content_settings(); + contents()->GetTabSpecificContentSettings(); content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_COOKIES, std::string()); @@ -83,7 +82,7 @@ TEST_F(ContentSettingBubbleModelTest, Cookies) { TEST_F(ContentSettingBubbleModelTest, Plugins) { TabSpecificContentSettings* content_settings = - contents_wrapper()->content_settings(); + contents()->GetTabSpecificContentSettings(); content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, std::string()); @@ -119,7 +118,7 @@ TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) { CONTENT_SETTING_ASK); TabSpecificContentSettings* content_settings = - contents_wrapper()->content_settings(); + contents()->GetTabSpecificContentSettings(); content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, fooPlugin); content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_PLUGINS, @@ -163,7 +162,7 @@ TEST_F(ContentSettingBubbleModelTest, Geolocation) { NavigateAndCommit(page_url); TabSpecificContentSettings* content_settings = - contents_wrapper()->content_settings(); + contents()->GetTabSpecificContentSettings(); // One permitted frame, but not in the content map: requires reload. content_settings->OnGeolocationPermissionSet(frame1_url, true); diff --git a/chrome/browser/ui/content_settings/content_setting_image_model.cc b/chrome/browser/ui/content_settings/content_setting_image_model.cc index 6e839b4..48314c55 100644 --- a/chrome/browser/ui/content_settings/content_setting_image_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_image_model.cc @@ -9,7 +9,6 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/tab_contents/tab_contents.h" #include "grit/generated_resources.h" #include "grit/theme_resources.h" @@ -119,8 +118,7 @@ void ContentSettingBlockedImageModel::UpdateFromTabContents( // If a content type is blocked by default and was accessed, display the // accessed icon. TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> - content_settings(); + tab_contents->GetTabSpecificContentSettings(); if (!content_settings->IsContentBlocked(get_content_settings_type())) { if (!content_settings->IsContentAccessed(get_content_settings_type()) || (tab_contents->profile()->GetHostContentSettingsMap()-> @@ -148,11 +146,8 @@ void ContentSettingGeolocationImageModel::UpdateFromTabContents( set_visible(false); if (!tab_contents) return; - TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> - content_settings(); - const GeolocationSettingsState& settings_state = content_settings-> - geolocation_settings_state(); + const GeolocationSettingsState& settings_state = tab_contents-> + GetTabSpecificContentSettings()->geolocation_settings_state(); if (settings_state.state_map().empty()) return; set_visible(true); diff --git a/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc index b8d303c..0208f7e 100644 --- a/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc +++ b/chrome/browser/ui/content_settings/content_setting_image_model_unittest.cc @@ -7,8 +7,6 @@ #include "chrome/browser/prerender/prerender_manager.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/content_settings/content_setting_image_model.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" -#include "chrome/browser/ui/tab_contents/test_tab_contents_wrapper.h" #include "chrome/test/testing_profile.h" #include "content/browser/browser_thread.h" #include "content/browser/renderer_host/test_render_view_host.h" @@ -16,10 +14,11 @@ #include "net/base/cookie_options.h" #include "testing/gtest/include/gtest/gtest.h" -class ContentSettingImageModelTest : public TabContentsWrapperTestHarness { +class ContentSettingImageModelTest : public RenderViewHostTestHarness { public: ContentSettingImageModelTest() - : ui_thread_(BrowserThread::UI, &message_loop_) {} + : RenderViewHostTestHarness(), + ui_thread_(BrowserThread::UI, &message_loop_) {} private: BrowserThread ui_thread_; @@ -28,8 +27,9 @@ class ContentSettingImageModelTest : public TabContentsWrapperTestHarness { }; TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) { + TestTabContents tab_contents(profile_.get(), NULL); TabSpecificContentSettings* content_settings = - contents_wrapper()->content_settings(); + tab_contents.GetTabSpecificContentSettings(); scoped_ptr<ContentSettingImageModel> content_setting_image_model( ContentSettingImageModel::CreateContentSettingImageModel( CONTENT_SETTINGS_TYPE_IMAGES)); @@ -39,7 +39,7 @@ TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) { content_settings->OnContentBlocked(CONTENT_SETTINGS_TYPE_IMAGES, std::string()); - content_setting_image_model->UpdateFromTabContents(contents()); + content_setting_image_model->UpdateFromTabContents(&tab_contents); EXPECT_TRUE(content_setting_image_model->is_visible()); EXPECT_NE(0, content_setting_image_model->get_icon()); @@ -47,8 +47,9 @@ TEST_F(ContentSettingImageModelTest, UpdateFromTabContents) { } TEST_F(ContentSettingImageModelTest, CookieAccessed) { + TestTabContents tab_contents(profile_.get(), NULL); TabSpecificContentSettings* content_settings = - contents_wrapper()->content_settings(); + tab_contents.GetTabSpecificContentSettings(); profile_->GetHostContentSettingsMap()->SetDefaultContentSetting( CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); scoped_ptr<ContentSettingImageModel> content_setting_image_model( @@ -61,7 +62,7 @@ TEST_F(ContentSettingImageModelTest, CookieAccessed) { net::CookieOptions options; content_settings->OnCookieChanged( GURL("http://google.com"), "A=B", options, false); - content_setting_image_model->UpdateFromTabContents(contents()); + content_setting_image_model->UpdateFromTabContents(&tab_contents); EXPECT_TRUE(content_setting_image_model->is_visible()); EXPECT_NE(0, content_setting_image_model->get_icon()); EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); @@ -70,6 +71,7 @@ TEST_F(ContentSettingImageModelTest, CookieAccessed) { TEST_F(ContentSettingImageModelTest, Prerender) { prerender::PrerenderManager::SetMode( prerender::PrerenderManager::PRERENDER_MODE_ENABLED); + TestTabContents tab_contents(profile_.get(), NULL); scoped_ptr<ContentSettingImageModel> content_setting_image_model( ContentSettingImageModel::CreateContentSettingImageModel( CONTENT_SETTINGS_TYPE_PRERENDER)); @@ -78,9 +80,9 @@ TEST_F(ContentSettingImageModelTest, Prerender) { EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); // Make the tab_contents prerendered - contents()->profile()->GetPrerenderManager()->MarkTabContentsAsPrerendered( - contents()); - content_setting_image_model->UpdateFromTabContents(contents()); + tab_contents.profile()->GetPrerenderManager()->MarkTabContentsAsPrerendered( + &tab_contents); + content_setting_image_model->UpdateFromTabContents(&tab_contents); EXPECT_TRUE(content_setting_image_model->is_visible()); EXPECT_NE(0, content_setting_image_model->get_icon()); EXPECT_FALSE(content_setting_image_model->get_tooltip().empty()); diff --git a/chrome/browser/ui/gtk/collected_cookies_gtk.cc b/chrome/browser/ui/gtk/collected_cookies_gtk.cc index fb2222c..53cfea6 100644 --- a/chrome/browser/ui/gtk/collected_cookies_gtk.cc +++ b/chrome/browser/ui/gtk/collected_cookies_gtk.cc @@ -13,7 +13,6 @@ #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" #include "chrome/browser/ui/gtk/gtk_chrome_cookie_view.h" #include "chrome/browser/ui/gtk/gtk_util.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/common/notification_source.h" #include "grit/generated_resources.h" @@ -81,8 +80,7 @@ CollectedCookiesGtk::CollectedCookiesGtk(GtkWindow* parent, : tab_contents_(tab_contents), status_changed_(false) { TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> - content_settings(); + tab_contents->GetTabSpecificContentSettings(); registrar_.Add(this, NotificationType::COLLECTED_COOKIES_SHOWN, Source<TabSpecificContentSettings>(content_settings)); @@ -183,8 +181,7 @@ GtkWidget* CollectedCookiesGtk::CreateAllowedPane() { gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0); TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - content_settings(); + tab_contents_->GetTabSpecificContentSettings(); allowed_cookies_tree_model_.reset( content_settings->GetAllowedCookiesTreeModel()); @@ -263,8 +260,7 @@ GtkWidget* CollectedCookiesGtk::CreateBlockedPane() { gtk_box_pack_start(GTK_BOX(cookie_list_vbox), scroll_window, TRUE, TRUE, 0); TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - content_settings(); + tab_contents_->GetTabSpecificContentSettings(); blocked_cookies_tree_model_.reset( content_settings->GetBlockedCookiesTreeModel()); @@ -425,6 +421,8 @@ void CollectedCookiesGtk::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK(type == NotificationType::COLLECTED_COOKIES_SHOWN); + DCHECK_EQ(Source<TabSpecificContentSettings>(source).ptr(), + tab_contents_->GetTabSpecificContentSettings()); window_->CloseConstrainedWindow(); } diff --git a/chrome/browser/ui/gtk/location_bar_view_gtk.cc b/chrome/browser/ui/gtk/location_bar_view_gtk.cc index 216e50c..3b37024 100644 --- a/chrome/browser/ui/gtk/location_bar_view_gtk.cc +++ b/chrome/browser/ui/gtk/location_bar_view_gtk.cc @@ -1287,11 +1287,8 @@ void LocationBarViewGtk::ContentSettingImageViewGtk::UpdateFromTabContents( content_setting_image_model_->get_tooltip().c_str()); gtk_widget_show_all(widget()); - TabSpecificContentSettings* content_settings = NULL; - if (tab_contents) { - content_settings = TabContentsWrapper::GetCurrentWrapperForContents( - tab_contents)->content_settings(); - } + TabSpecificContentSettings* content_settings = tab_contents ? + tab_contents->GetTabSpecificContentSettings() : NULL; if (!content_settings || content_settings->IsBlockageIndicated( content_setting_image_model_->get_content_settings_type())) return; diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc index e8787c8..6dac017 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.cc @@ -9,7 +9,6 @@ #include "chrome/browser/autocomplete_history_manager.h" #include "chrome/browser/autofill/autofill_manager.h" #include "chrome/browser/automation/automation_tab_helper.h" -#include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/custom_handlers/protocol_handler.h" #include "chrome/browser/custom_handlers/protocol_handler_registry.h" #include "chrome/browser/custom_handlers/register_protocol_handler_infobar_delegate.h" @@ -81,7 +80,6 @@ TabContentsWrapper::TabContentsWrapper(TabContents* contents) safebrowsing_detection_host_.reset( safe_browsing::ClientSideDetectionHost::Create(contents)); search_engine_tab_helper_.reset(new SearchEngineTabHelper(contents)); - content_settings_.reset(new TabSpecificContentSettings(contents)); translate_tab_helper_.reset(new TranslateTabHelper(contents)); print_view_manager_.reset(new printing::PrintViewManager(contents)); diff --git a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h index 8e91f35..6ed5690 100644 --- a/chrome/browser/ui/tab_contents/tab_contents_wrapper.h +++ b/chrome/browser/ui/tab_contents/tab_contents_wrapper.h @@ -41,7 +41,6 @@ class PasswordManager; class PasswordManagerDelegate; class SearchEngineTabHelper; class TabContentsWrapperDelegate; -class TabSpecificContentSettings; class ThumbnailGenerator; class TranslateTabHelper; @@ -150,10 +149,6 @@ class TabContentsWrapper : public TabContentsObserver { return search_engine_tab_helper_.get(); } - TabSpecificContentSettings* content_settings() { - return content_settings_.get(); - } - TranslateTabHelper* translate_tab_helper() { return translate_tab_helper_.get(); } @@ -218,11 +213,6 @@ class TabContentsWrapper : public TabContentsObserver { safebrowsing_detection_host_; scoped_ptr<SearchEngineTabHelper> search_engine_tab_helper_; - - // The TabSpecificContentSettings object is used to query the blocked content - // state by various UI elements. - scoped_ptr<TabSpecificContentSettings> content_settings_; - scoped_ptr<TranslateTabHelper> translate_tab_helper_; // Per-tab observers --------------------------------------------------------- diff --git a/chrome/browser/ui/views/collected_cookies_win.cc b/chrome/browser/ui/views/collected_cookies_win.cc index 92474fa..ef99ffa 100644 --- a/chrome/browser/ui/views/collected_cookies_win.cc +++ b/chrome/browser/ui/views/collected_cookies_win.cc @@ -9,7 +9,6 @@ #include "chrome/browser/cookies_tree_model.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/views/cookie_info_view.h" #include "content/browser/tab_contents/tab_contents.h" #include "content/common/notification_details.h" @@ -176,8 +175,7 @@ CollectedCookiesWin::CollectedCookiesWin(gfx::NativeWindow parent_window, infobar_(NULL), status_changed_(false) { TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> - content_settings(); + tab_contents->GetTabSpecificContentSettings(); registrar_.Add(this, NotificationType::COLLECTED_COOKIES_SHOWN, Source<TabSpecificContentSettings>(content_settings)); @@ -239,8 +237,7 @@ void CollectedCookiesWin::Init() { views::View* CollectedCookiesWin::CreateAllowedPane() { TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - content_settings(); + tab_contents_->GetTabSpecificContentSettings(); // Create the controls that go into the pane. allowed_label_ = new views::Label(UTF16ToWide(l10n_util::GetStringUTF16( @@ -289,8 +286,7 @@ views::View* CollectedCookiesWin::CreateAllowedPane() { views::View* CollectedCookiesWin::CreateBlockedPane() { TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents_)-> - content_settings(); + tab_contents_->GetTabSpecificContentSettings(); HostContentSettingsMap* host_content_settings_map = tab_contents_->profile()->GetHostContentSettingsMap(); @@ -499,5 +495,7 @@ void CollectedCookiesWin::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK(type == NotificationType::COLLECTED_COOKIES_SHOWN); + DCHECK_EQ(Source<TabSpecificContentSettings>(source).ptr(), + tab_contents_->GetTabSpecificContentSettings()); window_->CloseConstrainedWindow(); } diff --git a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc index b3932b5..1606443 100644 --- a/chrome/browser/ui/views/location_bar/content_setting_image_view.cc +++ b/chrome/browser/ui/views/location_bar/content_setting_image_view.cc @@ -76,11 +76,8 @@ void ContentSettingImageView::UpdateFromTabContents(TabContents* tab_contents) { SetTooltipText(UTF8ToWide(content_setting_image_model_->get_tooltip())); SetVisible(true); - TabSpecificContentSettings* content_settings = NULL; - if (tab_contents) { - content_settings = TabContentsWrapper::GetCurrentWrapperForContents( - tab_contents)->content_settings(); - } + TabSpecificContentSettings* content_settings = tab_contents ? + tab_contents->GetTabSpecificContentSettings() : NULL; if (!content_settings || content_settings->IsBlockageIndicated( content_setting_image_model_->get_content_settings_type())) return; diff --git a/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc b/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc index de3de0b..88441fc 100644 --- a/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc +++ b/chrome/browser/ui/webui/collected_cookies_ui_delegate.cc @@ -11,7 +11,6 @@ #include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/cookies_tree_model.h" #include "chrome/browser/profiles/profile.h" -#include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/browser/ui/webui/chrome_url_data_manager.h" #include "chrome/browser/ui/webui/constrained_html_ui.h" #include "chrome/browser/ui/webui/cookies_tree_model_util.h" @@ -146,8 +145,7 @@ CollectedCookiesUIDelegate::CollectedCookiesUIDelegate( : tab_contents_(tab_contents), closed_(false) { TabSpecificContentSettings* content_settings = - TabContentsWrapper::GetCurrentWrapperForContents(tab_contents)-> - content_settings(); + tab_contents->GetTabSpecificContentSettings(); HostContentSettingsMap* host_content_settings_map = tab_contents_->profile()->GetHostContentSettingsMap(); @@ -241,6 +239,8 @@ void CollectedCookiesUIDelegate::Observe(NotificationType type, const NotificationSource& source, const NotificationDetails& details) { DCHECK_EQ(type.value, NotificationType::COLLECTED_COOKIES_SHOWN); + DCHECK_EQ(Source<TabSpecificContentSettings>(source).ptr(), + tab_contents_->GetTabSpecificContentSettings()); CloseDialog(); } diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi index 8a08004..e5e38e7 100644 --- a/chrome/chrome_tests.gypi +++ b/chrome/chrome_tests.gypi @@ -2248,7 +2248,6 @@ 'browser/chromeos/status/status_area_view_browsertest.cc', 'browser/chromeos/tab_closeable_state_watcher_browsertest.cc', 'browser/chromeos/update_browsertest.cc', - 'browser/content_settings/content_settings_browsertest.cc', 'browser/crash_recovery_browsertest.cc', 'browser/download/download_browsertest.cc', 'browser/download/save_page_browsertest.cc', diff --git a/content/browser/renderer_host/render_view_host_browsertest.cc b/content/browser/renderer_host/render_view_host_browsertest.cc index 2146acd..253ac8b 100644 --- a/content/browser/renderer_host/render_view_host_browsertest.cc +++ b/content/browser/renderer_host/render_view_host_browsertest.cc @@ -2,8 +2,11 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/utf_string_conversions.h" #include "base/time.h" #include "base/values.h" +#include "chrome/browser/content_settings/host_content_settings_map.h" +#include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/browser.h" #include "chrome/test/in_process_browser_test.h" @@ -205,6 +208,25 @@ IN_PROC_BROWSER_TEST_F(RenderViewHostTest, } } +// Regression test for http://crbug.com/63649. +IN_PROC_BROWSER_TEST_F(RenderViewHostTest, RedirectLoopCookies) { + ASSERT_TRUE(test_server()->Start()); + + GURL test_url = test_server()->GetURL("files/redirect-loop.html"); + + browser()->profile()->GetHostContentSettingsMap()->SetDefaultContentSetting( + CONTENT_SETTINGS_TYPE_COOKIES, CONTENT_SETTING_BLOCK); + + ui_test_utils::NavigateToURL(browser(), test_url); + + TabContents* tab_contents = browser()->GetSelectedTabContents(); + ASSERT_EQ(UTF8ToUTF16(test_url.spec() + " failed to load"), + tab_contents->GetTitle()); + + EXPECT_TRUE(tab_contents->GetTabSpecificContentSettings()->IsContentBlocked( + CONTENT_SETTINGS_TYPE_COOKIES)); +} + class RenderViewHostTestTabContentsObserver : public TabContentsObserver { public: explicit RenderViewHostTestTabContentsObserver(TabContents* tab_contents) diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc index d51e63e..fc201e4 100644 --- a/content/browser/tab_contents/tab_contents.cc +++ b/content/browser/tab_contents/tab_contents.cc @@ -15,6 +15,7 @@ #include "base/utf_string_conversions.h" #include "chrome/browser/browser_process.h" #include "chrome/browser/browser_shutdown.h" +#include "chrome/browser/content_settings/tab_specific_content_settings.h" #include "chrome/browser/debugger/devtools_manager.h" #include "chrome/browser/defaults.h" #include "chrome/browser/download/download_request_limiter.h" @@ -335,6 +336,7 @@ TabContents::~TabContents() { } void TabContents::AddObservers() { + content_settings_delegate_.reset(new TabSpecificContentSettings(this)); plugin_observer_.reset(new PluginObserver(this)); net::NetworkChangeNotifier::AddOnlineStateObserver(this); } @@ -1511,6 +1513,10 @@ void TabContents::SetBookmarkDragDelegate( bookmark_drag_ = bookmark_drag; } +TabSpecificContentSettings* TabContents::GetTabSpecificContentSettings() const { + return content_settings_delegate_.get(); +} + RendererPreferences TabContents::GetRendererPrefs(Profile* profile) const { return renderer_preferences_; } diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h index 9a382b0..87e0fde 100644 --- a/content/browser/tab_contents/tab_contents.h +++ b/content/browser/tab_contents/tab_contents.h @@ -59,6 +59,7 @@ class TabContentsDelegate; class TabContentsObserver; class TabContentsSSLHelper; class TabContentsView; +class TabSpecificContentSettings; class URLPattern; struct RendererPreferences; struct ThumbnailScore; @@ -514,6 +515,10 @@ class TabContents : public PageNavigator, virtual void SetBookmarkDragDelegate( RenderViewHostDelegate::BookmarkDrag* bookmark_drag); + // The TabSpecificContentSettings object is used to query the blocked content + // state by various UI elements. + TabSpecificContentSettings* GetTabSpecificContentSettings() const; + // Updates history with the specified navigation. This is called by // OnMsgNavigate to update history state. void UpdateHistoryForNavigation( @@ -859,6 +864,9 @@ class TabContents : public PageNavigator, // Handles drag and drop event forwarding to extensions. BookmarkDrag* bookmark_drag_; + // RenderViewHost::ContentSettingsDelegate. + scoped_ptr<TabSpecificContentSettings> content_settings_delegate_; + // Data for loading state ---------------------------------------------------- // Indicates whether we're currently loading a resource. |