Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(171)

Side by Side Diff: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm

Issue 2593743002: [HBD] Update Cocoa to match removed controls from Plugins Blocked popup. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h " 5 #import "chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
465 for (const ContentSettingBubbleModel::ListItem& listItem : listItems) { 465 for (const ContentSettingBubbleModel::ListItem& listItem : listItems) {
466 NSImage* image = listItem.image.AsNSImage(); 466 NSImage* image = listItem.image.AsNSImage();
467 NSRect frame = NSMakeRect( 467 NSRect frame = NSMakeRect(
468 NSMinX(radioFrame), topLinkY - kLinkLineHeight * row, 200, kLinkHeight); 468 NSMinX(radioFrame), topLinkY - kLinkLineHeight * row, 200, kLinkHeight);
469 if (listItem.has_link) { 469 if (listItem.has_link) {
470 NSButton* button = 470 NSButton* button =
471 [self hyperlinkButtonWithFrame:frame 471 [self hyperlinkButtonWithFrame:frame
472 title:base::SysUTF8ToNSString(listItem.title) 472 title:base::SysUTF8ToNSString(listItem.title)
473 icon:image 473 icon:image
474 referenceFrame:radioFrame]; 474 referenceFrame:radioFrame];
475 [button setAutoresizingMask:NSViewMinYMargin];
475 [[self bubble] addSubview:button]; 476 [[self bubble] addSubview:button];
476 popupLinks_[button] = row++; 477 popupLinks_[button] = row++;
477 } else { 478 } else {
478 NSTextField* label = 479 NSTextField* label =
479 LabelWithFrame(base::SysUTF8ToNSString(listItem.title), frame); 480 LabelWithFrame(base::SysUTF8ToNSString(listItem.title), frame);
480 SetControlSize(label, NSSmallControlSize); 481 SetControlSize(label, NSSmallControlSize);
482 [label setAutoresizingMask:NSViewMinYMargin];
481 [[self bubble] addSubview:label]; 483 [[self bubble] addSubview:label];
482 row++; 484 row++;
483 } 485 }
484 } 486 }
485 } 487 }
486 488
487 - (void)initializeGeoLists { 489 - (void)initializeGeoLists {
488 // Cocoa has its origin in the lower left corner. This means elements are 490 // Cocoa has its origin in the lower left corner. This means elements are
489 // added from bottom to top, which explains why loops run backwards and the 491 // added from bottom to top, which explains why loops run backwards and the
490 // order of operations is the other way than on Linux/Windows. 492 // order of operations is the other way than on Linux/Windows.
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 size = [[[self window] contentView] convertSize:size toView:nil]; 777 size = [[[self window] contentView] convertSize:size toView:nil];
776 NSRect frame = [[self window] frame]; 778 NSRect frame = [[self window] frame];
777 frame.origin.x -= size.width; 779 frame.origin.x -= size.width;
778 frame.size.width += size.width; 780 frame.size.width += size.width;
779 [[self window] setFrame:frame display:NO]; 781 [[self window] setFrame:frame display:NO];
780 } 782 }
781 783
782 - (void)awakeFromNib { 784 - (void)awakeFromNib {
783 [super awakeFromNib]; 785 [super awakeFromNib];
784 786
787 ContentSettingSimpleBubbleModel* simple_bubble =
788 contentSettingBubbleModel_->AsSimpleBubbleModel();
789
785 [[self bubble] setArrowLocation:info_bubble::kTopRight]; 790 [[self bubble] setArrowLocation:info_bubble::kTopRight];
786 791
787 // Adapt window size to bottom buttons. Do this before all other layouting. 792 // Adapt window size to bottom buttons. Do this before all other layouting.
788 [self initManageDoneButtons]; 793 if (simple_bubble && !simple_bubble->bubble_content().manage_text.empty())
794 [self initManageDoneButtons];
789 795
790 [self initializeTitle]; 796 [self initializeTitle];
791 [self initializeMessage]; 797 [self initializeMessage];
792 798
793 // Note that the per-content-type methods and |initializeRadioGroup| below 799 // Note that the per-content-type methods and |initializeRadioGroup| below
794 // must be kept in the correct order, as they make interdependent adjustments 800 // must be kept in the correct order, as they make interdependent adjustments
795 // of the bubble's height. 801 // of the bubble's height.
796 ContentSettingSimpleBubbleModel* simple_bubble =
797 contentSettingBubbleModel_->AsSimpleBubbleModel();
798 if (simple_bubble && 802 if (simple_bubble &&
799 simple_bubble->content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) { 803 simple_bubble->content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) {
800 [self sizeToFitLoadButton]; 804 if (!simple_bubble->bubble_content().custom_link.empty())
805 [self sizeToFitLoadButton];
806
801 [self initializeBlockedPluginsList]; 807 [self initializeBlockedPluginsList];
802 } 808 }
803 809
804 if (allowBlockRadioGroup_) // Some xibs do not bind |allowBlockRadioGroup_|. 810 if (allowBlockRadioGroup_) // Some xibs do not bind |allowBlockRadioGroup_|.
805 [self initializeRadioGroup]; 811 [self initializeRadioGroup];
806 812
807 if (simple_bubble) { 813 if (simple_bubble) {
808 ContentSettingsType type = simple_bubble->content_type(); 814 ContentSettingsType type = simple_bubble->content_type();
809 815
810 if (type == CONTENT_SETTINGS_TYPE_POPUPS || 816 if (type == CONTENT_SETTINGS_TYPE_POPUPS ||
811 type == CONTENT_SETTINGS_TYPE_PLUGINS) 817 type == CONTENT_SETTINGS_TYPE_PLUGINS)
812 [self initializeItemList]; 818 [self initializeItemList];
813 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION) 819 if (type == CONTENT_SETTINGS_TYPE_GEOLOCATION)
814 [self initializeGeoLists]; 820 [self initializeGeoLists];
815 if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX) 821 if (type == CONTENT_SETTINGS_TYPE_MIDI_SYSEX)
816 [self initializeMIDISysExLists]; 822 [self initializeMIDISysExLists];
823
824 // For plugins, many controls are now removed. Remove them after the item
825 // list has been placed to preserve the existing layout logic.
826 if (type == CONTENT_SETTINGS_TYPE_PLUGINS) {
827 // The radio group is no longer applicable to plugins.
828 int delta = NSHeight([allowBlockRadioGroup_ frame]);
829 [allowBlockRadioGroup_ removeFromSuperview];
830
831 // Remove the "Load All" button if the model specifes it as empty.
832 if (simple_bubble->bubble_content().custom_link.empty()) {
833 delta += NSHeight([loadButton_ frame]);
834 [loadButton_ removeFromSuperview];
835 }
836
837 // Remove the "Manage" button if the model specifies it as empty.
838 if (simple_bubble->bubble_content().manage_text.empty())
839 [manageButton_ removeFromSuperview];
840
841 NSRect frame = [[self window] frame];
842 frame.size.height -= delta;
843 [[self window] setFrame:frame display:NO];
844 }
817 } 845 }
818 846
819 if (contentSettingBubbleModel_->AsMediaStreamBubbleModel()) 847 if (contentSettingBubbleModel_->AsMediaStreamBubbleModel())
820 [self initializeMediaMenus]; 848 [self initializeMediaMenus];
821 } 849 }
822 850
823 /////////////////////////////////////////////////////////////////////////////// 851 ///////////////////////////////////////////////////////////////////////////////
824 // Actual application logic 852 // Actual application logic
825 853
826 - (IBAction)allowBlockToggled:(id)sender { 854 - (IBAction)allowBlockToggled:(id)sender {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
881 909
882 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus { 910 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus {
883 return &mediaMenus_; 911 return &mediaMenus_;
884 } 912 }
885 913
886 - (LocationBarDecoration*)decorationForBubble { 914 - (LocationBarDecoration*)decorationForBubble {
887 return decoration_; 915 return decoration_;
888 } 916 }
889 917
890 @end // ContentSettingBubbleController 918 @end // ContentSettingBubbleController
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698