From 9a9a9e2c6904c534fb2d529f5e3a331549f4bf00 Mon Sep 17 00:00:00 2001 From: "jam@chromium.org" Date: Fri, 13 May 2011 22:20:35 +0000 Subject: Remove the last content settings include from content. BUG=76793 Review URL: http://codereview.chromium.org/7011045 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@85333 0039d316-1c4b-4281-b951-d872f2087c98 --- .../content_setting_bubble_model.cc | 63 +++++++++++++--------- .../content_setting_bubble_model.h | 2 + .../content_setting_bubble_model_unittest.cc | 17 +++--- 3 files changed, 52 insertions(+), 30 deletions(-) (limited to 'chrome/browser/ui/content_settings') 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..98890a7 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.cc +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.cc @@ -14,6 +14,7 @@ #include "chrome/browser/profiles/profile.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper.h" #include "chrome/browser/ui/blocked_content/blocked_content_tab_helper_delegate.h" +#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/collected_cookies_infobar_delegate.h" #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" #include "chrome/common/pref_names.h" @@ -29,10 +30,12 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { public: - ContentSettingTitleAndLinkModel(TabContentsWrapper* tab_contents, + ContentSettingTitleAndLinkModel(Browser* browser, + TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type) - : ContentSettingBubbleModel(tab_contents, profile, content_type) { + : ContentSettingBubbleModel(tab_contents, profile, content_type), + browser_(browser) { // Notifications do not have a bubble. DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS); SetBlockedResources(); @@ -121,20 +124,22 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { } virtual void OnManageLinkClicked() { - if (tab_contents()) { - tab_contents()->tab_contents()->delegate()-> - ShowContentSettingsPage(content_type()); - } + if (browser_) + browser_->ShowContentSettingsPage(content_type()); } + + Browser* browser_; }; class ContentSettingTitleLinkAndCustomModel : public ContentSettingTitleAndLinkModel { public: - ContentSettingTitleLinkAndCustomModel(TabContentsWrapper* tab_contents, + ContentSettingTitleLinkAndCustomModel(Browser* browser, + TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type) - : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { + : ContentSettingTitleAndLinkModel( + browser, tab_contents, profile, content_type) { SetCustomLink(); } @@ -165,10 +170,11 @@ class ContentSettingTitleLinkAndCustomModel class ContentSettingSingleRadioGroup : public ContentSettingTitleLinkAndCustomModel { public: - ContentSettingSingleRadioGroup(TabContentsWrapper* tab_contents, + ContentSettingSingleRadioGroup(Browser* browser, + TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type) - : ContentSettingTitleLinkAndCustomModel(tab_contents, profile, + : ContentSettingTitleLinkAndCustomModel(browser, tab_contents, profile, content_type), block_setting_(CONTENT_SETTING_BLOCK), selected_item_(0) { @@ -314,10 +320,12 @@ class ContentSettingSingleRadioGroup class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { public: - ContentSettingCookiesBubbleModel(TabContentsWrapper* tab_contents, + ContentSettingCookiesBubbleModel(Browser* browser, + TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type) - : ContentSettingSingleRadioGroup(tab_contents, profile, content_type) { + : ContentSettingSingleRadioGroup( + browser, tab_contents, profile, content_type) { DCHECK_EQ(CONTENT_SETTINGS_TYPE_COOKIES, content_type); set_custom_link_enabled(true); } @@ -344,10 +352,12 @@ class ContentSettingCookiesBubbleModel : public ContentSettingSingleRadioGroup { class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { public: - ContentSettingPluginBubbleModel(TabContentsWrapper* tab_contents, + ContentSettingPluginBubbleModel(Browser* browser, + TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type) - : ContentSettingSingleRadioGroup(tab_contents, profile, content_type) { + : ContentSettingSingleRadioGroup( + browser, 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()); @@ -368,10 +378,12 @@ class ContentSettingPluginBubbleModel : public ContentSettingSingleRadioGroup { class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { public: - ContentSettingPopupBubbleModel(TabContentsWrapper* tab_contents, + ContentSettingPopupBubbleModel(Browser* browser, + TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type) - : ContentSettingSingleRadioGroup(tab_contents, profile, content_type) { + : ContentSettingSingleRadioGroup( + browser, tab_contents, profile, content_type) { SetPopups(); } @@ -408,10 +420,12 @@ class ContentSettingPopupBubbleModel : public ContentSettingSingleRadioGroup { class ContentSettingDomainListBubbleModel : public ContentSettingTitleAndLinkModel { public: - ContentSettingDomainListBubbleModel(TabContentsWrapper* tab_contents, + ContentSettingDomainListBubbleModel(Browser* browser, + TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type) - : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { + : ContentSettingTitleAndLinkModel( + browser, tab_contents, profile, content_type) { DCHECK_EQ(CONTENT_SETTINGS_TYPE_GEOLOCATION, content_type) << "SetDomains currently only supports geolocation content type"; SetDomainsAndCustomLink(); @@ -477,26 +491,27 @@ class ContentSettingDomainListBubbleModel // static ContentSettingBubbleModel* ContentSettingBubbleModel::CreateContentSettingBubbleModel( + Browser* browser, TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type) { if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { - return new ContentSettingCookiesBubbleModel(tab_contents, profile, + return new ContentSettingCookiesBubbleModel(browser, tab_contents, profile, content_type); } if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { - return new ContentSettingPopupBubbleModel(tab_contents, profile, + return new ContentSettingPopupBubbleModel(browser, tab_contents, profile, content_type); } if (content_type == CONTENT_SETTINGS_TYPE_GEOLOCATION) { - return new ContentSettingDomainListBubbleModel(tab_contents, profile, - content_type); + return new ContentSettingDomainListBubbleModel(browser, tab_contents, + profile, content_type); } if (content_type == CONTENT_SETTINGS_TYPE_PLUGINS) { - return new ContentSettingPluginBubbleModel(tab_contents, profile, + return new ContentSettingPluginBubbleModel(browser, tab_contents, profile, content_type); } - return new ContentSettingSingleRadioGroup(tab_contents, profile, + return new ContentSettingSingleRadioGroup(browser, tab_contents, profile, content_type); } diff --git a/chrome/browser/ui/content_settings/content_setting_bubble_model.h b/chrome/browser/ui/content_settings/content_setting_bubble_model.h index 460ed0b..2e50a04 100644 --- a/chrome/browser/ui/content_settings/content_setting_bubble_model.h +++ b/chrome/browser/ui/content_settings/content_setting_bubble_model.h @@ -16,6 +16,7 @@ #include "googleurl/src/gurl.h" #include "third_party/skia/include/core/SkBitmap.h" +class Browser; class Profile; class SkBitmap; class TabContentsWrapper; @@ -27,6 +28,7 @@ class ContentSettingBubbleModel : public NotificationObserver { virtual ~ContentSettingBubbleModel(); static ContentSettingBubbleModel* CreateContentSettingBubbleModel( + Browser* browser, TabContentsWrapper* tab_contents, Profile* profile, ContentSettingsType content_type); 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..1320096 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 @@ -28,7 +28,7 @@ class ContentSettingBubbleModelTest : public TabContentsWrapperTestHarness { bool expect_reload_hint) { scoped_ptr content_setting_bubble_model( ContentSettingBubbleModel::CreateContentSettingBubbleModel( - contents_wrapper(), profile_.get(), + NULL, contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_GEOLOCATION)); const ContentSettingBubbleModel::BubbleContent& bubble_content = content_setting_bubble_model->bubble_content(); @@ -53,7 +53,8 @@ TEST_F(ContentSettingBubbleModelTest, ImageRadios) { scoped_ptr content_setting_bubble_model( ContentSettingBubbleModel::CreateContentSettingBubbleModel( - contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_IMAGES)); + NULL, contents_wrapper(), profile_.get(), + CONTENT_SETTINGS_TYPE_IMAGES)); const ContentSettingBubbleModel::BubbleContent& bubble_content = content_setting_bubble_model->bubble_content(); EXPECT_FALSE(bubble_content.title.empty()); @@ -71,7 +72,8 @@ TEST_F(ContentSettingBubbleModelTest, Cookies) { scoped_ptr content_setting_bubble_model( ContentSettingBubbleModel::CreateContentSettingBubbleModel( - contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_COOKIES)); + NULL, contents_wrapper(), profile_.get(), + CONTENT_SETTINGS_TYPE_COOKIES)); const ContentSettingBubbleModel::BubbleContent& bubble_content = content_setting_bubble_model->bubble_content(); EXPECT_FALSE(bubble_content.title.empty()); @@ -89,7 +91,8 @@ TEST_F(ContentSettingBubbleModelTest, Plugins) { scoped_ptr content_setting_bubble_model( ContentSettingBubbleModel::CreateContentSettingBubbleModel( - contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_PLUGINS)); + NULL, contents_wrapper(), profile_.get(), + CONTENT_SETTINGS_TYPE_PLUGINS)); const ContentSettingBubbleModel::BubbleContent& bubble_content = content_setting_bubble_model->bubble_content(); EXPECT_FALSE(bubble_content.title.empty()); @@ -127,7 +130,8 @@ TEST_F(ContentSettingBubbleModelTest, MultiplePlugins) { scoped_ptr content_setting_bubble_model( ContentSettingBubbleModel::CreateContentSettingBubbleModel( - contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_PLUGINS)); + NULL, contents_wrapper(), profile_.get(), + CONTENT_SETTINGS_TYPE_PLUGINS)); const ContentSettingBubbleModel::BubbleContent& bubble_content = content_setting_bubble_model->bubble_content(); EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); @@ -193,7 +197,8 @@ TEST_F(ContentSettingBubbleModelTest, FileURL) { NavigateAndCommit(GURL(file_url)); scoped_ptr content_setting_bubble_model( ContentSettingBubbleModel::CreateContentSettingBubbleModel( - contents_wrapper(), profile_.get(), CONTENT_SETTINGS_TYPE_IMAGES)); + NULL, contents_wrapper(), profile_.get(), + CONTENT_SETTINGS_TYPE_IMAGES)); std::string title = content_setting_bubble_model->bubble_content().radio_group.radio_items[0]; ASSERT_NE(std::string::npos, title.find(file_url)); -- cgit v1.1