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/web_intent_sheet_controller.h" | 5 #import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h" |
| 6 | 6 |
| 7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
| 8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
| 9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
| 10 #include "chrome/browser/ui/browser_list.h" | 10 #include "chrome/browser/ui/browser_list.h" |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 29 #include "ui/base/l10n/l10n_util.h" | 29 #include "ui/base/l10n/l10n_util.h" |
| 30 #include "ui/base/l10n/l10n_util_mac.h" | 30 #include "ui/base/l10n/l10n_util_mac.h" |
| 31 #include "ui/base/resource/resource_bundle.h" | 31 #include "ui/base/resource/resource_bundle.h" |
| 32 #include "ui/base/text/text_elider.h" | 32 #include "ui/base/text/text_elider.h" |
| 33 #include "ui/gfx/font.h" | 33 #include "ui/gfx/font.h" |
| 34 #include "ui/gfx/image/image.h" | 34 #include "ui/gfx/image/image.h" |
| 35 | 35 |
| 36 using content::OpenURLParams; | 36 using content::OpenURLParams; |
| 37 using content::Referrer; | 37 using content::Referrer; |
| 38 | 38 |
| 39 @interface HyperlinkButtonCell (Private) | |
| 40 - (void)customizeButtonCell; | |
| 41 @end | |
| 42 | |
| 43 @interface CustomLinkButtonCell : HyperlinkButtonCell | |
| 44 @end | |
| 45 | |
| 39 namespace { | 46 namespace { |
| 40 | 47 |
| 41 // The width of a service button, in view coordinates. | 48 // The width of a service button, in view coordinates. |
| 42 const CGFloat kServiceButtonWidth = 300; | 49 const CGFloat kServiceButtonWidth = 300; |
| 43 | 50 |
| 44 // Spacing in between sections. | 51 // Spacing in between sections. |
| 45 const CGFloat kVerticalSpacing = 18; | 52 const CGFloat kVerticalSpacing = 18; |
| 46 | 53 |
| 47 // Square size of the close button. | 54 // Square size of the close button. |
| 48 const CGFloat kCloseButtonSize = 16; | 55 const CGFloat kCloseButtonSize = 16; |
| 49 | 56 |
| 50 // Font size for picker header. | |
| 51 const CGFloat kHeaderFontSize = 14.5; | |
| 52 | |
| 53 // Width of the text fields. | 57 // Width of the text fields. |
| 54 const CGFloat kTextWidth = WebIntentPicker::kWindowWidth - | 58 const CGFloat kTextWidth = WebIntentPicker::kWindowWidth - |
| 55 (WebIntentPicker::kContentAreaBorder * 2.0 + kCloseButtonSize); | 59 (WebIntentPicker::kContentAreaBorder * 2.0 + kCloseButtonSize); |
| 56 | 60 |
| 57 // Maximum number of intents (suggested and installed) displayed. | 61 // Maximum number of intents (suggested and installed) displayed. |
| 58 const int kMaxIntentRows = 4; | 62 const int kMaxIntentRows = 4; |
| 59 | 63 |
| 60 // Sets properties on the given |field| to act as title or description labels. | 64 // Sets properties on the given |field| to act as title or description labels. |
| 61 void ConfigureTextFieldAsLabel(NSTextField* field) { | 65 void ConfigureTextFieldAsLabel(NSTextField* field) { |
| 62 [field setEditable:NO]; | 66 [field setEditable:NO]; |
| 63 [field setSelectable:YES]; | 67 [field setSelectable:YES]; |
| 64 [field setDrawsBackground:NO]; | 68 [field setDrawsBackground:NO]; |
| 65 [field setBezeled:NO]; | 69 [field setBezeled:NO]; |
| 66 } | 70 } |
| 67 | 71 |
| 68 NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { | 72 NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) { |
| 69 NSButton* button = [[NSButton alloc] initWithFrame:frame]; | 73 NSButton* button = [[NSButton alloc] initWithFrame:frame]; |
| 70 scoped_nsobject<HyperlinkButtonCell> cell( | 74 scoped_nsobject<CustomLinkButtonCell> cell( |
| 71 [[HyperlinkButtonCell alloc] initTextCell:title]); | 75 [[CustomLinkButtonCell alloc] initTextCell:title]); |
| 72 [cell setControlSize:NSSmallControlSize]; | 76 [cell setControlSize:NSSmallControlSize]; |
| 73 [button setCell:cell.get()]; | 77 [button setCell:cell.get()]; |
| 74 [button setButtonType:NSMomentaryPushInButton]; | 78 [button setButtonType:NSMomentaryPushInButton]; |
| 75 [button setBezelStyle:NSRegularSquareBezelStyle]; | 79 [button setBezelStyle:NSRegularSquareBezelStyle]; |
| 76 | 80 |
| 77 return button; | 81 return button; |
| 78 } | 82 } |
| 79 | 83 |
| 80 } // namespace | 84 } // namespace |
| 81 | 85 |
| 86 | |
| 87 // Provide custom link format for intent picker. Removes underline attribute, | |
| 88 // since UX direction is "look like WebUI". | |
| 89 @implementation CustomLinkButtonCell | |
| 90 - (void)customizeButtonCell { | |
| 91 [super customizeButtonCell]; | |
| 92 [self setTextColor:[NSColor colorWithDeviceRed:0xff/255.0 | |
| 93 green:0x11/255.0 | |
| 94 blue:0x55/255.0 | |
| 95 alpha:0xcc/255.0]]; | |
| 96 } | |
| 97 | |
| 98 - (NSDictionary*)linkAttributes { | |
| 99 scoped_nsobject<NSMutableParagraphStyle> paragraphStyle( | |
| 100 [[NSParagraphStyle defaultParagraphStyle] mutableCopy]); | |
|
Nico
2012/09/11 06:56:36
indent 2 more
groby-ooo-7-16
2012/09/12 22:39:11
Done.
| |
| 101 [paragraphStyle setAlignment:[self alignment]]; | |
| 102 | |
| 103 return @{ | |
| 104 NSForegroundColorAttributeName: [self textColor], | |
| 105 NSFontAttributeName: [self font], | |
| 106 NSCursorAttributeName: [NSCursor pointingHandCursor], | |
| 107 NSParagraphStyleAttributeName: paragraphStyle.get() | |
| 108 }; | |
| 109 } | |
| 110 @end | |
| 111 | |
| 82 // This simple NSView subclass is used as the single subview of the page info | 112 // This simple NSView subclass is used as the single subview of the page info |
| 83 // bubble's window's contentView. Drawing is flipped so that layout of the | 113 // bubble's window's contentView. Drawing is flipped so that layout of the |
| 84 // sections is easier. Apple recommends flipping the coordinate origin when | 114 // sections is easier. Apple recommends flipping the coordinate origin when |
| 85 // doing a lot of text layout because it's more natural. | 115 // doing a lot of text layout because it's more natural. |
| 86 @interface WebIntentsContentView : NSView | 116 @interface WebIntentsContentView : NSView |
| 87 @end | 117 @end |
| 88 @implementation WebIntentsContentView | 118 @implementation WebIntentsContentView |
| 89 - (BOOL)isFlipped { | 119 - (BOOL)isFlipped { |
| 90 return YES; | 120 return YES; |
| 91 } | 121 } |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 244 kTextWidth, 1); | 274 kTextWidth, 1); |
| 245 subtitleField_.reset([[NSTextField alloc] initWithFrame:frame]); | 275 subtitleField_.reset([[NSTextField alloc] initWithFrame:frame]); |
| 246 ConfigureTextFieldAsLabel(subtitleField_); | 276 ConfigureTextFieldAsLabel(subtitleField_); |
| 247 gfx::Font textFont = rb.GetFont(ConstrainedWindow::kTextFontStyle); | 277 gfx::Font textFont = rb.GetFont(ConstrainedWindow::kTextFontStyle); |
| 248 [subtitleField_ setFont:textFont.GetNativeFont()]; | 278 [subtitleField_ setFont:textFont.GetNativeFont()]; |
| 249 | 279 |
| 250 frame = NSMakeRect(0, 0, WebIntentPicker::kWindowWidth, 1.0); | 280 frame = NSMakeRect(0, 0, WebIntentPicker::kWindowWidth, 1.0); |
| 251 spacer_.reset([[NSBox alloc] initWithFrame:frame]); | 281 spacer_.reset([[NSBox alloc] initWithFrame:frame]); |
| 252 [spacer_ setBoxType:NSBoxSeparator]; | 282 [spacer_ setBoxType:NSBoxSeparator]; |
| 253 [spacer_ setBorderColor:[NSColor blackColor]]; | 283 [spacer_ setBorderColor:[NSColor blackColor]]; |
| 284 [spacer_ setAlphaValue:0.2]; | |
| 254 | 285 |
| 255 NSArray* subviews = @[titleField_, subtitleField_, spacer_]; | 286 NSArray* subviews = @[titleField_, subtitleField_, spacer_]; |
| 256 [self setSubviews:subviews]; | 287 [self setSubviews:subviews]; |
| 257 } | 288 } |
| 258 return self; | 289 return self; |
| 259 } | 290 } |
| 260 | 291 |
| 261 - (void)setTitle:(NSString*)title { | 292 - (void)setTitle:(NSString*)title { |
| 262 NSRect frame = [titleField_ frame]; | 293 NSRect frame = [titleField_ frame]; |
| 263 [titleField_ setStringValue:title]; | 294 [titleField_ setStringValue:title]; |
| (...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 685 styleMask:NSTitledWindowMask | 716 styleMask:NSTitledWindowMask |
| 686 backing:NSBackingStoreBuffered | 717 backing:NSBackingStoreBuffered |
| 687 defer:YES]); | 718 defer:YES]); |
| 688 if ((self = [super initWithWindow:window.get()])) { | 719 if ((self = [super initWithWindow:window.get()])) { |
| 689 picker_ = picker; | 720 picker_ = picker; |
| 690 if (picker) | 721 if (picker) |
| 691 model_ = picker->model(); | 722 model_ = picker->model(); |
| 692 | 723 |
| 693 inlineDispositionTitleField_.reset([[NSTextField alloc] init]); | 724 inlineDispositionTitleField_.reset([[NSTextField alloc] init]); |
| 694 ConfigureTextFieldAsLabel(inlineDispositionTitleField_); | 725 ConfigureTextFieldAsLabel(inlineDispositionTitleField_); |
| 695 | 726 [inlineDispositionTitleField_ setFont:[NSFont boldSystemFontOfSize:0]]; |
| 696 flipView_.reset([[WebIntentsContentView alloc] init]); | 727 flipView_.reset([[WebIntentsContentView alloc] init]); |
| 697 [flipView_ setAutoresizingMask:NSViewMinYMargin]; | 728 [flipView_ setAutoresizingMask:NSViewMinYMargin]; |
| 698 [[[self window] contentView] setSubviews: | 729 [[[self window] contentView] setSubviews: |
| 699 [NSArray arrayWithObject:flipView_]]; | 730 [NSArray arrayWithObject:flipView_]]; |
| 700 | 731 |
| 701 [self performLayoutWithModel:model_]; | 732 [self performLayoutWithModel:model_]; |
| 702 [[self window] makeFirstResponder:self]; | 733 [[self window] makeFirstResponder:self]; |
| 703 } | 734 } |
| 704 return self; | 735 return self; |
| 705 } | 736 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 746 containerSize.height += | 777 containerSize.height += |
| 747 [webContentView frame].origin.y + WebIntentPicker::kContentAreaBorder; | 778 [webContentView frame].origin.y + WebIntentPicker::kContentAreaBorder; |
| 748 containerSize.width += 2 * WebIntentPicker::kContentAreaBorder; | 779 containerSize.width += 2 * WebIntentPicker::kContentAreaBorder; |
| 749 | 780 |
| 750 // Ensure minimum container width. | 781 // Ensure minimum container width. |
| 751 containerSize.width = | 782 containerSize.width = |
| 752 std::max(CGFloat(WebIntentPicker::kWindowWidth), containerSize.width); | 783 std::max(CGFloat(WebIntentPicker::kWindowWidth), containerSize.width); |
| 753 | 784 |
| 754 // Resize web contents. | 785 // Resize web contents. |
| 755 [webContentView setFrameSize:inlineContentSize]; | 786 [webContentView setFrameSize:inlineContentSize]; |
| 756 | |
| 757 // Position close button. | |
| 758 NSRect buttonFrame = [closeButton_ frame]; | |
| 759 buttonFrame.origin.x = containerSize.width - | |
| 760 WebIntentPicker::kContentAreaBorder - kCloseButtonSize; | |
| 761 [closeButton_ setFrame:buttonFrame]; | |
| 762 | |
| 763 [self setContainerSize:containerSize]; | 787 [self setContainerSize:containerSize]; |
| 764 } | 788 } |
| 765 | 789 |
| 766 - (void)setContainerSize:(NSSize)containerSize { | 790 - (void)setContainerSize:(NSSize)containerSize { |
| 767 // Resize container views | 791 // Resize container views |
| 768 NSRect frame = NSMakeRect(0, 0, 0, 0); | 792 NSRect frame = NSMakeRect(0, 0, 0, 0); |
| 769 frame.size = containerSize; | 793 frame.size = containerSize; |
| 770 [[[self window] contentView] setFrame:frame]; | 794 [[[self window] contentView] setFrame:frame]; |
| 771 [flipView_ setFrame:frame]; | 795 [flipView_ setFrame:frame]; |
| 772 | 796 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 843 [button setAction:@selector(showChromeWebStore:)]; | 867 [button setAction:@selector(showChromeWebStore:)]; |
| 844 [subviews addObject:button.get()]; | 868 [subviews addObject:button.get()]; |
| 845 | 869 |
| 846 // Call size-to-fit to fixup for the localized string. | 870 // Call size-to-fit to fixup for the localized string. |
| 847 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; | 871 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button.get()]; |
| 848 | 872 |
| 849 return NSHeight([button frame]); | 873 return NSHeight([button frame]); |
| 850 } | 874 } |
| 851 | 875 |
| 852 - (void)addCloseButtonToSubviews:(NSMutableArray*)subviews { | 876 - (void)addCloseButtonToSubviews:(NSMutableArray*)subviews { |
| 877 const CGFloat kButtonPadding = 4.0; // whitespace inside button frame. | |
| 853 if (!closeButton_.get()) { | 878 if (!closeButton_.get()) { |
| 854 NSRect buttonFrame = NSMakeRect( | 879 NSRect buttonFrame = NSMakeRect( |
| 855 WebIntentPicker::kContentAreaBorder + kTextWidth, | 880 WebIntentPicker::kContentAreaBorder + kTextWidth + kButtonPadding, |
| 856 WebIntentPicker::kContentAreaBorder, | 881 WebIntentPicker::kContentAreaBorder - kButtonPadding, |
| 857 kCloseButtonSize, kCloseButtonSize); | 882 kCloseButtonSize, kCloseButtonSize); |
| 858 closeButton_.reset( | 883 closeButton_.reset( |
| 859 [[HoverCloseButton alloc] initWithFrame:buttonFrame]); | 884 [[HoverCloseButton alloc] initWithFrame:buttonFrame]); |
| 885 // Anchor close button to upper right. | |
| 886 // (NSViewMaxYMargin since parent view is flipped.) | |
| 887 [closeButton_ setAutoresizingMask:NSViewMaxYMargin|NSViewMinXMargin]; | |
| 860 [closeButton_ setTarget:self]; | 888 [closeButton_ setTarget:self]; |
| 861 [closeButton_ setAction:@selector(cancelOperation:)]; | 889 [closeButton_ setAction:@selector(cancelOperation:)]; |
| 862 } | 890 } |
| 863 [subviews addObject:closeButton_]; | 891 [subviews addObject:closeButton_]; |
| 864 } | 892 } |
| 865 | 893 |
| 866 // Adds a header (icon and explanatory text) to picker bubble. | 894 // Adds a header (icon and explanatory text) to picker bubble. |
| 867 // Returns the y position delta for the next offset. | 895 // Returns the y position delta for the next offset. |
| 868 - (CGFloat)addHeaderToSubviews:(NSMutableArray*)subviews | 896 - (CGFloat)addHeaderToSubviews:(NSMutableArray*)subviews |
| 869 atOffset:(CGFloat)offset { | 897 atOffset:(CGFloat)offset { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 904 WebIntentPicker::kContentAreaBorder, offset, size.width(), size.height()); | 932 WebIntentPicker::kContentAreaBorder, offset, size.width(), size.height()); |
| 905 | 933 |
| 906 [contents_->web_contents()->GetNativeView() setFrame:frame]; | 934 [contents_->web_contents()->GetNativeView() setFrame:frame]; |
| 907 [subviews addObject:contents_->web_contents()->GetNativeView()]; | 935 [subviews addObject:contents_->web_contents()->GetNativeView()]; |
| 908 | 936 |
| 909 return NSHeight(frame); | 937 return NSHeight(frame); |
| 910 } | 938 } |
| 911 | 939 |
| 912 - (CGFloat)addAnotherServiceLinkToSubviews:(NSMutableArray*)subviews | 940 - (CGFloat)addAnotherServiceLinkToSubviews:(NSMutableArray*)subviews |
| 913 atOffset:(CGFloat)offset { | 941 atOffset:(CGFloat)offset { |
| 942 DCHECK(model_); | |
| 943 DCHECK(model_->IsInlineDisposition()); | |
| 944 GURL url = model_->inline_disposition_url(); | |
| 914 | 945 |
| 946 const WebIntentPickerModel::InstalledService* service = | |
| 947 model_->GetInstalledServiceWithURL(url); | |
| 948 DCHECK(service); | |
| 949 | |
| 950 CGFloat originalOffset = offset; | |
| 951 | |
| 952 // Icon for current service. | |
| 953 scoped_nsobject<NSImageView> icon; | |
| 954 NSRect imageFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, offset, | |
| 955 0, 0); | |
| 956 icon.reset([[NSImageView alloc] initWithFrame:imageFrame]); | |
| 957 [icon setImage:service->favicon.ToNSImage()]; | |
| 958 [icon setImageFrameStyle:NSImageFrameNone]; | |
| 959 [icon setEnabled:YES]; | |
| 960 | |
| 961 imageFrame.size = [service->favicon.ToNSImage() size]; | |
| 962 [icon setFrame:imageFrame]; | |
| 963 | |
| 964 [subviews addObject:icon]; | |
| 965 | |
| 966 // Resize control to fit text | |
| 915 NSRect textFrame = | 967 NSRect textFrame = |
| 916 NSMakeRect(WebIntentPicker::kContentAreaBorder, offset, kTextWidth, 1); | 968 NSMakeRect(NSMaxX(imageFrame) + 4, |
| 969 offset, | |
| 970 WebIntentPicker::kTitleLinkMaxWidth, 1); | |
| 917 [inlineDispositionTitleField_ setFrame:textFrame]; | 971 [inlineDispositionTitleField_ setFrame:textFrame]; |
| 918 [subviews addObject:inlineDispositionTitleField_]; | 972 [subviews addObject:inlineDispositionTitleField_]; |
| 919 [GTMUILocalizerAndLayoutTweaker sizeToFitView:inlineDispositionTitleField_]; | 973 [GTMUILocalizerAndLayoutTweaker sizeToFitView:inlineDispositionTitleField_]; |
| 920 textFrame = [inlineDispositionTitleField_ frame]; | 974 textFrame = [inlineDispositionTitleField_ frame]; |
| 921 | 975 |
| 922 // Add link for "choose another service" if other suggestions are available | 976 // Add link for "choose another service" if other suggestions are available |
| 923 // or if more than one (the current) service is installed. | 977 // or if more than one (the current) service is installed. |
| 924 if (model_->GetInstalledServiceCount() > 1 || | 978 if (model_->GetInstalledServiceCount() > 1 || |
| 925 model_->GetSuggestedExtensionCount()) { | 979 model_->GetSuggestedExtensionCount()) { |
| 926 NSRect frame = NSMakeRect( | 980 NSRect frame = NSMakeRect( |
| 927 NSMaxX(textFrame) + WebIntentPicker::kContentAreaBorder, offset, | 981 NSMaxX(textFrame) + WebIntentPicker::kContentAreaBorder, offset, |
| 928 WebIntentPicker::kTitleLinkMaxWidth, 1); | 982 1, 1); |
| 929 NSString* string = l10n_util::GetNSStringWithFixup( | 983 NSString* string = l10n_util::GetNSStringWithFixup( |
| 930 IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE); | 984 IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE); |
| 931 scoped_nsobject<NSButton> button(CreateHyperlinkButton(string, frame)); | 985 scoped_nsobject<NSButton> button(CreateHyperlinkButton(string, frame)); |
| 932 [[button cell] setControlSize:NSRegularControlSize]; | 986 [[button cell] setControlSize:NSRegularControlSize]; |
| 987 [[button cell] setFont:[NSFont controlContentFontOfSize:0]]; | |
|
Nico
2012/09/11 06:56:36
nit: i think you replaced "0" with the explicit fo
groby-ooo-7-16
2012/09/12 22:39:11
Done.
| |
| 933 [button setTarget:self]; | 988 [button setTarget:self]; |
| 934 [button setAction:@selector(chooseAnotherService:)]; | 989 [button setAction:@selector(chooseAnotherService:)]; |
| 935 [subviews addObject:button]; | 990 [subviews addObject:button]; |
| 936 | 991 |
| 937 // Call size-to-fit to fixup for the localized string. | 992 // Call size-to-fit to fixup for the localized string. |
| 938 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button]; | 993 [GTMUILocalizerAndLayoutTweaker sizeToFitView:button]; |
| 939 | 994 |
| 995 // Right-align the "use another service" button. | |
| 996 frame = [button frame]; | |
| 997 frame.origin.x = WebIntentPicker::kWindowWidth - NSWidth(frame) - | |
| 998 2 * WebIntentPicker::kContentAreaBorder - kCloseButtonSize; | |
| 999 [button setFrame:frame]; | |
| 1000 [button setAutoresizingMask:NSViewMinXMargin]; | |
| 1001 | |
| 940 // And finally, make sure the link and the title are horizontally centered. | 1002 // And finally, make sure the link and the title are horizontally centered. |
| 941 frame = [button frame]; | 1003 frame = [button frame]; |
| 942 CGFloat height = std::max(NSHeight(textFrame), NSHeight(frame)); | 1004 CGFloat height = std::max(NSHeight(textFrame), NSHeight(frame)); |
| 943 frame.origin.y += (height - NSHeight(frame)) / 2.0; | 1005 frame.origin.y += (height - NSHeight(frame)) / 2.0; |
| 944 frame.size.height = height; | 1006 frame.size.height = height; |
| 945 textFrame.origin.y += (height - NSHeight(textFrame)) / 2.0; | 1007 textFrame.origin.y += (height - NSHeight(textFrame)) / 2.0; |
| 946 textFrame.size.height = height; | 1008 textFrame.size.height = height; |
| 947 [button setFrame:frame]; | 1009 [button setFrame:frame]; |
| 948 [inlineDispositionTitleField_ setFrame:textFrame]; | 1010 [inlineDispositionTitleField_ setFrame:textFrame]; |
| 949 } | 1011 } |
| 950 | 1012 |
| 951 return NSHeight(textFrame); | 1013 offset += NSHeight(textFrame) + kVerticalSpacing; |
| 1014 | |
| 1015 scoped_nsobject<NSBox> spacer; | |
| 1016 | |
| 1017 NSRect frame = NSMakeRect(0, offset, WebIntentPicker::kWindowWidth, 1.0); | |
| 1018 spacer.reset([[NSBox alloc] initWithFrame:frame]); | |
| 1019 [spacer setBoxType:NSBoxSeparator]; | |
| 1020 [spacer setAlphaValue:0.2]; | |
| 1021 [spacer setAutoresizingMask:NSViewWidthSizable]; | |
| 1022 [subviews addObject: spacer]; | |
| 1023 | |
| 1024 return offset + kVerticalSpacing - originalOffset; | |
| 952 } | 1025 } |
| 953 | 1026 |
| 954 - (NSView*)createEmptyView { | 1027 - (NSView*)createEmptyView { |
| 955 NSRect titleFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, | 1028 NSRect titleFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, |
| 956 WebIntentPicker::kContentAreaBorder, | 1029 WebIntentPicker::kContentAreaBorder, |
| 957 kTextWidth, 1); | 1030 kTextWidth, 1); |
| 958 scoped_nsobject<NSTextField> title( | 1031 scoped_nsobject<NSTextField> title( |
| 959 [[NSTextField alloc] initWithFrame:titleFrame]); | 1032 [[NSTextField alloc] initWithFrame:titleFrame]); |
| 960 ConfigureTextFieldAsLabel(title); | 1033 ConfigureTextFieldAsLabel(title); |
| 961 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1034 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1018 waitingView_.reset([[WaitingView alloc] init]); | 1091 waitingView_.reset([[WaitingView alloc] init]); |
| 1019 [subviews addObject:waitingView_]; | 1092 [subviews addObject:waitingView_]; |
| 1020 offset += NSHeight([waitingView_ frame]); | 1093 offset += NSHeight([waitingView_ frame]); |
| 1021 } else if (isEmpty) { | 1094 } else if (isEmpty) { |
| 1022 scoped_nsobject<NSView> emptyView([self createEmptyView]); | 1095 scoped_nsobject<NSView> emptyView([self createEmptyView]); |
| 1023 [subviews addObject:emptyView]; | 1096 [subviews addObject:emptyView]; |
| 1024 offset += NSHeight([emptyView frame]); | 1097 offset += NSHeight([emptyView frame]); |
| 1025 } else if (contents_) { | 1098 } else if (contents_) { |
| 1026 offset += [self addAnotherServiceLinkToSubviews:subviews | 1099 offset += [self addAnotherServiceLinkToSubviews:subviews |
| 1027 atOffset:offset]; | 1100 atOffset:offset]; |
| 1028 offset += WebIntentPicker::kContentAreaBorder; | |
| 1029 offset += [self addInlineHtmlToSubviews:subviews atOffset:offset]; | 1101 offset += [self addInlineHtmlToSubviews:subviews atOffset:offset]; |
| 1030 } else { | 1102 } else { |
| 1031 offset += [self addHeaderToSubviews:subviews atOffset:offset]; | 1103 offset += [self addHeaderToSubviews:subviews atOffset:offset]; |
| 1032 | 1104 |
| 1033 if (model) { | 1105 if (model) { |
| 1034 intentView_.reset( | 1106 intentView_.reset( |
| 1035 [[IntentView alloc] initWithModel:model forController:self]); | 1107 [[IntentView alloc] initWithModel:model forController:self]); |
| 1036 offset += [self addStackedView:intentView_ | 1108 offset += [self addStackedView:intentView_ |
| 1037 toSubviews:subviews | 1109 toSubviews:subviews |
| 1038 atOffset:offset]; | 1110 atOffset:offset]; |
| 1039 } | 1111 } |
| 1040 offset += [self addCwsButtonToSubviews:subviews atOffset:offset]; | 1112 offset += [self addCwsButtonToSubviews:subviews atOffset:offset]; |
| 1041 } | 1113 } |
| 1042 [self addCloseButtonToSubviews:subviews]; | |
| 1043 | 1114 |
| 1044 // Add the bottom padding. | 1115 // Add the bottom padding. |
| 1045 offset += WebIntentPicker::kContentAreaBorder; | 1116 offset += WebIntentPicker::kContentAreaBorder; |
| 1046 | 1117 |
| 1118 // Resize to fit. | |
| 1119 [self setContainerSize:NSMakeSize(WebIntentPicker::kWindowWidth, offset)]; | |
| 1120 | |
| 1121 [self addCloseButtonToSubviews:subviews]; | |
| 1122 | |
| 1047 // Replace the window's content. | 1123 // Replace the window's content. |
| 1048 [flipView_ setSubviews:subviews]; | 1124 [flipView_ setSubviews:subviews]; |
| 1049 | |
| 1050 // And resize to fit. | |
| 1051 [self setContainerSize:NSMakeSize(WebIntentPicker::kWindowWidth, offset)]; | |
| 1052 } | 1125 } |
| 1053 | 1126 |
| 1054 - (void)setActionString:(NSString*)actionString { | 1127 - (void)setActionString:(NSString*)actionString { |
| 1055 NSRect textFrame; | 1128 NSRect textFrame; |
| 1056 if (!actionTextField_.get()) { | 1129 if (!actionTextField_.get()) { |
| 1057 textFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0, | 1130 textFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0, |
| 1058 kTextWidth, 1); | 1131 kTextWidth, 1); |
| 1059 | 1132 |
| 1060 actionTextField_.reset([[NSTextField alloc] initWithFrame:textFrame]); | 1133 actionTextField_.reset([[NSTextField alloc] initWithFrame:textFrame]); |
| 1061 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 1134 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 1087 - (void)stopThrobber { | 1160 - (void)stopThrobber { |
| 1088 [closeButton_ setEnabled:YES]; | 1161 [closeButton_ setEnabled:YES]; |
| 1089 [intentView_ stopThrobber]; | 1162 [intentView_ stopThrobber]; |
| 1090 } | 1163 } |
| 1091 | 1164 |
| 1092 - (void)closeSheet { | 1165 - (void)closeSheet { |
| 1093 [NSApp endSheet:[self window]]; | 1166 [NSApp endSheet:[self window]]; |
| 1094 } | 1167 } |
| 1095 | 1168 |
| 1096 @end // WebIntentPickerSheetController | 1169 @end // WebIntentPickerSheetController |
| OLD | NEW |