Commit 428eaaad authored by meacer's avatar meacer Committed by Commit bot
parent 12846b3c
...@@ -236,10 +236,6 @@ void TabSpecificContentSettings::FileSystemAccessed(int render_process_id, ...@@ -236,10 +236,6 @@ void TabSpecificContentSettings::FileSystemAccessed(int render_process_id,
settings->OnFileSystemAccessed(url, blocked_by_policy); settings->OnFileSystemAccessed(url, blocked_by_policy);
} }
const base::string16 TabSpecificContentSettings::GetBlockedPluginNames() const {
return JoinString(blocked_plugin_names_, base::ASCIIToUTF16(", "));
}
bool TabSpecificContentSettings::IsContentBlocked( bool TabSpecificContentSettings::IsContentBlocked(
ContentSettingsType content_type) const { ContentSettingsType content_type) const {
DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION) DCHECK(content_type != CONTENT_SETTINGS_TYPE_GEOLOCATION)
......
...@@ -180,7 +180,9 @@ class TabSpecificContentSettings ...@@ -180,7 +180,9 @@ class TabSpecificContentSettings
bool IsContentAllowed(ContentSettingsType content_type) const; bool IsContentAllowed(ContentSettingsType content_type) const;
// Returns the names of plugins that have been blocked for this tab. // Returns the names of plugins that have been blocked for this tab.
const base::string16 GetBlockedPluginNames() const; const std::vector<base::string16>& blocked_plugin_names() const {
return blocked_plugin_names_;
}
const GURL& media_stream_access_origin() const { const GURL& media_stream_access_origin() const {
return media_stream_access_origin_; return media_stream_access_origin_;
......
...@@ -210,7 +210,7 @@ class ContentSettingBubbleWebContentsObserverBridge ...@@ -210,7 +210,7 @@ class ContentSettingBubbleWebContentsObserverBridge
- (void)initializeBlockedPluginsList; - (void)initializeBlockedPluginsList;
- (void)initializeTitle; - (void)initializeTitle;
- (void)initializeRadioGroup; - (void)initializeRadioGroup;
- (void)initializePopupList; - (void)initializeItemList;
- (void)initializeGeoLists; - (void)initializeGeoLists;
- (void)initializeMediaMenus; - (void)initializeMediaMenus;
- (void)initializeMIDISysExLists; - (void)initializeMIDISysExLists;
...@@ -384,16 +384,20 @@ class ContentSettingBubbleWebContentsObserverBridge ...@@ -384,16 +384,20 @@ class ContentSettingBubbleWebContentsObserverBridge
} }
- (void)initializeBlockedPluginsList { - (void)initializeBlockedPluginsList {
NSString* label = base::SysUTF16ToNSString( // Hide the empty label at the top of the dialog.
contentSettingBubbleModel_->bubble_content().plugin_names); int delta =
[blockedResourcesField_ setStringValue:label]; NSMinY([titleLabel_ frame]) - NSMinY([blockedResourcesField_ frame]);
[blockedResourcesField_ removeFromSuperview];
NSRect frame = [[self window] frame];
frame.size.height -= delta;
[[self window] setFrame:frame display:NO];
} }
- (void)initializePopupList { - (void)initializeItemList {
// I didn't put the buttons into a NSMatrix because then they are only one // I didn't put the buttons into a NSMatrix because then they are only one
// entity in the key view loop. This way, one can tab through all of them. // entity in the key view loop. This way, one can tab through all of them.
const ContentSettingBubbleModel::PopupItems& popupItems = const ContentSettingBubbleModel::ListItems& listItems =
contentSettingBubbleModel_->bubble_content().popup_items; contentSettingBubbleModel_->bubble_content().list_items;
// Get the pre-resize frame of the radio group. Its origin is where the // Get the pre-resize frame of the radio group. Its origin is where the
// popup list should go. // popup list should go.
...@@ -403,37 +407,36 @@ class ContentSettingBubbleWebContentsObserverBridge ...@@ -403,37 +407,36 @@ class ContentSettingBubbleWebContentsObserverBridge
// themselves when the window is enlarged. // themselves when the window is enlarged.
// Heading and radio box are already 1 * kLinkOuterPadding apart in the nib, // Heading and radio box are already 1 * kLinkOuterPadding apart in the nib,
// so only 1 * kLinkOuterPadding more is needed. // so only 1 * kLinkOuterPadding more is needed.
int delta = popupItems.size() * kLinkLineHeight - kLinkPadding + int delta =
kLinkOuterPadding; listItems.size() * kLinkLineHeight - kLinkPadding + kLinkOuterPadding;
NSSize deltaSize = NSMakeSize(0, delta); NSSize deltaSize = NSMakeSize(0, delta);
deltaSize = [[[self window] contentView] convertSize:deltaSize toView:nil]; deltaSize = [[[self window] contentView] convertSize:deltaSize toView:nil];
NSRect windowFrame = [[self window] frame]; NSRect windowFrame = [[self window] frame];
windowFrame.size.height += deltaSize.height; windowFrame.size.height += deltaSize.height;
[[self window] setFrame:windowFrame display:NO]; [[self window] setFrame:windowFrame display:NO];
// Create popup list. // Create item list.
int topLinkY = NSMaxY(radioFrame) + delta - kLinkHeight; int topLinkY = NSMaxY(radioFrame) + delta - kLinkHeight;
int row = 0; int row = 0;
for (std::vector<ContentSettingBubbleModel::PopupItem>::const_iterator for (const ContentSettingBubbleModel::ListItem& listItem : listItems) {
it(popupItems.begin()); it != popupItems.end(); ++it, ++row) { NSImage* image = listItem.image.AsNSImage();
NSImage* image = it->image.AsNSImage(); NSRect frame = NSMakeRect(
NSMinX(radioFrame), topLinkY - kLinkLineHeight * row, 200, kLinkHeight);
std::string title(it->title); if (listItem.has_link) {
// The popup may not have committed a load yet, in which case it won't NSButton* button =
// have a URL or title. [self hyperlinkButtonWithFrame:frame
if (title.empty()) title:base::SysUTF8ToNSString(listItem.title)
title = l10n_util::GetStringUTF8(IDS_TAB_LOADING_TITLE); icon:image
referenceFrame:radioFrame];
NSRect linkFrame = [[self bubble] addSubview:button];
NSMakeRect(NSMinX(radioFrame), topLinkY - kLinkLineHeight * row, popupLinks_[button] = row++;
200, kLinkHeight); } else {
NSButton* button = [self NSTextField* label =
hyperlinkButtonWithFrame:linkFrame LabelWithFrame(base::SysUTF8ToNSString(listItem.title), frame);
title:base::SysUTF8ToNSString(title) SetControlSize(label, NSSmallControlSize);
icon:image [[self bubble] addSubview:label];
referenceFrame:radioFrame]; row++;
[[self bubble] addSubview:button]; }
popupLinks_[button] = row;
} }
} }
...@@ -531,12 +534,13 @@ class ContentSettingBubbleWebContentsObserverBridge ...@@ -531,12 +534,13 @@ class ContentSettingBubbleWebContentsObserverBridge
CGFloat maxMenuWidth = 0; CGFloat maxMenuWidth = 0;
CGFloat maxMenuHeight = 0; CGFloat maxMenuHeight = 0;
NSRect radioFrame = [allowBlockRadioGroup_ frame]; NSRect radioFrame = [allowBlockRadioGroup_ frame];
for (ContentSettingBubbleModel::MediaMenuMap::const_iterator it( for (const std::pair<content::MediaStreamType,
media_menus.begin()); it != media_menus.end(); ++it) { ContentSettingBubbleModel::MediaMenu>& map_entry :
media_menus) {
// |labelFrame| will be resized later on in this function. // |labelFrame| will be resized later on in this function.
NSRect labelFrame = NSMakeRect(NSMinX(radioFrame), 0, 0, 0); NSRect labelFrame = NSMakeRect(NSMinX(radioFrame), 0, 0, 0);
NSTextField* label = NSTextField* label = LabelWithFrame(
LabelWithFrame(base::SysUTF8ToNSString(it->second.label), labelFrame); base::SysUTF8ToNSString(map_entry.second.label), labelFrame);
SetControlSize(label, NSSmallControlSize); SetControlSize(label, NSSmallControlSize);
NSCell* cell = [label cell]; NSCell* cell = [label cell];
[cell setAlignment:NSRightTextAlignment]; [cell setAlignment:NSRightTextAlignment];
...@@ -553,15 +557,14 @@ class ContentSettingBubbleWebContentsObserverBridge ...@@ -553,15 +557,14 @@ class ContentSettingBubbleWebContentsObserverBridge
// Store the |label| and |button| into MediaMenuParts struct and build // Store the |label| and |button| into MediaMenuParts struct and build
// the popup menu from the menu model. // the popup menu from the menu model.
content_setting_bubble::MediaMenuParts* menuParts = content_setting_bubble::MediaMenuParts* menuParts =
new content_setting_bubble::MediaMenuParts(it->first, label); new content_setting_bubble::MediaMenuParts(map_entry.first, label);
menuParts->model.reset(new ContentSettingMediaMenuModel( menuParts->model.reset(new ContentSettingMediaMenuModel(
it->first, contentSettingBubbleModel_.get(), map_entry.first, contentSettingBubbleModel_.get(),
ContentSettingMediaMenuModel::MenuLabelChangedCallback())); ContentSettingMediaMenuModel::MenuLabelChangedCallback()));
mediaMenus_[button] = menuParts; mediaMenus_[button] = menuParts;
CGFloat width = BuildPopUpMenuFromModel(button, CGFloat width = BuildPopUpMenuFromModel(
menuParts->model.get(), button, menuParts->model.get(), map_entry.second.selected_device.name,
it->second.selected_device.name, map_entry.second.disabled);
it->second.disabled);
maxMenuWidth = std::max(maxMenuWidth, width); maxMenuWidth = std::max(maxMenuWidth, width);
[[self bubble] addSubview:button [[self bubble] addSubview:button
...@@ -593,20 +596,20 @@ class ContentSettingBubbleWebContentsObserverBridge ...@@ -593,20 +596,20 @@ class ContentSettingBubbleWebContentsObserverBridge
// Resize and reposition the media menus layout. // Resize and reposition the media menus layout.
CGFloat topMenuY = NSMinY(radioFrame) - kMediaMenuVerticalPadding; CGFloat topMenuY = NSMinY(radioFrame) - kMediaMenuVerticalPadding;
maxMenuWidth = std::max(maxMenuWidth, kMinMediaMenuButtonWidth); maxMenuWidth = std::max(maxMenuWidth, kMinMediaMenuButtonWidth);
for (content_setting_bubble::MediaMenuPartsMap::const_iterator i = for (const std::pair<NSPopUpButton*, content_setting_bubble::MediaMenuParts*>&
mediaMenus_.begin(); i != mediaMenus_.end(); ++i) { map_entry : mediaMenus_) {
NSRect labelFrame = [i->second->label frame]; NSRect labelFrame = [map_entry.second->label frame];
// Align the label text with the button text. // Align the label text with the button text.
labelFrame.origin.y = labelFrame.origin.y =
topMenuY + (maxMenuHeight - labelFrame.size.height) / 2 + 1; topMenuY + (maxMenuHeight - labelFrame.size.height) / 2 + 1;
labelFrame.size.width = maxLabelWidth; labelFrame.size.width = maxLabelWidth;
[i->second->label setFrame:labelFrame]; [map_entry.second->label setFrame:labelFrame];
NSRect menuFrame = [i->first frame]; NSRect menuFrame = [map_entry.first frame];
menuFrame.origin.y = topMenuY; menuFrame.origin.y = topMenuY;
menuFrame.origin.x = NSMinX(radioFrame) + maxLabelWidth; menuFrame.origin.x = NSMinX(radioFrame) + maxLabelWidth;
menuFrame.size.width = maxMenuWidth; menuFrame.size.width = maxMenuWidth;
menuFrame.size.height = maxMenuHeight; menuFrame.size.height = maxMenuHeight;
[i->first setFrame:menuFrame]; [map_entry.first setFrame:menuFrame];
topMenuY -= (maxMenuHeight + kMediaMenuElementVerticalPadding); topMenuY -= (maxMenuHeight + kMediaMenuElementVerticalPadding);
} }
} }
...@@ -748,8 +751,9 @@ class ContentSettingBubbleWebContentsObserverBridge ...@@ -748,8 +751,9 @@ class ContentSettingBubbleWebContentsObserverBridge
if (allowBlockRadioGroup_) // not bound in cookie bubble xib if (allowBlockRadioGroup_) // not bound in cookie bubble xib
[self initializeRadioGroup]; [self initializeRadioGroup];
if (type == CONTENT_SETTINGS_TYPE_POPUPS) if (type == CONTENT_SETTINGS_TYPE_POPUPS ||
[self initializePopupList]; type == CONTENT_SETTINGS_TYPE_PLUGINS)
[self initializeItemList];
if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
[self initializeGeoLists]; [self initializeGeoLists];
if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM) if (type == CONTENT_SETTINGS_TYPE_MEDIASTREAM)
...@@ -769,7 +773,7 @@ class ContentSettingBubbleWebContentsObserverBridge ...@@ -769,7 +773,7 @@ class ContentSettingBubbleWebContentsObserverBridge
- (void)popupLinkClicked:(id)sender { - (void)popupLinkClicked:(id)sender {
content_setting_bubble::PopupLinks::iterator i(popupLinks_.find(sender)); content_setting_bubble::PopupLinks::iterator i(popupLinks_.find(sender));
DCHECK(i != popupLinks_.end()); DCHECK(i != popupLinks_.end());
contentSettingBubbleModel_->OnPopupClicked(i->second); contentSettingBubbleModel_->OnListItemClicked(i->second);
} }
- (void)clearGeolocationForCurrentHost:(id)sender { - (void)clearGeolocationForCurrentHost:(id)sender {
......
...@@ -34,15 +34,19 @@ class ContentSettingBubbleModel : public content::NotificationObserver { ...@@ -34,15 +34,19 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
public: public:
typedef ContentSettingBubbleModelDelegate Delegate; typedef ContentSettingBubbleModelDelegate Delegate;
struct PopupItem { struct ListItem {
PopupItem(const gfx::Image& image, const std::string& title, int32 popup_id) ListItem(const gfx::Image& image,
: image(image), title(title), popup_id(popup_id) {} const std::string& title,
bool has_link,
int32 item_id)
: image(image), title(title), has_link(has_link), item_id(item_id) {}
gfx::Image image; gfx::Image image;
std::string title; std::string title;
int32 popup_id; bool has_link;
int32 item_id;
}; };
typedef std::vector<PopupItem> PopupItems; typedef std::vector<ListItem> ListItems;
typedef std::vector<std::string> RadioItems; typedef std::vector<std::string> RadioItems;
struct RadioGroup { struct RadioGroup {
...@@ -79,8 +83,7 @@ class ContentSettingBubbleModel : public content::NotificationObserver { ...@@ -79,8 +83,7 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
~BubbleContent(); ~BubbleContent();
std::string title; std::string title;
base::string16 plugin_names; ListItems list_items;
PopupItems popup_items;
RadioGroup radio_group; RadioGroup radio_group;
bool radio_group_enabled; bool radio_group_enabled;
std::vector<DomainList> domain_lists; std::vector<DomainList> domain_lists;
...@@ -112,7 +115,7 @@ class ContentSettingBubbleModel : public content::NotificationObserver { ...@@ -112,7 +115,7 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
const content::NotificationDetails& details) override; const content::NotificationDetails& details) override;
virtual void OnRadioClicked(int radio_index) {} virtual void OnRadioClicked(int radio_index) {}
virtual void OnPopupClicked(int index) {} virtual void OnListItemClicked(int index) {}
virtual void OnCustomLinkClicked() {} virtual void OnCustomLinkClicked() {}
virtual void OnManageLinkClicked() {} virtual void OnManageLinkClicked() {}
virtual void OnLearnMoreLinkClicked() {} virtual void OnLearnMoreLinkClicked() {}
...@@ -133,11 +136,8 @@ class ContentSettingBubbleModel : public content::NotificationObserver { ...@@ -133,11 +136,8 @@ class ContentSettingBubbleModel : public content::NotificationObserver {
Profile* profile() const { return profile_; } Profile* profile() const { return profile_; }
void set_title(const std::string& title) { bubble_content_.title = title; } void set_title(const std::string& title) { bubble_content_.title = title; }
void set_plugin_names(const base::string16& plugin_names) { void add_list_item(const ListItem& item) {
bubble_content_.plugin_names = plugin_names; bubble_content_.list_items.push_back(item);
}
void add_popup(const PopupItem& popup) {
bubble_content_.popup_items.push_back(popup);
} }
void set_radio_group(const RadioGroup& radio_group) { void set_radio_group(const RadioGroup& radio_group) {
bubble_content_.radio_group = radio_group; bubble_content_.radio_group = radio_group;
...@@ -213,8 +213,7 @@ class ContentSettingRPHBubbleModel : public ContentSettingTitleAndLinkModel { ...@@ -213,8 +213,7 @@ class ContentSettingRPHBubbleModel : public ContentSettingTitleAndLinkModel {
ContentSettingRPHBubbleModel(Delegate* delegate, ContentSettingRPHBubbleModel(Delegate* delegate,
content::WebContents* web_contents, content::WebContents* web_contents,
Profile* profile, Profile* profile,
ProtocolHandlerRegistry* registry, ProtocolHandlerRegistry* registry);
ContentSettingsType content_type);
void OnRadioClicked(int radio_index) override; void OnRadioClicked(int radio_index) override;
void OnDoneClicked() override; void OnDoneClicked() override;
......
...@@ -47,7 +47,7 @@ class ContentSettingBubbleModelTest : public ChromeRenderViewHostTestHarness { ...@@ -47,7 +47,7 @@ class ContentSettingBubbleModelTest : public ChromeRenderViewHostTestHarness {
content_setting_bubble_model->bubble_content(); content_setting_bubble_model->bubble_content();
EXPECT_TRUE(bubble_content.title.empty()); EXPECT_TRUE(bubble_content.title.empty());
EXPECT_TRUE(bubble_content.radio_group.radio_items.empty()); EXPECT_TRUE(bubble_content.radio_group.radio_items.empty());
EXPECT_TRUE(bubble_content.popup_items.empty()); EXPECT_TRUE(bubble_content.list_items.empty());
EXPECT_EQ(expected_domains, bubble_content.domain_lists.size()); EXPECT_EQ(expected_domains, bubble_content.domain_lists.size());
EXPECT_NE(expect_clear_link || expect_reload_hint, EXPECT_NE(expect_clear_link || expect_reload_hint,
bubble_content.custom_link.empty()); bubble_content.custom_link.empty());
...@@ -96,7 +96,6 @@ TEST_F(ContentSettingBubbleModelTest, Cookies) { ...@@ -96,7 +96,6 @@ TEST_F(ContentSettingBubbleModelTest, Cookies) {
content_setting_bubble_model->bubble_content(); content_setting_bubble_model->bubble_content();
std::string title = bubble_content.title; std::string title = bubble_content.title;
EXPECT_FALSE(title.empty()); EXPECT_FALSE(title.empty());
EXPECT_TRUE(bubble_content.plugin_names.empty());
ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size()); ASSERT_EQ(2U, bubble_content.radio_group.radio_items.size());
std::string radio1 = bubble_content.radio_group.radio_items[0]; std::string radio1 = bubble_content.radio_group.radio_items[0];
std::string radio2 = bubble_content.radio_group.radio_items[1]; std::string radio2 = bubble_content.radio_group.radio_items[1];
...@@ -742,9 +741,9 @@ TEST_F(ContentSettingBubbleModelTest, Plugins) { ...@@ -742,9 +741,9 @@ TEST_F(ContentSettingBubbleModelTest, Plugins) {
const ContentSettingBubbleModel::BubbleContent& bubble_content = const ContentSettingBubbleModel::BubbleContent& bubble_content =
content_setting_bubble_model->bubble_content(); content_setting_bubble_model->bubble_content();
EXPECT_FALSE(bubble_content.title.empty()); EXPECT_FALSE(bubble_content.title.empty());
EXPECT_FALSE(bubble_content.plugin_names.empty()); ASSERT_EQ(1U, bubble_content.list_items.size());
EXPECT_NE(base::string16::npos, EXPECT_EQ(plugin_name,
bubble_content.plugin_names.find(plugin_name)); base::ASCIIToUTF16(bubble_content.list_items[0].title));
EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size()); EXPECT_EQ(2U, bubble_content.radio_group.radio_items.size());
EXPECT_FALSE(bubble_content.custom_link.empty()); EXPECT_FALSE(bubble_content.custom_link.empty());
EXPECT_TRUE(bubble_content.custom_link_enabled); EXPECT_TRUE(bubble_content.custom_link_enabled);
...@@ -853,14 +852,13 @@ TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) { ...@@ -853,14 +852,13 @@ TEST_F(ContentSettingBubbleModelTest, RegisterProtocolHandler) {
"mailto", GURL("http://www.toplevel.example/"))); "mailto", GURL("http://www.toplevel.example/")));
ContentSettingRPHBubbleModel content_setting_bubble_model( ContentSettingRPHBubbleModel content_setting_bubble_model(
NULL, web_contents(), profile(), NULL, NULL, web_contents(), profile(), NULL);
CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS);
const ContentSettingBubbleModel::BubbleContent& bubble_content = const ContentSettingBubbleModel::BubbleContent& bubble_content =
content_setting_bubble_model.bubble_content(); content_setting_bubble_model.bubble_content();
EXPECT_FALSE(bubble_content.title.empty()); EXPECT_FALSE(bubble_content.title.empty());
EXPECT_FALSE(bubble_content.radio_group.radio_items.empty()); EXPECT_FALSE(bubble_content.radio_group.radio_items.empty());
EXPECT_TRUE(bubble_content.popup_items.empty()); EXPECT_TRUE(bubble_content.list_items.empty());
EXPECT_TRUE(bubble_content.domain_lists.empty()); EXPECT_TRUE(bubble_content.domain_lists.empty());
EXPECT_TRUE(bubble_content.custom_link.empty()); EXPECT_TRUE(bubble_content.custom_link.empty());
EXPECT_FALSE(bubble_content.custom_link_enabled); EXPECT_FALSE(bubble_content.custom_link_enabled);
...@@ -907,8 +905,7 @@ TEST_F(ContentSettingBubbleModelTest, RPHAllow) { ...@@ -907,8 +905,7 @@ TEST_F(ContentSettingBubbleModelTest, RPHAllow) {
content_settings->set_pending_protocol_handler(test_handler); content_settings->set_pending_protocol_handler(test_handler);
ContentSettingRPHBubbleModel content_setting_bubble_model( ContentSettingRPHBubbleModel content_setting_bubble_model(
NULL, web_contents(), profile(), &registry, NULL, web_contents(), profile(), &registry);
CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS);
{ {
ProtocolHandler handler = registry.GetHandlerFor("mailto"); ProtocolHandler handler = registry.GetHandlerFor("mailto");
......
...@@ -211,52 +211,38 @@ void ContentSettingBubbleContents::Init() { ...@@ -211,52 +211,38 @@ void ContentSettingBubbleContents::Init() {
bubble_content_empty = false; bubble_content_empty = false;
} }
if (!bubble_content.plugin_names.empty()) { // Layout for the item list (blocked plugins and popups).
const int kPluginsColumnSetId = 4; if (!bubble_content.list_items.empty()) {
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); const int kItemListColumnSetId = 2;
views::ColumnSet* plugins_column_set = views::ColumnSet* item_list_column_set =
layout->AddColumnSet(kPluginsColumnSetId); layout->AddColumnSet(kItemListColumnSetId);
plugins_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, item_list_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
plugins_column_set->AddPaddingColumn( item_list_column_set->AddPaddingColumn(
0, views::kRelatedControlHorizontalSpacing); 0, views::kRelatedControlHorizontalSpacing);
plugins_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1, item_list_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0); GridLayout::USE_PREF, 0, 0);
views::Label* plugin_names_label =
new views::Label(bubble_content.plugin_names);
plugin_names_label->SetMultiLine(true);
plugin_names_label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
layout->StartRow(0, kPluginsColumnSetId);
layout->AddView(plugin_names_label);
bubble_content_empty = false;
}
if (content_setting_bubble_model_->content_type() ==
CONTENT_SETTINGS_TYPE_POPUPS) {
const int kPopupColumnSetId = 2;
views::ColumnSet* popup_column_set =
layout->AddColumnSet(kPopupColumnSetId);
popup_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 0,
GridLayout::USE_PREF, 0, 0);
popup_column_set->AddPaddingColumn(
0, views::kRelatedControlHorizontalSpacing);
popup_column_set->AddColumn(GridLayout::LEADING, GridLayout::FILL, 1,
GridLayout::USE_PREF, 0, 0);
for (std::vector<ContentSettingBubbleModel::PopupItem>::const_iterator int row = 0;
i(bubble_content.popup_items.begin()); for (const ContentSettingBubbleModel::ListItem& list_item :
i != bubble_content.popup_items.end(); ++i) { bubble_content.list_items) {
if (!bubble_content_empty) if (!bubble_content_empty)
layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing); layout->AddPaddingRow(0, views::kRelatedControlVerticalSpacing);
layout->StartRow(0, kPopupColumnSetId); layout->StartRow(0, kItemListColumnSetId);
if (list_item.has_link) {
views::Link* link = new views::Link(base::UTF8ToUTF16(i->title)); views::Link* link = new views::Link(base::UTF8ToUTF16(list_item.title));
link->set_listener(this); link->set_listener(this);
link->SetElideBehavior(gfx::ELIDE_MIDDLE); link->SetElideBehavior(gfx::ELIDE_MIDDLE);
popup_links_[link] = i - bubble_content.popup_items.begin(); list_item_links_[link] = row;
layout->AddView(new Favicon(i->image, this, link)); layout->AddView(new Favicon(list_item.image, this, link));
layout->AddView(link); layout->AddView(link);
} else {
views::Label* label =
new views::Label(base::UTF8ToUTF16(list_item.title));
layout->AddView(new Favicon(list_item.image, this, NULL));
layout->AddView(label);
}
row++;
bubble_content_empty = false; bubble_content_empty = false;
} }
} }
...@@ -295,7 +281,7 @@ void ContentSettingBubbleContents::Init() { ...@@ -295,7 +281,7 @@ void ContentSettingBubbleContents::Init() {
// Layout code for the media device menus. // Layout code for the media device menus.
if (content_setting_bubble_model_->content_type() == if (content_setting_bubble_model_->content_type() ==
CONTENT_SETTINGS_TYPE_MEDIASTREAM) { CONTENT_SETTINGS_TYPE_MEDIASTREAM) {
const int kMediaMenuColumnSetId = 2; const int kMediaMenuColumnSetId = 4;
views::ColumnSet* menu_column_set = views::ColumnSet* menu_column_set =
layout->AddColumnSet(kMediaMenuColumnSetId); layout->AddColumnSet(kMediaMenuColumnSetId);
menu_column_set->AddPaddingColumn(0, views::kCheckboxIndent); menu_column_set->AddPaddingColumn(0, views::kCheckboxIndent);
...@@ -463,9 +449,9 @@ void ContentSettingBubbleContents::LinkClicked(views::Link* source, ...@@ -463,9 +449,9 @@ void ContentSettingBubbleContents::LinkClicked(views::Link* source,
return; return;
} }
PopupLinks::const_iterator i(popup_links_.find(source)); ListItemLinks::const_iterator i(list_item_links_.find(source));
DCHECK(i != popup_links_.end()); DCHECK(i != list_item_links_.end());
content_setting_bubble_model_->OnPopupClicked(i->second); content_setting_bubble_model_->OnListItemClicked(i->second);
} }
void ContentSettingBubbleContents::OnMenuButtonClicked( void ContentSettingBubbleContents::OnMenuButtonClicked(
......
...@@ -68,7 +68,7 @@ class ContentSettingBubbleContents : public content::WebContentsObserver, ...@@ -68,7 +68,7 @@ class ContentSettingBubbleContents : public content::WebContentsObserver,
class Favicon; class Favicon;
struct MediaMenuParts; struct MediaMenuParts;
typedef std::map<views::Link*, int> PopupLinks; typedef std::map<views::Link*, int> ListItemLinks;
typedef std::map<views::MenuButton*, MediaMenuParts*> MediaMenuPartsMap; typedef std::map<views::MenuButton*, MediaMenuParts*> MediaMenuPartsMap;
// content::WebContentsObserver: // content::WebContentsObserver:
...@@ -97,7 +97,7 @@ class ContentSettingBubbleContents : public content::WebContentsObserver, ...@@ -97,7 +97,7 @@ class ContentSettingBubbleContents : public content::WebContentsObserver,
// Some of our controls, so we can tell what's been clicked when we get a // Some of our controls, so we can tell what's been clicked when we get a
// message. // message.
PopupLinks popup_links_; ListItemLinks list_item_links_;
typedef std::vector<views::RadioButton*> RadioGroup; typedef std::vector<views::RadioButton*> RadioGroup;
RadioGroup radio_group_; RadioGroup radio_group_;
views::Link* custom_link_; views::Link* custom_link_;
......
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