Commit 2c245143 authored by melandory's avatar melandory Committed by Commit bot

Make 'Load full site' a button instead of link.

BUG=646762

Review-Url: https://codereview.chromium.org/2339783003
Cr-Commit-Position: refs/heads/master@{#418697}
parent aaa4fe75
......@@ -742,7 +742,7 @@ const ContentTypeToNibPath kNibPaths[] = {
- (void)initManageDoneButtons {
const ContentSettingBubbleModel::BubbleContent& content =
contentSettingBubbleModel_->bubble_content();
[manageButton_ setTitle:base::SysUTF8ToNSString(content.manage_link)];
[manageButton_ setTitle:base::SysUTF8ToNSString(content.manage_text)];
[GTMUILocalizerAndLayoutTweaker sizeToFitView:[manageButton_ superview]];
CGFloat actualWidth = NSWidth([[[self window] contentView] frame]);
......
......@@ -115,7 +115,7 @@ ContentSettingSimpleBubbleModel::ContentSettingSimpleBubbleModel(
// Notifications do not have a bubble.
DCHECK_NE(content_type, CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
SetTitle();
SetManageLink();
SetManageText();
SetCustomLink();
}
......@@ -162,7 +162,7 @@ void ContentSettingSimpleBubbleModel::SetTitle() {
set_title(l10n_util::GetStringUTF16(title_id));
}
void ContentSettingSimpleBubbleModel::SetManageLink() {
void ContentSettingSimpleBubbleModel::SetManageText() {
static const ContentSettingsTypeIdEntry kLinkIDs[] = {
{CONTENT_SETTINGS_TYPE_COOKIES, IDS_BLOCKED_COOKIES_LINK},
{CONTENT_SETTINGS_TYPE_IMAGES, IDS_BLOCKED_IMAGES_LINK},
......@@ -176,7 +176,7 @@ void ContentSettingSimpleBubbleModel::SetManageLink() {
{CONTENT_SETTINGS_TYPE_AUTOMATIC_DOWNLOADS, IDS_BLOCKED_DOWNLOADS_LINK},
{CONTENT_SETTINGS_TYPE_MIDI_SYSEX, IDS_MIDI_SYSEX_BUBBLE_MANAGE_LINK},
};
set_manage_link(l10n_util::GetStringUTF8(
set_manage_text(l10n_util::GetStringUTF8(
GetIdForContentType(kLinkIDs, arraysize(kLinkIDs), content_type())));
}
......@@ -617,7 +617,7 @@ ContentSettingMediaStreamBubbleModel::ContentSettingMediaStreamBubbleModel(
SetTitle();
SetRadioGroup();
SetMediaMenus();
SetManageLink();
SetManageText();
SetCustomLink();
}
......@@ -860,7 +860,7 @@ void ContentSettingMediaStreamBubbleModel::SetMediaMenus() {
}
}
void ContentSettingMediaStreamBubbleModel::SetManageLink() {
void ContentSettingMediaStreamBubbleModel::SetManageText() {
// By default, the manage link refers to both media types. We only need
// to change the link text if only one media type was accessed.
int link_id;
......@@ -875,7 +875,7 @@ void ContentSettingMediaStreamBubbleModel::SetManageLink() {
return;
}
set_manage_link(l10n_util::GetStringUTF8(link_id));
set_manage_text(l10n_util::GetStringUTF8(link_id));
}
void ContentSettingMediaStreamBubbleModel::SetCustomLink() {
......@@ -1200,7 +1200,7 @@ ContentSettingSubresourceFilterBubbleModel::
: ContentSettingBubbleModel(delegate, web_contents, profile) {
SetTitle();
SetMessage();
SetManageLink();
SetManageText();
}
ContentSettingSubresourceFilterBubbleModel::
......@@ -1211,10 +1211,10 @@ void ContentSettingSubresourceFilterBubbleModel::SetTitle() {
l10n_util::GetStringUTF16(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_TITLE));
}
void ContentSettingSubresourceFilterBubbleModel::SetManageLink() {
// TODO(melandory): introduce the button instead of link.
set_manage_link(
void ContentSettingSubresourceFilterBubbleModel::SetManageText() {
set_manage_text(
l10n_util::GetStringUTF8(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_RELOAD));
set_show_manage_text_as_button(true);
}
void ContentSettingSubresourceFilterBubbleModel::SetMessage() {
......@@ -1405,8 +1405,8 @@ ContentSettingBubbleModel::MediaMenu::~MediaMenu() {}
ContentSettingBubbleModel::BubbleContent::BubbleContent()
: radio_group_enabled(false),
custom_link_enabled(false) {
}
custom_link_enabled(false),
show_manage_text_as_button(false) {}
ContentSettingBubbleModel::BubbleContent::~BubbleContent() {}
......
......@@ -120,7 +120,8 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
std::vector<DomainList> domain_lists;
std::string custom_link;
bool custom_link_enabled;
std::string manage_link;
std::string manage_text;
bool show_manage_text_as_button;
MediaMenuMap media_menus;
std::string learn_more_link;
......@@ -211,8 +212,11 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
void set_custom_link_enabled(bool enabled) {
bubble_content_.custom_link_enabled = enabled;
}
void set_manage_link(const std::string& link) {
bubble_content_.manage_link = link;
void set_manage_text(const std::string& link) {
bubble_content_.manage_text = link;
}
void set_show_manage_text_as_button(bool show_manage_text_as_button) {
bubble_content_.show_manage_text_as_button = show_manage_text_as_button;
}
void set_learn_more_link(const std::string& link) {
bubble_content_.learn_more_link = link;
......@@ -233,7 +237,7 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
private:
virtual void SetTitle() = 0;
virtual void SetManageLink() = 0;
virtual void SetManageText() = 0;
content::WebContents* web_contents_;
Profile* profile_;
......@@ -266,7 +270,7 @@ class ContentSettingSimpleBubbleModel : public ContentSettingBubbleModel {
private:
// ContentSettingBubbleModel implementation.
void SetTitle() override;
void SetManageLink() override;
void SetManageText() override;
void OnManageLinkClicked() override;
void SetCustomLink();
void OnCustomLinkClicked() override;
......@@ -324,7 +328,7 @@ class ContentSettingSubresourceFilterBubbleModel
// ContentSettingBubbleModel:
void SetTitle() override;
void SetManageLink() override;
void SetManageText() override;
DISALLOW_COPY_AND_ASSIGN(ContentSettingSubresourceFilterBubbleModel);
};
......@@ -350,7 +354,7 @@ class ContentSettingMediaStreamBubbleModel : public ContentSettingBubbleModel {
// ContentSettingBubbleModel:
void SetTitle() override;
void SetManageLink() override;
void SetManageText() override;
// Sets the data for the radio buttons of the bubble.
void SetRadioGroup();
......
......@@ -56,7 +56,7 @@ class ContentSettingBubbleModelTest : public ChromeRenderViewHostTestHarness {
EXPECT_NE(expect_clear_link || expect_reload_hint,
bubble_content.custom_link.empty());
EXPECT_EQ(expect_clear_link, bubble_content.custom_link_enabled);
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
}
std::string GetDefaultAudioDevice() {
......@@ -84,7 +84,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_TRUE(bubble_content.custom_link.empty());
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
}
TEST_F(ContentSettingBubbleModelTest, Cookies) {
......@@ -102,7 +102,7 @@ TEST_F(ContentSettingBubbleModelTest, Cookies) {
ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size());
EXPECT_FALSE(bubble_content.custom_link.empty());
EXPECT_TRUE(bubble_content.custom_link_enabled);
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
content_settings->ClearCookieSpecificContentSettings();
content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_COOKIES);
......@@ -124,7 +124,7 @@ TEST_F(ContentSettingBubbleModelTest, Cookies) {
web_contents()->GetURL())));
EXPECT_FALSE(bubble_content_2.custom_link.empty());
EXPECT_TRUE(bubble_content_2.custom_link_enabled);
EXPECT_FALSE(bubble_content_2.manage_link.empty());
EXPECT_FALSE(bubble_content_2.manage_text.empty());
}
TEST_F(ContentSettingBubbleModelTest, MediastreamMicAndCamera) {
......@@ -164,7 +164,7 @@ TEST_F(ContentSettingBubbleModelTest, MediastreamMicAndCamera) {
EXPECT_EQ(0, bubble_content.radio_group.default_item);
EXPECT_TRUE(bubble_content.custom_link.empty());
EXPECT_FALSE(bubble_content.custom_link_enabled);
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
EXPECT_EQ(2U, bubble_content.media_menus.size());
}
......@@ -523,7 +523,7 @@ TEST_F(ContentSettingBubbleModelTest, MediastreamMic) {
EXPECT_EQ(0, bubble_content.radio_group.default_item);
EXPECT_TRUE(bubble_content.custom_link.empty());
EXPECT_FALSE(bubble_content.custom_link_enabled);
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
EXPECT_EQ(1U, bubble_content.media_menus.size());
EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
bubble_content.media_menus.begin()->first);
......@@ -554,7 +554,7 @@ TEST_F(ContentSettingBubbleModelTest, MediastreamMic) {
EXPECT_EQ(1, new_bubble_content.radio_group.default_item);
EXPECT_TRUE(new_bubble_content.custom_link.empty());
EXPECT_FALSE(new_bubble_content.custom_link_enabled);
EXPECT_FALSE(new_bubble_content.manage_link.empty());
EXPECT_FALSE(new_bubble_content.manage_text.empty());
EXPECT_EQ(1U, new_bubble_content.media_menus.size());
EXPECT_EQ(content::MEDIA_DEVICE_AUDIO_CAPTURE,
new_bubble_content.media_menus.begin()->first);
......@@ -596,7 +596,7 @@ TEST_F(ContentSettingBubbleModelTest, MediastreamCamera) {
EXPECT_EQ(0, bubble_content.radio_group.default_item);
EXPECT_TRUE(bubble_content.custom_link.empty());
EXPECT_FALSE(bubble_content.custom_link_enabled);
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
EXPECT_EQ(1U, bubble_content.media_menus.size());
EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE,
bubble_content.media_menus.begin()->first);
......@@ -627,7 +627,7 @@ TEST_F(ContentSettingBubbleModelTest, MediastreamCamera) {
EXPECT_EQ(1, new_bubble_content.radio_group.default_item);
EXPECT_TRUE(new_bubble_content.custom_link.empty());
EXPECT_FALSE(new_bubble_content.custom_link_enabled);
EXPECT_FALSE(new_bubble_content.manage_link.empty());
EXPECT_FALSE(new_bubble_content.manage_text.empty());
EXPECT_EQ(1U, new_bubble_content.media_menus.size());
EXPECT_EQ(content::MEDIA_DEVICE_VIDEO_CAPTURE,
new_bubble_content.media_menus.begin()->first);
......@@ -721,7 +721,7 @@ TEST_F(ContentSettingBubbleModelTest, Plugins) {
EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
EXPECT_FALSE(bubble_content.custom_link.empty());
EXPECT_TRUE(bubble_content.custom_link_enabled);
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
EXPECT_FALSE(bubble_content.learn_more_link.empty());
}
......@@ -742,7 +742,7 @@ TEST_F(ContentSettingBubbleModelTest, PepperBroker) {
std::string radio1 = bubble_content.radio_group.radio_items[0];
std::string radio2 = bubble_content.radio_group.radio_items[1];
EXPECT_FALSE(bubble_content.custom_link_enabled);
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
content_settings->ClearBlockedContentSettingsExceptForCookies();
content_settings->OnContentAllowed(CONTENT_SETTINGS_TYPE_PPAPI_BROKER);
......@@ -759,7 +759,7 @@ TEST_F(ContentSettingBubbleModelTest, PepperBroker) {
EXPECT_NE(radio1, bubble_content_2.radio_group.radio_items[0]);
EXPECT_NE(radio2, bubble_content_2.radio_group.radio_items[1]);
EXPECT_FALSE(bubble_content_2.custom_link_enabled);
EXPECT_FALSE(bubble_content_2.manage_link.empty());
EXPECT_FALSE(bubble_content_2.manage_text.empty());
}
TEST_F(ContentSettingBubbleModelTest, Geolocation) {
......@@ -831,7 +831,7 @@ TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) {
EXPECT_TRUE(bubble_content.domain_lists.empty());
EXPECT_TRUE(bubble_content.custom_link.empty());
EXPECT_FALSE(bubble_content.custom_link_enabled);
EXPECT_FALSE(bubble_content.manage_link.empty());
EXPECT_FALSE(bubble_content.manage_text.empty());
}
class FakeDelegate : public ProtocolHandlerRegistry::Delegate {
......@@ -937,7 +937,7 @@ TEST_F(ContentSettingBubbleModelTest, SubresourceFilter) {
EXPECT_TRUE(bubble_content.custom_link.empty());
EXPECT_FALSE(bubble_content.custom_link_enabled);
EXPECT_EQ(
bubble_content.manage_link,
bubble_content.manage_text,
l10n_util::GetStringUTF8(IDS_FILTERED_DECEPTIVE_CONTENT_PROMPT_RELOAD));
EXPECT_EQ(0U, bubble_content.media_menus.size());
}
......@@ -29,6 +29,7 @@
#include "ui/base/resource/resource_bundle.h"
#include "ui/gfx/font_list.h"
#include "ui/gfx/text_utils.h"
#include "ui/views/controls/button/md_text_button.h"
#include "ui/views/controls/button/menu_button.h"
#include "ui/views/controls/button/radio_button.h"
#include "ui/views/controls/combobox/combobox.h"
......@@ -159,9 +160,10 @@ ContentSettingBubbleContents::ContentSettingBubbleContents(
: content::WebContentsObserver(web_contents),
BubbleDialogDelegateView(anchor_view, arrow),
content_setting_bubble_model_(content_setting_bubble_model),
custom_link_(NULL),
manage_link_(NULL),
learn_more_link_(NULL) {
custom_link_(nullptr),
manage_link_(nullptr),
manage_button_(nullptr),
learn_more_link_(nullptr) {
// Compensate for built-in vertical padding in the anchor view's image.
set_anchor_view_insets(gfx::Insets(
GetLayoutConstant(LOCATION_BAR_BUBBLE_ANCHOR_VERTICAL_INSET), 0));
......@@ -381,10 +383,18 @@ void ContentSettingBubbleContents::Init() {
}
views::View* ContentSettingBubbleContents::CreateExtraView() {
manage_link_ = new views::Link(base::UTF8ToUTF16(
content_setting_bubble_model_->bubble_content().manage_link));
manage_link_->set_listener(this);
return manage_link_;
if (content_setting_bubble_model_->bubble_content()
.show_manage_text_as_button) {
manage_button_ = views::MdTextButton::CreateSecondaryUiButton(
this, base::UTF8ToUTF16(
content_setting_bubble_model_->bubble_content().manage_text));
return manage_button_;
} else {
manage_link_ = new views::Link(base::UTF8ToUTF16(
content_setting_bubble_model_->bubble_content().manage_text));
manage_link_->set_listener(this);
return manage_link_;
}
}
bool ContentSettingBubbleContents::Accept() {
......@@ -415,10 +425,15 @@ void ContentSettingBubbleContents::DidNavigateMainFrame(
void ContentSettingBubbleContents::ButtonPressed(views::Button* sender,
const ui::Event& event) {
RadioGroup::const_iterator i(
std::find(radio_group_.begin(), radio_group_.end(), sender));
DCHECK(i != radio_group_.end());
content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin());
if (manage_button_ == sender) {
GetWidget()->Close();
content_setting_bubble_model_->OnManageLinkClicked();
} else {
RadioGroup::const_iterator i(
std::find(radio_group_.begin(), radio_group_.end(), sender));
DCHECK(i != radio_group_.end());
content_setting_bubble_model_->OnRadioClicked(i - radio_group_.begin());
}
}
void ContentSettingBubbleContents::LinkClicked(views::Link* source,
......
......@@ -28,6 +28,7 @@ class ContentSettingBubbleViewsBridge;
namespace views {
class RadioButton;
class LabelButton;
}
// ContentSettingBubbleContents is used when the user turns on different kinds
......@@ -116,6 +117,7 @@ class ContentSettingBubbleContents : public content::WebContentsObserver,
RadioGroup radio_group_;
views::Link* custom_link_;
views::Link* manage_link_;
views::LabelButton* manage_button_;
views::Link* learn_more_link_;
// Combobox models the bubble owns.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment