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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings_bubble_controller.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 5 months 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 | Annotate | Revision Log
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/website_settings_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/website_settings_bubble_controller.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #import <AppKit/AppKit.h> 9 #import <AppKit/AppKit.h>
10 10
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 return [NSColor colorWithCalibratedRed:0x07/255.0 113 return [NSColor colorWithCalibratedRed:0x07/255.0
114 green:0x95/255.0 114 green:0x95/255.0
115 blue:0 115 blue:0
116 alpha:1.0]; 116 alpha:1.0];
117 } 117 }
118 118
119 } // namespace 119 } // namespace
120 120
121 @interface WebsiteSettingsTabSegmentedCell : NSSegmentedCell { 121 @interface WebsiteSettingsTabSegmentedCell : NSSegmentedCell {
122 @private 122 @private
123 scoped_nsobject<NSImage> tabstripCenterImage_; 123 base::scoped_nsobject<NSImage> tabstripCenterImage_;
124 scoped_nsobject<NSImage> tabstripLeftImage_; 124 base::scoped_nsobject<NSImage> tabstripLeftImage_;
125 scoped_nsobject<NSImage> tabstripRightImage_; 125 base::scoped_nsobject<NSImage> tabstripRightImage_;
126 126
127 scoped_nsobject<NSImage> tabCenterImage_; 127 base::scoped_nsobject<NSImage> tabCenterImage_;
128 scoped_nsobject<NSImage> tabLeftImage_; 128 base::scoped_nsobject<NSImage> tabLeftImage_;
129 scoped_nsobject<NSImage> tabRightImage_; 129 base::scoped_nsobject<NSImage> tabRightImage_;
130 130
131 // Key track of the index of segment which has keyboard focus. This is not 131 // Key track of the index of segment which has keyboard focus. This is not
132 // the same as the currently selected segment. 132 // the same as the currently selected segment.
133 NSInteger keySegment_; 133 NSInteger keySegment_;
134 } 134 }
135 @end 135 @end
136 136
137 @implementation WebsiteSettingsTabSegmentedCell 137 @implementation WebsiteSettingsTabSegmentedCell
138 - (id)init { 138 - (id)init {
139 if ((self = [super init])) { 139 if ((self = [super init])) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge 296 websiteSettingsUIBridge:(WebsiteSettingsUIBridge*)bridge
297 webContents:(content::WebContents*)webContents 297 webContents:(content::WebContents*)webContents
298 isInternalPage:(BOOL)isInternalPage { 298 isInternalPage:(BOOL)isInternalPage {
299 DCHECK(parentWindow); 299 DCHECK(parentWindow);
300 300
301 webContents_ = webContents; 301 webContents_ = webContents;
302 302
303 // Use an arbitrary height; it will be changed in performLayout. 303 // Use an arbitrary height; it will be changed in performLayout.
304 NSRect contentRect = NSMakeRect(0, 0, [self defaultWindowWidth], 1); 304 NSRect contentRect = NSMakeRect(0, 0, [self defaultWindowWidth], 1);
305 // Create an empty window into which content is placed. 305 // Create an empty window into which content is placed.
306 scoped_nsobject<InfoBubbleWindow> window( 306 base::scoped_nsobject<InfoBubbleWindow> window(
307 [[InfoBubbleWindow alloc] initWithContentRect:contentRect 307 [[InfoBubbleWindow alloc] initWithContentRect:contentRect
308 styleMask:NSBorderlessWindowMask 308 styleMask:NSBorderlessWindowMask
309 backing:NSBackingStoreBuffered 309 backing:NSBackingStoreBuffered
310 defer:NO]); 310 defer:NO]);
311 311
312 if ((self = [super initWithWindow:window.get() 312 if ((self = [super initWithWindow:window.get()
313 parentWindow:parentWindow 313 parentWindow:parentWindow
314 anchoredAt:NSZeroPoint])) { 314 anchoredAt:NSZeroPoint])) {
315 [[self bubble] setArrowLocation:info_bubble::kTopLeft]; 315 [[self bubble] setArrowLocation:info_bubble::kTopLeft];
316 316
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 396
397 // Create a text field to identity status (e.g. verified, not verified). 397 // Create a text field to identity status (e.g. verified, not verified).
398 identityStatusField_ = [self addText:string16() 398 identityStatusField_ = [self addText:string16()
399 withSize:[NSFont smallSystemFontSize] 399 withSize:[NSFont smallSystemFontSize]
400 bold:NO 400 bold:NO
401 toView:contentView_ 401 toView:contentView_
402 atPoint:controlOrigin]; 402 atPoint:controlOrigin];
403 403
404 // Create the tab view and its two tabs. 404 // Create the tab view and its two tabs.
405 405
406 scoped_nsobject<WebsiteSettingsTabSegmentedCell> cell( 406 base::scoped_nsobject<WebsiteSettingsTabSegmentedCell> cell(
407 [[WebsiteSettingsTabSegmentedCell alloc] init]); 407 [[WebsiteSettingsTabSegmentedCell alloc] init]);
408 CGFloat tabstripHeight = [cell cellSize].height; 408 CGFloat tabstripHeight = [cell cellSize].height;
409 NSRect tabstripFrame = NSMakeRect( 409 NSRect tabstripFrame = NSMakeRect(
410 0, 0, [self defaultWindowWidth], tabstripHeight); 410 0, 0, [self defaultWindowWidth], tabstripHeight);
411 segmentedControl_.reset( 411 segmentedControl_.reset(
412 [[NSSegmentedControl alloc] initWithFrame:tabstripFrame]); 412 [[NSSegmentedControl alloc] initWithFrame:tabstripFrame]);
413 [segmentedControl_ setCell:cell]; 413 [segmentedControl_ setCell:cell];
414 [segmentedControl_ setSegmentCount:WebsiteSettingsUI::NUM_TAB_IDS]; 414 [segmentedControl_ setSegmentCount:WebsiteSettingsUI::NUM_TAB_IDS];
415 [segmentedControl_ setTarget:self]; 415 [segmentedControl_ setTarget:self];
416 [segmentedControl_ setAction:@selector(tabSelected:)]; 416 [segmentedControl_ setAction:@selector(tabSelected:)];
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 permissionsTabContentView_ = [self addPermissionsTabToTabView:tabView_]; 463 permissionsTabContentView_ = [self addPermissionsTabToTabView:tabView_];
464 connectionTabContentView_ = [self addConnectionTabToTabView:tabView_]; 464 connectionTabContentView_ = [self addConnectionTabToTabView:tabView_];
465 [self setSelectedTab:WebsiteSettingsUI::TAB_ID_PERMISSIONS]; 465 [self setSelectedTab:WebsiteSettingsUI::TAB_ID_PERMISSIONS];
466 466
467 [self performLayout]; 467 [self performLayout];
468 } 468 }
469 469
470 // Create the contents of the Permissions tab and add it to the given tab view. 470 // Create the contents of the Permissions tab and add it to the given tab view.
471 // Returns a weak reference to the tab view item's view. 471 // Returns a weak reference to the tab view item's view.
472 - (NSView*)addPermissionsTabToTabView:(NSTabView*)tabView { 472 - (NSView*)addPermissionsTabToTabView:(NSTabView*)tabView {
473 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]); 473 base::scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]);
474 [tabView_ insertTabViewItem:item.get() 474 [tabView_ insertTabViewItem:item.get()
475 atIndex:WebsiteSettingsUI::TAB_ID_PERMISSIONS]; 475 atIndex:WebsiteSettingsUI::TAB_ID_PERMISSIONS];
476 scoped_nsobject<NSView> contentView([[FlippedView alloc] 476 base::scoped_nsobject<NSView> contentView(
477 initWithFrame:[tabView_ contentRect]]); 477 [[FlippedView alloc] initWithFrame:[tabView_ contentRect]]);
478 [contentView setAutoresizingMask:NSViewWidthSizable]; 478 [contentView setAutoresizingMask:NSViewWidthSizable];
479 [item setView:contentView.get()]; 479 [item setView:contentView.get()];
480 480
481 // Initialize the two containers that hold the controls. The initial frames 481 // Initialize the two containers that hold the controls. The initial frames
482 // are arbitrary, and will be adjusted after the controls are laid out. 482 // are arbitrary, and will be adjusted after the controls are laid out.
483 cookiesView_ = [[[FlippedView alloc] 483 cookiesView_ = [[[FlippedView alloc]
484 initWithFrame:[tabView_ contentRect]] autorelease]; 484 initWithFrame:[tabView_ contentRect]] autorelease];
485 [cookiesView_ setAutoresizingMask:NSViewWidthSizable]; 485 [cookiesView_ setAutoresizingMask:NSViewWidthSizable];
486 486
487 permissionsView_ = [[[FlippedView alloc] 487 permissionsView_ = [[[FlippedView alloc]
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
524 GURL(chrome::kPageInfoHelpCenterURL), 524 GURL(chrome::kPageInfoHelpCenterURL),
525 content::Referrer(), 525 content::Referrer(),
526 NEW_FOREGROUND_TAB, 526 NEW_FOREGROUND_TAB,
527 content::PAGE_TRANSITION_LINK, 527 content::PAGE_TRANSITION_LINK,
528 false)); 528 false));
529 } 529 }
530 530
531 // Create the contents of the Connection tab and add it to the given tab view. 531 // Create the contents of the Connection tab and add it to the given tab view.
532 // Returns a weak reference to the tab view item's view. 532 // Returns a weak reference to the tab view item's view.
533 - (NSView*)addConnectionTabToTabView:(NSTabView*)tabView { 533 - (NSView*)addConnectionTabToTabView:(NSTabView*)tabView {
534 scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]); 534 base::scoped_nsobject<NSTabViewItem> item([[NSTabViewItem alloc] init]);
535 scoped_nsobject<NSView> contentView([[FlippedView alloc] 535 base::scoped_nsobject<NSView> contentView(
536 initWithFrame:[tabView_ contentRect]]); 536 [[FlippedView alloc] initWithFrame:[tabView_ contentRect]]);
537 [contentView setAutoresizingMask:NSViewWidthSizable]; 537 [contentView setAutoresizingMask:NSViewWidthSizable];
538 538
539 // Place all the text and images at the same position. The positions will be 539 // Place all the text and images at the same position. The positions will be
540 // adjusted in performLayout. 540 // adjusted in performLayout.
541 NSPoint textPosition = NSMakePoint( 541 NSPoint textPosition = NSMakePoint(
542 kFramePadding + kConnectionImageSize + kConnectionImageSpacing, 542 kFramePadding + kConnectionImageSize + kConnectionImageSpacing,
543 kFramePadding); 543 kFramePadding);
544 NSPoint imagePosition = NSMakePoint(kFramePadding, kFramePadding); 544 NSPoint imagePosition = NSMakePoint(kFramePadding, kFramePadding);
545 NSSize imageSize = NSMakeSize(kConnectionImageSize, kConnectionImageSize); 545 NSSize imageSize = NSMakeSize(kConnectionImageSize, kConnectionImageSize);
546 546
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
775 // The array will retain a reference to the object. 775 // The array will retain a reference to the object.
776 - (NSTextField*)addText:(const string16&)text 776 - (NSTextField*)addText:(const string16&)text
777 withSize:(CGFloat)fontSize 777 withSize:(CGFloat)fontSize
778 bold:(BOOL)bold 778 bold:(BOOL)bold
779 toView:(NSView*)view 779 toView:(NSView*)view
780 atPoint:(NSPoint)point { 780 atPoint:(NSPoint)point {
781 // Size the text to take up the full available width, with some padding. 781 // Size the text to take up the full available width, with some padding.
782 // The height is arbitrary as it will be adjusted later. 782 // The height is arbitrary as it will be adjusted later.
783 CGFloat width = NSWidth([view frame]) - point.x - kFramePadding; 783 CGFloat width = NSWidth([view frame]) - point.x - kFramePadding;
784 NSRect frame = NSMakeRect(point.x, point.y, width, 100); 784 NSRect frame = NSMakeRect(point.x, point.y, width, 100);
785 scoped_nsobject<NSTextField> textField( 785 base::scoped_nsobject<NSTextField> textField(
786 [[NSTextField alloc] initWithFrame:frame]); 786 [[NSTextField alloc] initWithFrame:frame]);
787 [self configureTextFieldAsLabel:textField.get()]; 787 [self configureTextFieldAsLabel:textField.get()];
788 [textField setStringValue:base::SysUTF16ToNSString(text)]; 788 [textField setStringValue:base::SysUTF16ToNSString(text)];
789 NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize] 789 NSFont* font = bold ? [NSFont boldSystemFontOfSize:fontSize]
790 : [NSFont systemFontOfSize:fontSize]; 790 : [NSFont systemFontOfSize:fontSize];
791 [textField setFont:font]; 791 [textField setFont:font];
792 [self sizeTextFieldHeightToFit:textField]; 792 [self sizeTextFieldHeightToFit:textField];
793 [textField setAutoresizingMask:NSViewWidthSizable]; 793 [textField setAutoresizingMask:NSViewWidthSizable];
794 [view addSubview:textField.get()]; 794 [view addSubview:textField.get()];
795 return textField.get(); 795 return textField.get();
796 } 796 }
797 797
798 // Add an image as a subview of the given view, placed at a pre-determined x 798 // Add an image as a subview of the given view, placed at a pre-determined x
799 // position and the given y position. Return the new NSImageView. 799 // position and the given y position. Return the new NSImageView.
800 - (NSImageView*)addImageWithSize:(NSSize)size 800 - (NSImageView*)addImageWithSize:(NSSize)size
801 toView:(NSView*)view 801 toView:(NSView*)view
802 atPoint:(NSPoint)point { 802 atPoint:(NSPoint)point {
803 NSRect frame = NSMakeRect(point.x, point.y, size.width, size.height); 803 NSRect frame = NSMakeRect(point.x, point.y, size.width, size.height);
804 scoped_nsobject<NSImageView> imageView( 804 base::scoped_nsobject<NSImageView> imageView(
805 [[NSImageView alloc] initWithFrame:frame]); 805 [[NSImageView alloc] initWithFrame:frame]);
806 [imageView setImageFrameStyle:NSImageFrameNone]; 806 [imageView setImageFrameStyle:NSImageFrameNone];
807 [view addSubview:imageView.get()]; 807 [view addSubview:imageView.get()];
808 return imageView.get(); 808 return imageView.get();
809 } 809 }
810 810
811 // Add a separator as a subview of the given view. Return the new view. 811 // Add a separator as a subview of the given view. Return the new view.
812 - (NSView*)addSeparatorToView:(NSView*)view { 812 - (NSView*)addSeparatorToView:(NSView*)view {
813 // Take up almost the full width of the container's frame. 813 // Take up almost the full width of the container's frame.
814 CGFloat width = NSWidth([view frame]) - 2 * kFramePadding; 814 CGFloat width = NSWidth([view frame]) - 2 * kFramePadding;
815 815
816 // Use an arbitrary position; it will be adjusted in performLayout. 816 // Use an arbitrary position; it will be adjusted in performLayout.
817 NSBox* spacer = 817 NSBox* spacer =
818 [self separatorWithFrame:NSMakeRect(kFramePadding, 0, width, 0)]; 818 [self separatorWithFrame:NSMakeRect(kFramePadding, 0, width, 0)];
819 [view addSubview:spacer]; 819 [view addSubview:spacer];
820 return spacer; 820 return spacer;
821 } 821 }
822 822
823 // Add a link button with the given text to |view|. 823 // Add a link button with the given text to |view|.
824 - (NSButton*)addLinkButtonWithText:(NSString*)text toView:(NSView*)view { 824 - (NSButton*)addLinkButtonWithText:(NSString*)text toView:(NSView*)view {
825 // Frame size is arbitrary; it will be adjusted by the layout tweaker. 825 // Frame size is arbitrary; it will be adjusted by the layout tweaker.
826 NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10); 826 NSRect frame = NSMakeRect(kFramePadding, 0, 100, 10);
827 scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:frame]); 827 base::scoped_nsobject<NSButton> button(
828 scoped_nsobject<HyperlinkButtonCell> cell( 828 [[NSButton alloc] initWithFrame:frame]);
829 base::scoped_nsobject<HyperlinkButtonCell> cell(
829 [[HyperlinkButtonCell alloc] initTextCell:text]); 830 [[HyperlinkButtonCell alloc] initTextCell:text]);
830 [cell setControlSize:NSSmallControlSize]; 831 [cell setControlSize:NSSmallControlSize];
831 [button setCell:cell.get()]; 832 [button setCell:cell.get()];
832 [button setButtonType:NSMomentaryPushInButton]; 833 [button setButtonType:NSMomentaryPushInButton];
833 [button setBezelStyle:NSRegularSquareBezelStyle]; 834 [button setBezelStyle:NSRegularSquareBezelStyle];
834 [view addSubview:button.get()]; 835 [view addSubview:button.get()];
835 836
836 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; 837 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()];
837 return button.get(); 838 return button.get();
838 } 839 }
(...skipping 14 matching lines...) Expand all
853 NSHeight(buttonFrame)); 854 NSHeight(buttonFrame));
854 } 855 }
855 856
856 // Add a pop-up button for |permissionInfo| to the given view. 857 // Add a pop-up button for |permissionInfo| to the given view.
857 - (NSPopUpButton*)addPopUpButtonForPermission: 858 - (NSPopUpButton*)addPopUpButtonForPermission:
858 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo 859 (const WebsiteSettingsUI::PermissionInfo&)permissionInfo
859 toView:(NSView*)view 860 toView:(NSView*)view
860 atPoint:(NSPoint)point { 861 atPoint:(NSPoint)point {
861 // Use an arbitrary width and height; it will be sized to fit. 862 // Use an arbitrary width and height; it will be sized to fit.
862 NSRect frame = NSMakeRect(point.x, point.y, 1, 1); 863 NSRect frame = NSMakeRect(point.x, point.y, 1, 1);
863 scoped_nsobject<NSPopUpButton> button( 864 base::scoped_nsobject<NSPopUpButton> button(
864 [[NSPopUpButton alloc] initWithFrame:frame pullsDown:NO]); 865 [[NSPopUpButton alloc] initWithFrame:frame pullsDown:NO]);
865 [button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; 866 [button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
866 [button setBordered:NO]; 867 [button setBordered:NO];
867 [[button cell] setControlSize:NSSmallControlSize]; 868 [[button cell] setControlSize:NSSmallControlSize];
868 [button setTag:permissionInfo.type]; 869 [button setTag:permissionInfo.type];
869 [button setAction:@selector(permissionValueChanged:)]; 870 [button setAction:@selector(permissionValueChanged:)];
870 [button setTarget:self]; 871 [button setTarget:self];
871 872
872 // Create the popup menu. 873 // Create the popup menu.
873 // TODO(dubroy): Refactor this code to use PermissionMenuModel. 874 // TODO(dubroy): Refactor this code to use PermissionMenuModel.
(...skipping 15 matching lines...) Expand all
889 890
890 [button addItemWithTitle:l10n_util::GetNSStringF( 891 [button addItemWithTitle:l10n_util::GetNSStringF(
891 IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL, 892 IDS_WEBSITE_SETTINGS_DEFAULT_PERMISSION_LABEL,
892 WebsiteSettingsUI::PermissionValueToUIString( 893 WebsiteSettingsUI::PermissionValueToUIString(
893 permissionInfo.default_setting))]; 894 permissionInfo.default_setting))];
894 [[button lastItem] setTag:CONTENT_SETTING_DEFAULT]; 895 [[button lastItem] setTag:CONTENT_SETTING_DEFAULT];
895 896
896 [button selectItemWithTag:permissionInfo.setting]; 897 [button selectItemWithTag:permissionInfo.setting];
897 898
898 // Set the button title. 899 // Set the button title.
899 scoped_nsobject<NSMenuItem> titleItem([[NSMenuItem alloc] init]); 900 base::scoped_nsobject<NSMenuItem> titleItem([[NSMenuItem alloc] init]);
900 string16 buttonTitle = WebsiteSettingsUI::PermissionActionToUIString( 901 string16 buttonTitle = WebsiteSettingsUI::PermissionActionToUIString(
901 permissionInfo.setting, 902 permissionInfo.setting,
902 permissionInfo.default_setting, 903 permissionInfo.default_setting,
903 permissionInfo.source); 904 permissionInfo.source);
904 [titleItem setTitle:base::SysUTF16ToNSString(buttonTitle)]; 905 [titleItem setTitle:base::SysUTF16ToNSString(buttonTitle)];
905 [[button cell] setUsesItemFromMenu:NO]; 906 [[button cell] setUsesItemFromMenu:NO];
906 [[button cell] setMenuItem:titleItem.get()]; 907 [[button cell] setMenuItem:titleItem.get()];
907 [button sizeToFit]; 908 [button sizeToFit];
908 909
909 // Determine the largest possible size for this button. 910 // Determine the largest possible size for this button.
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
1232 [bubble_controller_ setPermissionInfo:permission_info_list]; 1233 [bubble_controller_ setPermissionInfo:permission_info_list];
1233 } 1234 }
1234 1235
1235 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) { 1236 void WebsiteSettingsUIBridge::SetFirstVisit(const string16& first_visit) {
1236 [bubble_controller_ setFirstVisit:first_visit]; 1237 [bubble_controller_ setFirstVisit:first_visit];
1237 } 1238 }
1238 1239
1239 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) { 1240 void WebsiteSettingsUIBridge::SetSelectedTab(TabId tab_id) {
1240 [bubble_controller_ setSelectedTab:tab_id]; 1241 [bubble_controller_ setSelectedTab:tab_id];
1241 } 1242 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698