| Index: chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm
|
| ===================================================================
|
| --- chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm (revision 147078)
|
| +++ chrome/browser/ui/cocoa/content_settings/content_setting_bubble_cocoa.mm (working copy)
|
| @@ -23,6 +23,12 @@
|
|
|
| namespace {
|
|
|
| +// Must match the tag of the unblock radio button in the xib files.
|
| +const int kAllowTag = 1;
|
| +
|
| +// Must match the tag of the block radio button in the xib files.
|
| +const int kBlockTag = 2;
|
| +
|
| // Height of one link in the popup list.
|
| const int kLinkHeight = 16;
|
|
|
| @@ -131,8 +137,6 @@
|
| nibPath = @"ContentBlockedGeolocation"; break;
|
| case CONTENT_SETTINGS_TYPE_MIXEDSCRIPT:
|
| nibPath = @"ContentBlockedMixedScript"; break;
|
| - case CONTENT_SETTINGS_TYPE_PROTOCOL_HANDLERS:
|
| - nibPath = @"ContentProtocolHandlers"; break;
|
| default:
|
| NOTREACHED();
|
| }
|
| @@ -165,21 +169,25 @@
|
| }
|
|
|
| - (void)initializeRadioGroup {
|
| - // NOTE! Tags in the xib files must match the order of the radio buttons
|
| - // passed in the radio_group and be 1-based, not 0-based.
|
| + // Configure the radio group. For now, only deal with the
|
| + // strictly needed case of group containing 2 radio buttons.
|
| const ContentSettingBubbleModel::RadioGroup& radio_group =
|
| contentSettingBubbleModel_->bubble_content().radio_group;
|
|
|
| // Select appropriate radio button.
|
| - [allowBlockRadioGroup_ selectCellWithTag: radio_group.default_item + 1];
|
| + [allowBlockRadioGroup_ selectCellWithTag:
|
| + radio_group.default_item == 0 ? kAllowTag : kBlockTag];
|
|
|
| const ContentSettingBubbleModel::RadioItems& radio_items =
|
| radio_group.radio_items;
|
| - for (size_t ii = 0; ii < radio_group.radio_items.size(); ++ii) {
|
| - NSCell* radioCell = [allowBlockRadioGroup_ cellWithTag: ii + 1];
|
| - [radioCell setTitle:base::SysUTF8ToNSString(radio_items[ii])];
|
| - }
|
| + DCHECK_EQ(2u, radio_items.size()) << "Only 2 radio items per group supported";
|
| + // Set radio group labels from model.
|
| + NSCell* radioCell = [allowBlockRadioGroup_ cellWithTag:kAllowTag];
|
| + [radioCell setTitle:base::SysUTF8ToNSString(radio_items[0])];
|
|
|
| + radioCell = [allowBlockRadioGroup_ cellWithTag:kBlockTag];
|
| + [radioCell setTitle:base::SysUTF8ToNSString(radio_items[1])];
|
| +
|
| // Layout radio group labels post-localization.
|
| [GTMUILocalizerAndLayoutTweaker
|
| wrapRadioGroupForWidth:allowBlockRadioGroup_];
|
| @@ -438,7 +446,6 @@
|
| [self sizeToFitLoadButton];
|
| [self initializeBlockedPluginsList];
|
| }
|
| -
|
| if (allowBlockRadioGroup_) // not bound in cookie bubble xib
|
| [self initializeRadioGroup];
|
|
|
| @@ -453,7 +460,8 @@
|
|
|
| - (IBAction)allowBlockToggled:(id)sender {
|
| NSButtonCell *selectedCell = [sender selectedCell];
|
| - contentSettingBubbleModel_->OnRadioClicked([selectedCell tag] - 1);
|
| + contentSettingBubbleModel_->OnRadioClicked(
|
| + [selectedCell tag] == kAllowTag ? 0 : 1);
|
| }
|
|
|
| - (void)popupLinkClicked:(id)sender {
|
|
|