diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-06 08:48:23 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-06 08:48:23 +0000 |
commit | f8f69210d233566fddf71b57b093dd16da609ffc (patch) | |
tree | 9ed9ffcd865d65c11b11f73ea486efa79af13346 /chrome/browser | |
parent | 0af29d8cedd97d4604619dd4ab2b5e0a0805ecb1 (diff) | |
download | chromium_src-f8f69210d233566fddf71b57b093dd16da609ffc.zip chromium_src-f8f69210d233566fddf71b57b093dd16da609ffc.tar.gz chromium_src-f8f69210d233566fddf71b57b093dd16da609ffc.tar.bz2 |
Display an info link in the blocked cookies info bubble.
The link will pop up a dialog that displays the cookies blocked and accessed by the current page.
The XIB change adds a link-styled button (cell type HyperlinkButtonCell) below the title and above the horizontal line on the bubble with the text IDS_BLOCKED_COOKIES_INFO. The button action is hooked up to showMoreInfo: in the File's Owner.
BUG=45230
TEST=none
Review URL: http://codereview.chromium.org/2799012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51656 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
9 files changed, 93 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.h b/chrome/browser/cocoa/content_blocked_bubble_controller.h index 6bb7c90..3d824cf 100644 --- a/chrome/browser/cocoa/content_blocked_bubble_controller.h +++ b/chrome/browser/cocoa/content_blocked_bubble_controller.h @@ -53,4 +53,7 @@ typedef std::map<NSButton*, int> PopupLinks; // Callback for "manage" button. - (IBAction)manageBlocking:(id)sender; +// Callback for "info" link. +- (IBAction)showMoreInfo:(id)sender; + @end diff --git a/chrome/browser/cocoa/content_blocked_bubble_controller.mm b/chrome/browser/cocoa/content_blocked_bubble_controller.mm index d0ae86f..b4c453b 100644 --- a/chrome/browser/cocoa/content_blocked_bubble_controller.mm +++ b/chrome/browser/cocoa/content_blocked_bubble_controller.mm @@ -393,6 +393,11 @@ NSTextField* LabelWithFrame(NSString* text, const NSRect& frame) { contentSettingBubbleModel_->OnManageLinkClicked(); } +- (IBAction)showMoreInfo:(id)sender { + contentSettingBubbleModel_->OnInfoLinkClicked(); + [self close]; +} + - (void)popupLinkClicked:(id)sender { content_blocked_bubble::PopupLinks::iterator i(popupLinks_.find(sender)); DCHECK(i != popupLinks_.end()); diff --git a/chrome/browser/content_setting_bubble_model.cc b/chrome/browser/content_setting_bubble_model.cc index f396cded..19587a5 100644 --- a/chrome/browser/content_setting_bubble_model.cc +++ b/chrome/browser/content_setting_bubble_model.cc @@ -66,6 +66,40 @@ class ContentSettingTitleAndLinkModel : public ContentSettingBubbleModel { } }; +class ContentSettingTitleLinkAndInfoModel + : public ContentSettingTitleAndLinkModel { + public: + ContentSettingTitleLinkAndInfoModel(TabContents* tab_contents, + Profile* profile, + ContentSettingsType content_type) + : ContentSettingTitleAndLinkModel(tab_contents, profile, content_type) { + SetInfoLink(); + } + + private: + void SetInfoLink() { + static const int kInfoIDs[] = { + IDS_BLOCKED_COOKIES_INFO, + 0, // Images do not have an info link. + 0, // Javascript doesn't have an info link. + 0, // Plugins do not have an info link. + 0, // Popups do not have an info link. + 0, // Geolocation does not have an info link. + 0, // Notifications do not have a bubble. + }; + COMPILE_ASSERT(arraysize(kInfoIDs) == CONTENT_SETTINGS_NUM_TYPES, + Need_a_setting_for_every_content_settings_type); + if (kInfoIDs[content_type()]) + set_info_link(l10n_util::GetStringUTF8(kInfoIDs[content_type()])); + } + + virtual void OnInfoLinkClicked() { + DCHECK(content_type() == CONTENT_SETTINGS_TYPE_COOKIES); + // FIXME(jochen): show cookie info dialog. + } +}; + + class ContentSettingSingleRadioGroup : public ContentSettingTitleAndLinkModel { public: ContentSettingSingleRadioGroup(TabContents* tab_contents, Profile* profile, @@ -256,8 +290,8 @@ ContentSettingBubbleModel* Profile* profile, ContentSettingsType content_type) { if (content_type == CONTENT_SETTINGS_TYPE_COOKIES) { - return new ContentSettingTitleAndLinkModel(tab_contents, profile, - content_type); + return new ContentSettingTitleLinkAndInfoModel(tab_contents, profile, + content_type); } if (content_type == CONTENT_SETTINGS_TYPE_POPUPS) { return new ContentSettingPopupBubbleModel(tab_contents, profile, diff --git a/chrome/browser/content_setting_bubble_model.h b/chrome/browser/content_setting_bubble_model.h index 18cf6ac..a8aa744 100644 --- a/chrome/browser/content_setting_bubble_model.h +++ b/chrome/browser/content_setting_bubble_model.h @@ -59,6 +59,7 @@ class ContentSettingBubbleModel : public NotificationObserver { std::vector<DomainList> domain_lists; std::string manage_link; std::string clear_link; + std::string info_link; }; const BubbleContent& bubble_content() const { return bubble_content_; } @@ -72,6 +73,7 @@ class ContentSettingBubbleModel : public NotificationObserver { virtual void OnPopupClicked(int index) {} virtual void OnManageLinkClicked() {} virtual void OnClearLinkClicked() {} + virtual void OnInfoLinkClicked() {} protected: ContentSettingBubbleModel(TabContents* tab_contents, Profile* profile, @@ -96,6 +98,9 @@ class ContentSettingBubbleModel : public NotificationObserver { void set_clear_link(const std::string& link) { bubble_content_.clear_link = link; } + void set_info_link(const std::string& link) { + bubble_content_.info_link = link; + } private: TabContents* tab_contents_; diff --git a/chrome/browser/content_setting_bubble_model_unittest.cc b/chrome/browser/content_setting_bubble_model_unittest.cc index 5615a94..5f96e49 100644 --- a/chrome/browser/content_setting_bubble_model_unittest.cc +++ b/chrome/browser/content_setting_bubble_model_unittest.cc @@ -36,6 +36,7 @@ class ContentSettingBubbleModelTest : public RenderViewHostTestHarness { else EXPECT_EQ(std::string(), bubble_content.clear_link); EXPECT_NE(std::string(), bubble_content.manage_link); + EXPECT_EQ(std::string(), bubble_content.info_link); EXPECT_EQ(std::string(), bubble_content.title); } @@ -55,6 +56,7 @@ TEST_F(ContentSettingBubbleModelTest, ImageRadios) { EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); EXPECT_EQ(0, bubble_content.radio_group.default_item); EXPECT_NE(std::string(), bubble_content.manage_link); + EXPECT_EQ(std::string(), bubble_content.info_link); EXPECT_NE(std::string(), bubble_content.title); } @@ -70,6 +72,7 @@ TEST_F(ContentSettingBubbleModelTest, Cookies) { content_setting_bubble_model->bubble_content(); EXPECT_EQ(0U, bubble_content.radio_group.radio_items.size()); EXPECT_NE(std::string(), bubble_content.manage_link); + EXPECT_NE(std::string(), bubble_content.info_link); EXPECT_NE(std::string(), bubble_content.title); } diff --git a/chrome/browser/gtk/content_setting_bubble_gtk.cc b/chrome/browser/gtk/content_setting_bubble_gtk.cc index e4afdcd..f285fd8 100644 --- a/chrome/browser/gtk/content_setting_bubble_gtk.cc +++ b/chrome/browser/gtk/content_setting_bubble_gtk.cc @@ -184,6 +184,19 @@ void ContentSettingBubbleGtk::BuildBubble() { FALSE, FALSE, 0); } + if (!content.info_link.empty()) { + GtkWidget* info_link_box = gtk_hbox_new(FALSE, 0); + GtkWidget* info_link = gtk_chrome_link_button_new( + content.info_link.c_str()); + g_signal_connect(info_link, "clicked", G_CALLBACK(OnInfoLinkClickedThunk), + this); + gtk_box_pack_start(GTK_BOX(info_link_box), info_link, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(bubble_content), info_link_box, + FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(bubble_content), gtk_hseparator_new(), + FALSE, FALSE, 0); + } + GtkWidget* bottom_box = gtk_hbox_new(FALSE, 0); GtkWidget* manage_link = @@ -263,3 +276,8 @@ void ContentSettingBubbleGtk::OnClearLinkClicked(GtkWidget* button) { content_setting_bubble_model_->OnClearLinkClicked(); Close(); } + +void ContentSettingBubbleGtk::OnInfoLinkClicked(GtkWidget* button) { + content_setting_bubble_model_->OnInfoLinkClicked(); + Close(); +} diff --git a/chrome/browser/gtk/content_setting_bubble_gtk.h b/chrome/browser/gtk/content_setting_bubble_gtk.h index e0e9921..868eeb2 100644 --- a/chrome/browser/gtk/content_setting_bubble_gtk.h +++ b/chrome/browser/gtk/content_setting_bubble_gtk.h @@ -58,6 +58,7 @@ class ContentSettingBubbleGtk : public InfoBubbleGtkDelegate, CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnCloseButtonClicked); CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnManageLinkClicked); CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnClearLinkClicked); + CHROMEGTK_CALLBACK_0(ContentSettingBubbleGtk, void, OnInfoLinkClicked); // We position the bubble near this widget. GtkWidget* anchor_; diff --git a/chrome/browser/views/content_blocked_bubble_contents.cc b/chrome/browser/views/content_blocked_bubble_contents.cc index ab7675a..bef80be 100644 --- a/chrome/browser/views/content_blocked_bubble_contents.cc +++ b/chrome/browser/views/content_blocked_bubble_contents.cc @@ -102,7 +102,8 @@ ContentSettingBubbleContents::ContentSettingBubbleContents( info_bubble_(NULL), close_button_(NULL), manage_link_(NULL), - clear_link_(NULL) { + clear_link_(NULL), + info_link_(NULL) { registrar_.Add(this, NotificationType::TAB_CONTENTS_DESTROYED, Source<TabContents>(tab_contents)); } @@ -150,6 +151,12 @@ void ContentSettingBubbleContents::LinkActivated(views::Link* source, info_bubble_->Close(); // CAREFUL: This deletes us. return; } + if (source == info_link_) { + content_setting_bubble_model_->OnInfoLinkClicked(); + info_bubble_->set_fade_away_on_close(true); + info_bubble_->Close(); // CAREFUL: This deletes us. + return; + } PopupLinks::const_iterator i(popup_links_.find(source)); DCHECK(i != popup_links_.end()); @@ -283,6 +290,19 @@ void ContentSettingBubbleContents::InitControlLayout() { layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); } + if (!bubble_content.info_link.empty()) { + info_link_ = new views::Link(UTF8ToWide(bubble_content.info_link)); + info_link_->SetController(this); + layout->StartRow(0, single_column_set_id); + layout->AddView(info_link_); + + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + layout->StartRow(0, single_column_set_id); + layout->AddView(new views::Separator, 1, 1, + GridLayout::FILL, GridLayout::FILL); + layout->AddPaddingRow(0, kRelatedControlVerticalSpacing); + } + const int double_column_set_id = 1; views::ColumnSet* double_column_set = layout->AddColumnSet(double_column_set_id); diff --git a/chrome/browser/views/content_blocked_bubble_contents.h b/chrome/browser/views/content_blocked_bubble_contents.h index ad4511c..bdbaf9e 100644 --- a/chrome/browser/views/content_blocked_bubble_contents.h +++ b/chrome/browser/views/content_blocked_bubble_contents.h @@ -93,6 +93,7 @@ class ContentSettingBubbleContents : public views::View, views::NativeButton* close_button_; views::Link* manage_link_; views::Link* clear_link_; + views::Link* info_link_; DISALLOW_IMPLICIT_CONSTRUCTORS(ContentSettingBubbleContents); }; |