Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 205 webContents:(content::WebContents*)webContents | 205 webContents:(content::WebContents*)webContents |
| 206 parentWindow:(NSWindow*)parentWindow | 206 parentWindow:(NSWindow*)parentWindow |
| 207 anchoredAt:(NSPoint)anchoredAt; | 207 anchoredAt:(NSPoint)anchoredAt; |
| 208 - (NSString*)getNibPathForModel:(ContentSettingBubbleModel*)model; | 208 - (NSString*)getNibPathForModel:(ContentSettingBubbleModel*)model; |
| 209 - (NSButton*)hyperlinkButtonWithFrame:(NSRect)frame | 209 - (NSButton*)hyperlinkButtonWithFrame:(NSRect)frame |
| 210 title:(NSString*)title | 210 title:(NSString*)title |
| 211 icon:(NSImage*)icon | 211 icon:(NSImage*)icon |
| 212 referenceFrame:(NSRect)referenceFrame; | 212 referenceFrame:(NSRect)referenceFrame; |
| 213 - (void)initializeBlockedPluginsList; | 213 - (void)initializeBlockedPluginsList; |
| 214 - (void)initializeTitle; | 214 - (void)initializeTitle; |
| 215 - (void)initializeMessage; | |
| 215 - (void)initializeRadioGroup; | 216 - (void)initializeRadioGroup; |
| 216 - (void)initializeItemList; | 217 - (void)initializeItemList; |
| 217 - (void)initializeGeoLists; | 218 - (void)initializeGeoLists; |
| 218 - (void)initializeMediaMenus; | 219 - (void)initializeMediaMenus; |
| 219 - (void)initializeMIDISysExLists; | 220 - (void)initializeMIDISysExLists; |
| 220 - (void)sizeToFitLoadButton; | 221 - (void)sizeToFitLoadButton; |
| 221 - (void)initManageDoneButtons; | 222 - (void)initManageDoneButtons; |
| 222 - (void)removeInfoButton; | 223 - (void)removeInfoButton; |
| 223 - (void)popupLinkClicked:(id)sender; | 224 - (void)popupLinkClicked:(id)sender; |
| 224 - (void)clearGeolocationForCurrentHost:(id)sender; | 225 - (void)clearGeolocationForCurrentHost:(id)sender; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 322 CGFloat deltaY = [GTMUILocalizerAndLayoutTweaker | 323 CGFloat deltaY = [GTMUILocalizerAndLayoutTweaker |
| 323 sizeToFitFixedWidthTextField:titleLabel_]; | 324 sizeToFitFixedWidthTextField:titleLabel_]; |
| 324 NSRect windowFrame = [[self window] frame]; | 325 NSRect windowFrame = [[self window] frame]; |
| 325 windowFrame.size.height += deltaY; | 326 windowFrame.size.height += deltaY; |
| 326 [[self window] setFrame:windowFrame display:NO]; | 327 [[self window] setFrame:windowFrame display:NO]; |
| 327 NSRect titleFrame = [titleLabel_ frame]; | 328 NSRect titleFrame = [titleLabel_ frame]; |
| 328 titleFrame.origin.y -= deltaY; | 329 titleFrame.origin.y -= deltaY; |
| 329 [titleLabel_ setFrame:titleFrame]; | 330 [titleLabel_ setFrame:titleFrame]; |
| 330 } | 331 } |
| 331 | 332 |
| 333 - (void)initializeMessage { | |
| 334 if (!messageLabel_) | |
| 335 return; | |
| 336 | |
| 337 NSString* label = base::SysUTF16ToNSString( | |
| 338 contentSettingBubbleModel_->bubble_content().message); | |
| 339 [messageLabel_ setStringValue:label]; | |
| 340 | |
| 341 // Layout title post-localization. | |
| 342 CGFloat deltaY = [GTMUILocalizerAndLayoutTweaker | |
| 343 sizeToFitFixedWidthTextField:messageLabel_]; | |
| 344 NSRect windowFrame = [[self window] frame]; | |
| 345 windowFrame.size.height += deltaY; | |
| 346 [[self window] setFrame:windowFrame display:NO]; | |
| 347 NSRect messageFrame = [messageLabel_ frame]; | |
| 348 messageFrame.origin.y -= deltaY; | |
| 349 [messageLabel_ setFrame:messageFrame]; | |
| 350 } | |
| 351 | |
| 332 - (void)initializeRadioGroup { | 352 - (void)initializeRadioGroup { |
| 333 // NOTE! Tags in the xib files must match the order of the radio buttons | 353 // NOTE! Tags in the xib files must match the order of the radio buttons |
| 334 // passed in the radio_group and be 1-based, not 0-based. | 354 // passed in the radio_group and be 1-based, not 0-based. |
| 335 const ContentSettingBubbleModel::BubbleContent& bubble_content = | 355 const ContentSettingBubbleModel::BubbleContent& bubble_content = |
| 336 contentSettingBubbleModel_->bubble_content(); | 356 contentSettingBubbleModel_->bubble_content(); |
| 337 const ContentSettingBubbleModel::RadioGroup& radio_group = | 357 const ContentSettingBubbleModel::RadioGroup& radio_group = |
| 338 bubble_content.radio_group; | 358 bubble_content.radio_group; |
| 339 | 359 |
| 340 // Xcode 5.1 Interface Builder doesn't allow a font property to be set for | 360 // Xcode 5.1 Interface Builder doesn't allow a font property to be set for |
| 341 // NSMatrix. The implementation of GTMUILocalizerAndLayoutTweaker assumes that | 361 // NSMatrix. The implementation of GTMUILocalizerAndLayoutTweaker assumes that |
| (...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 762 | 782 |
| 763 - (void)awakeFromNib { | 783 - (void)awakeFromNib { |
| 764 [super awakeFromNib]; | 784 [super awakeFromNib]; |
| 765 | 785 |
| 766 [[self bubble] setArrowLocation:info_bubble::kTopRight]; | 786 [[self bubble] setArrowLocation:info_bubble::kTopRight]; |
| 767 | 787 |
| 768 // Adapt window size to bottom buttons. Do this before all other layouting. | 788 // Adapt window size to bottom buttons. Do this before all other layouting. |
| 769 [self initManageDoneButtons]; | 789 [self initManageDoneButtons]; |
| 770 | 790 |
| 771 [self initializeTitle]; | 791 [self initializeTitle]; |
| 772 | 792 |
|
Nico
2016/09/15 19:26:50
nit: i wouldn't put a newline here
melandory
2016/09/15 19:55:02
Done.
| |
| 793 [self initializeMessage]; | |
| 794 | |
| 773 // Note that the per-content-type methods and |initializeRadioGroup| below | 795 // Note that the per-content-type methods and |initializeRadioGroup| below |
| 774 // must be kept in the correct order, as they make interdependent adjustments | 796 // must be kept in the correct order, as they make interdependent adjustments |
| 775 // of the bubble's height. | 797 // of the bubble's height. |
| 776 ContentSettingSimpleBubbleModel* simple_bubble = | 798 ContentSettingSimpleBubbleModel* simple_bubble = |
| 777 contentSettingBubbleModel_->AsSimpleBubbleModel(); | 799 contentSettingBubbleModel_->AsSimpleBubbleModel(); |
| 778 if (simple_bubble && | 800 if (simple_bubble && |
| 779 simple_bubble->content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) { | 801 simple_bubble->content_type() == CONTENT_SETTINGS_TYPE_PLUGINS) { |
| 780 [self sizeToFitLoadButton]; | 802 [self sizeToFitLoadButton]; |
| 781 [self initializeBlockedPluginsList]; | 803 [self initializeBlockedPluginsList]; |
| 782 } | 804 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 button, base::SysUTF16ToNSString(it->second->model->GetLabelAt(index))); | 880 button, base::SysUTF16ToNSString(it->second->model->GetLabelAt(index))); |
| 859 | 881 |
| 860 it->second->model->ExecuteCommand(index, 0); | 882 it->second->model->ExecuteCommand(index, 0); |
| 861 } | 883 } |
| 862 | 884 |
| 863 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus { | 885 - (content_setting_bubble::MediaMenuPartsMap*)mediaMenus { |
| 864 return &mediaMenus_; | 886 return &mediaMenus_; |
| 865 } | 887 } |
| 866 | 888 |
| 867 @end // ContentSettingBubbleController | 889 @end // ContentSettingBubbleController |
| OLD | NEW |