1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "chrome/browser/ui/cocoa/web_intent_sheet_controller.h"
#include "base/memory/scoped_nsobject.h"
#include "base/sys_string_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/ui/browser_list.h"
#import "chrome/browser/ui/cocoa/event_utils.h"
#import "chrome/browser/ui/cocoa/hover_close_button.h"
#import "chrome/browser/ui/cocoa/hyperlink_button_cell.h"
#import "chrome/browser/ui/cocoa/info_bubble_view.h"
#import "chrome/browser/ui/cocoa/info_bubble_window.h"
#include "chrome/browser/ui/cocoa/web_intent_picker_cocoa.h"
#include "chrome/browser/ui/constrained_window.h"
#include "chrome/browser/ui/constrained_window_constants.h"
#include "chrome/browser/ui/intents/web_intent_picker_delegate.h"
#include "chrome/browser/ui/intents/web_intent_picker_model.h"
#include "chrome/browser/ui/tab_contents/tab_contents.h"
#import "chrome/browser/ui/cocoa/tabs/throbber_view.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_view.h"
#include "grit/generated_resources.h"
#include "grit/google_chrome_strings.h"
#include "grit/locale_settings.h"
#include "grit/theme_resources.h"
#include "grit/ui_resources.h"
#import "third_party/GTM/AppKit/GTMUILocalizerAndLayoutTweaker.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/l10n/l10n_util_mac.h"
#include "ui/base/resource/resource_bundle.h"
#include "ui/base/text/text_elider.h"
#include "ui/gfx/font.h"
#include "ui/gfx/image/image.h"
using content::OpenURLParams;
using content::Referrer;
@interface HyperlinkButtonCell (Private)
- (void)customizeButtonCell;
@end
@interface CustomLinkButtonCell : HyperlinkButtonCell
@end
namespace {
// The width of a service button, in view coordinates.
const CGFloat kServiceButtonWidth = 300;
// Spacing in between sections.
const CGFloat kVerticalSpacing = 18;
// Square size of the close button.
const CGFloat kCloseButtonSize = 16;
// Width of the text fields.
const CGFloat kTextWidth = WebIntentPicker::kWindowMinWidth -
(WebIntentPicker::kContentAreaBorder * 2.0 + kCloseButtonSize);
// Maximum number of intents (suggested and installed) displayed.
const int kMaxIntentRows = 4;
// Sets properties on the given |field| to act as title or description labels.
void ConfigureTextFieldAsLabel(NSTextField* field) {
[field setEditable:NO];
[field setSelectable:YES];
[field setDrawsBackground:NO];
[field setBezeled:NO];
}
NSButton* CreateHyperlinkButton(NSString* title, const NSRect& frame) {
NSButton* button = [[NSButton alloc] initWithFrame:frame];
scoped_nsobject<CustomLinkButtonCell> cell(
[[CustomLinkButtonCell alloc] initTextCell:title]);
[cell setControlSize:NSSmallControlSize];
[button setCell:cell.get()];
[button setButtonType:NSMomentaryPushInButton];
[button setBezelStyle:NSRegularSquareBezelStyle];
return button;
}
} // namespace
// Provide custom link format for intent picker. Removes underline attribute,
// since UX direction is "look like WebUI".
@implementation CustomLinkButtonCell
- (void)customizeButtonCell {
[super customizeButtonCell];
[self setTextColor:[NSColor colorWithDeviceRed:0x11/255.0
green:0x55/255.0
blue:0xcc/255.0
alpha:0xff/255.0]];
}
- (NSDictionary*)linkAttributes {
scoped_nsobject<NSMutableParagraphStyle> paragraphStyle(
[[NSParagraphStyle defaultParagraphStyle] mutableCopy]);
[paragraphStyle setAlignment:[self alignment]];
return @{
NSForegroundColorAttributeName: [self textColor],
NSFontAttributeName: [self font],
NSCursorAttributeName: [NSCursor pointingHandCursor],
NSParagraphStyleAttributeName: paragraphStyle.get()
};
}
@end
// This simple NSView subclass is used as the single subview of the page info
// bubble's window's contentView. Drawing is flipped so that layout of the
// sections is easier. Apple recommends flipping the coordinate origin when
// doing a lot of text layout because it's more natural.
@interface WebIntentsContentView : NSView
@end
@implementation WebIntentsContentView
- (BOOL)isFlipped {
return YES;
}
- (void)drawRect:(NSRect)rect {
[[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] set];
NSRectFill(rect);
}
@end
// NSImageView subclassed to allow fading the alpha value of the image to
// indicate an inactive/disabled extension.
@interface DimmableImageView : NSImageView {
@private
CGFloat alpha;
}
- (void)setEnabled:(BOOL)enabled;
// NSView override
- (void)drawRect:(NSRect)rect;
@end
@implementation DimmableImageView
- (void)drawRect:(NSRect)rect {
NSImage* image = [self image];
NSRect sourceRect, destinationRect;
sourceRect.origin = NSZeroPoint;
sourceRect.size = [image size];
destinationRect.origin = NSZeroPoint;
destinationRect.size = [self frame].size;
// If the source image is smaller than the destination, center it.
if (destinationRect.size.width > sourceRect.size.width) {
destinationRect.origin.x =
(destinationRect.size.width - sourceRect.size.width) / 2.0;
destinationRect.size.width = sourceRect.size.width;
}
if (destinationRect.size.height > sourceRect.size.height) {
destinationRect.origin.y =
(destinationRect.size.height - sourceRect.size.height) / 2.0;
destinationRect.size.height = sourceRect.size.height;
}
[image drawInRect:destinationRect
fromRect:sourceRect
operation:NSCompositeSourceOver
fraction:alpha];
}
- (void)setEnabled:(BOOL)enabled {
if (enabled)
alpha = 1.0;
else
alpha = 0.5;
[self setNeedsDisplay:YES];
}
@end
@interface WaitingView : NSView {
@private
scoped_nsobject<NSTextField> text_;
scoped_nsobject<ThrobberView> throbber_;
}
@end
@implementation WaitingView
- (id)init {
NSRect frame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0,
kTextWidth, 140);
if (self = [super initWithFrame:frame]) {
const CGFloat kTopMargin = 35.0;
const CGFloat kBottomMargin = 25.0;
const CGFloat kVerticalSpacing = 18.0;
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
frame.origin = NSMakePoint(WebIntentPicker::kContentAreaBorder,
kBottomMargin);
frame.size.width = kTextWidth;
text_.reset([[NSTextField alloc] initWithFrame:frame]);
ConfigureTextFieldAsLabel(text_);
[text_ setAlignment:NSCenterTextAlignment];
[text_ setFont:[NSFont boldSystemFontOfSize:[NSFont systemFontSize]]];
[text_ setStringValue:
l10n_util::GetNSStringWithFixup(IDS_INTENT_PICKER_WAIT_FOR_CWS)];
frame.size.height +=
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:
text_];
[text_ setFrame:frame];
frame.origin.y += NSHeight(frame) + kVerticalSpacing;
// The sprite image consists of all the animation frames put together in one
// horizontal/wide image. Each animation frame is square in shape within the
// sprite.
NSImage* iconImage =
rb.GetNativeImageNamed(IDR_SPEECH_INPUT_SPINNER).ToNSImage();
frame.size = [iconImage size];
frame.size.width = NSHeight(frame);
frame.origin.x = (WebIntentPicker::kWindowMinWidth - NSWidth(frame))/2.0;
throbber_.reset([ThrobberView filmstripThrobberViewWithFrame:frame
image:iconImage]);
frame.size = NSMakeSize(WebIntentPicker::kWindowMinWidth,
NSMaxY(frame) + kTopMargin);
frame.origin = NSMakePoint(0, 0);
[self setSubviews:@[throbber_, text_]];
[self setFrame:frame];
}
return self;
}
@end
// An NSView subclass to display ratings stars.
@interface RatingsView : NSView
// Mark RatingsView as disabled/enabled.
- (void)setEnabled:(BOOL)enabled;
@end
@implementation RatingsView
- (void)setEnabled:(BOOL)enabled {
for (DimmableImageView* imageView in [self subviews])
[imageView setEnabled:enabled];
}
@end
// NSView for the header of the box.
@interface HeaderView : NSView {
@private
// Used to forward button clicks. Weak reference.
scoped_nsobject<NSTextField> titleField_;
scoped_nsobject<NSTextField> subtitleField_;
scoped_nsobject<NSBox> spacer_;
}
- (id)init;
@end
@implementation HeaderView
- (id)init {
NSRect contentFrame = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, 1);
if (self = [super initWithFrame:contentFrame]) {
NSRect frame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0,
kTextWidth, 1);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
titleField_.reset([[NSTextField alloc] initWithFrame:frame]);
ConfigureTextFieldAsLabel(titleField_);
gfx::Font titleFont = rb.GetFont(
ConstrainedWindowConstants::kTitleFontStyle);
titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD);
[titleField_ setFont:titleFont.GetNativeFont()];
frame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0,
kTextWidth, 1);
subtitleField_.reset([[NSTextField alloc] initWithFrame:frame]);
ConfigureTextFieldAsLabel(subtitleField_);
gfx::Font textFont = rb.GetFont(ConstrainedWindowConstants::kTextFontStyle);
[subtitleField_ setFont:textFont.GetNativeFont()];
frame = NSMakeRect(0, 0, WebIntentPicker::kWindowMinWidth, 1.0);
spacer_.reset([[NSBox alloc] initWithFrame:frame]);
[spacer_ setBoxType:NSBoxSeparator];
[spacer_ setBorderColor:[NSColor blackColor]];
[spacer_ setAlphaValue:0.2];
NSArray* subviews = @[titleField_, subtitleField_, spacer_];
[self setSubviews:subviews];
}
return self;
}
- (void)setTitle:(NSString*)title {
NSRect frame = [titleField_ frame];
[titleField_ setStringValue:title];
frame.size.height +=
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:
titleField_];
[titleField_ setFrame:frame];
}
- (void)setSubtitle:(NSString*)subtitle {
if (subtitle && [subtitle length]) {
NSRect frame = [subtitleField_ frame];
[subtitleField_ setHidden:FALSE];
[subtitleField_ setStringValue:subtitle];
frame.size.height +=
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:
subtitleField_];
[subtitleField_ setFrame:frame];
} else {
[subtitleField_ setHidden:TRUE];
}
}
- (void)performLayout {
CGFloat offset = kVerticalSpacing;
NSRect frame = [spacer_ frame];
frame.origin.y = offset;
[spacer_ setFrame:frame];
offset += NSHeight(frame);
offset += kVerticalSpacing;
if (![subtitleField_ isHidden]) {
frame = [subtitleField_ frame];
frame.origin.y = offset;
[subtitleField_ setFrame:frame];
offset += NSHeight(frame);
}
frame = [titleField_ frame];
frame.origin.y = offset;
[titleField_ setFrame:frame];
offset += NSHeight(frame);
// No kContentAreaBorder here, since that is currently handled elsewhere.
frame = [self frame];
frame.size.height = offset;
[self setFrame:frame];
}
@end
// NSView for a single row in the intents view.
@interface IntentRowView : NSView {
@private
scoped_nsobject<NSProgressIndicator> throbber_;
scoped_nsobject<NSButton> cwsButton_;
scoped_nsobject<RatingsView> ratingsWidget_;
scoped_nsobject<NSButton> installButton_;
scoped_nsobject<DimmableImageView> iconView_;
scoped_nsobject<NSTextField> label_;
}
- (id)initWithExtension:
(const WebIntentPickerModel::SuggestedExtension*)extension
withIndex:(size_t)index
forController:(WebIntentPickerSheetController*)controller;
- (void)startThrobber;
- (void)setEnabled:(BOOL)enabled;
- (void)stopThrobber;
- (NSInteger)tag;
@end
@implementation IntentRowView
const CGFloat kMaxHeight = 34.0;
const CGFloat kTitleX = 20.0;
const CGFloat kMinAddButtonHeight = 28.0;
const CGFloat kAddButtonX = 245;
const CGFloat kAddButtonWidth = 128.0;
+ (RatingsView*)createStarWidgetWithRating:(CGFloat)rating {
const int kStarSpacing = 1; // Spacing between stars in pixels.
const CGFloat kStarSize = 16.0; // Size of the star in pixels.
NSMutableArray* subviews = [NSMutableArray array];
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
NSRect imageFrame = NSMakeRect(0, 0, kStarSize, kStarSize);
for (int i = 0; i < 5; ++i) {
NSImage* nsImage = rb.GetNativeImageNamed(
WebIntentPicker::GetNthStarImageIdFromCWSRating(rating, i)).ToNSImage();
scoped_nsobject<DimmableImageView> imageView(
[[DimmableImageView alloc] initWithFrame:imageFrame]);
[imageView setImage:nsImage];
[imageView setImageFrameStyle:NSImageFrameNone];
[imageView setFrame:imageFrame];
[imageView setEnabled:YES];
[subviews addObject:imageView];
imageFrame.origin.x += kStarSize + kStarSpacing;
}
NSRect frame = NSMakeRect(0, 0, (kStarSize + kStarSpacing) * 5, kStarSize);
RatingsView* widget = [[RatingsView alloc] initWithFrame:frame];
[widget setSubviews:subviews];
return widget;
}
- (void)setIcon:(NSImage*)icon {
NSRect imageFrame = NSZeroRect;
iconView_.reset(
[[DimmableImageView alloc] initWithFrame:imageFrame]);
[iconView_ setImage:icon];
[iconView_ setImageFrameStyle:NSImageFrameNone];
[iconView_ setEnabled:YES];
imageFrame.size = [icon size];
imageFrame.size.height = std::min(NSHeight(imageFrame), kMaxHeight);
imageFrame.origin.y += (kMaxHeight - NSHeight(imageFrame)) / 2.0;
[iconView_ setFrame:imageFrame];
}
- (void)setActionButton:(NSString*)title
withSelector:(SEL)selector
forController:(WebIntentPickerSheetController*)controller {
NSRect frame = NSMakeRect(kAddButtonX, 0, kAddButtonWidth, 0);
installButton_.reset([[NSButton alloc] initWithFrame:frame]);
[installButton_ setAlignment:NSCenterTextAlignment];
[installButton_ setButtonType:NSMomentaryPushInButton];
[installButton_ setBezelStyle:NSRegularSquareBezelStyle];
[installButton_ setTitle:title];
frame.size.height = std::min(kMinAddButtonHeight, kMaxHeight);
frame.origin.y += (kMaxHeight - NSHeight(frame)) / 2.0;
[installButton_ setFrame:frame];
[installButton_ setTarget:controller];
[installButton_ setAction:selector];
}
- (id)init {
// Build the main view.
NSRect contentFrame = NSMakeRect(
0, 0, WebIntentPicker::kWindowMinWidth, kMaxHeight);
if (self = [super initWithFrame:contentFrame]) {
NSMutableArray* subviews = [NSMutableArray array];
if (iconView_) [subviews addObject:iconView_];
if (label_) [subviews addObject:label_];
if (cwsButton_) [subviews addObject:cwsButton_];
if (ratingsWidget_) [subviews addObject:ratingsWidget_];
if (installButton_) [subviews addObject:installButton_];
if (throbber_) [subviews addObject:throbber_];
[self setSubviews:subviews];
}
return self;
}
- (id)initWithExtension:
(const WebIntentPickerModel::SuggestedExtension*)extension
withIndex:(size_t)index
forController:(WebIntentPickerSheetController*)controller {
// Add the extension icon.
[self setIcon:extension->icon.ToNSImage()];
// Add the extension title.
NSRect frame = NSMakeRect(kTitleX, 0, 0, 0);
const string16 elidedTitle = ui::ElideText(
extension->title, gfx::Font(), WebIntentPicker::kTitleLinkMaxWidth,
ui::ELIDE_AT_END);
NSString* string = base::SysUTF16ToNSString(elidedTitle);
cwsButton_.reset(CreateHyperlinkButton(string, frame));
[cwsButton_ setAlignment:NSCenterTextAlignment];
[cwsButton_ setTarget:controller];
[cwsButton_ setAction:@selector(openExtensionLink:)];
[cwsButton_ setTag:index];
[cwsButton_ sizeToFit];
frame = [cwsButton_ frame];
frame.size.height = std::min([[cwsButton_ cell] cellSize].height,
kMaxHeight);
frame.origin.y = (kMaxHeight - NSHeight(frame)) / 2.0;
[cwsButton_ setFrame:frame];
// Add the star rating
CGFloat offsetX = frame.origin.x + NSWidth(frame) +
WebIntentPicker::kContentAreaBorder;
ratingsWidget_.reset(
[IntentRowView
createStarWidgetWithRating:extension->average_rating]);
frame = [ratingsWidget_ frame];
frame.origin.y += (kMaxHeight - NSHeight(frame)) / 2.0;
frame.origin.x = offsetX;
[ratingsWidget_ setFrame:frame];
// Add an "add to chromium" button.
string = l10n_util::GetNSStringWithFixup(
IDS_INTENT_PICKER_INSTALL_EXTENSION);
[self setActionButton:string
withSelector:@selector(installExtension:)
forController:controller];
[installButton_ setTag:index];
// Keep a throbber handy.
frame = [installButton_ frame];
frame.origin.x += (NSWidth(frame) - 16) / 2;
frame.origin.y += (NSHeight(frame) - 16) /2;
frame.size = NSMakeSize(16, 16);
throbber_.reset([[NSProgressIndicator alloc] initWithFrame:frame]);
[throbber_ setHidden:YES];
[throbber_ setStyle:NSProgressIndicatorSpinningStyle];
return [self init];
}
- (id)initWithService:
(const WebIntentPickerModel::InstalledService*)service
withIndex:(size_t)index
forController:(WebIntentPickerSheetController*)controller {
// Add the extension icon.
[self setIcon:service->favicon.ToNSImage()];
// Add the extension title.
NSRect frame = NSMakeRect(
kTitleX, 0, WebIntentPicker::kTitleLinkMaxWidth, 10);
const string16 elidedTitle = ui::ElideText(
service->title, gfx::Font(),
WebIntentPicker::kTitleLinkMaxWidth, ui::ELIDE_AT_END);
NSString* string = base::SysUTF16ToNSString(elidedTitle);
label_.reset([[NSTextField alloc] initWithFrame:frame]);
ConfigureTextFieldAsLabel(label_);
[label_ setStringValue:string];
frame.size.height +=
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:
label_];
frame.origin.y = (kMaxHeight - NSHeight(frame)) / 2.0;
[label_ setFrame:frame];
string = l10n_util::GetNSStringWithFixup(
IDS_INTENT_PICKER_SELECT_INTENT);
[self setActionButton:string
withSelector:@selector(invokeService:)
forController:controller];
[installButton_ setTag:index];
return [self init];
}
- (NSInteger)tag {
return [installButton_ tag];
}
- (void)startThrobber {
[installButton_ setHidden:YES];
[throbber_ setHidden:NO];
[throbber_ startAnimation:self];
[iconView_ setEnabled:YES];
[ratingsWidget_ setEnabled:NO];
}
- (void)setEnabled:(BOOL) enabled {
[installButton_ setEnabled:enabled];
[cwsButton_ setEnabled:enabled];
[iconView_ setEnabled:enabled];
[ratingsWidget_ setEnabled:enabled];
}
- (void)stopThrobber {
if (throbber_.get()) {
[throbber_ setHidden:YES];
[throbber_ stopAnimation:self];
}
[installButton_ setHidden:NO];
}
- (void)adjustButtonSize:(CGFloat)newWidth {
CGFloat increase = std::max(kAddButtonWidth, newWidth) - kAddButtonWidth;
NSRect frame = [self frame];
frame.size.width += increase;
[self setFrame:frame];
frame = [installButton_ frame];
frame.size.width += increase;
[installButton_ setFrame:frame];
}
@end
@interface IntentView : NSView {
@private
// Used to forward button clicks. Weak reference.
WebIntentPickerSheetController* controller_;
}
- (id)initWithModel:(WebIntentPickerModel*)model
forController:(WebIntentPickerSheetController*)controller;
- (void)startThrobberForRow:(NSInteger)index;
- (void)stopThrobber;
@end
@implementation IntentView
- (id)initWithModel:(WebIntentPickerModel*)model
forController:(WebIntentPickerSheetController*)controller {
if (self = [super initWithFrame:NSZeroRect]) {
const CGFloat kYMargin = 16.0;
int availableSpots = kMaxIntentRows;
CGFloat offset = kYMargin;
NSMutableArray* subviews = [NSMutableArray array];
NSMutableArray* rows = [NSMutableArray array];
for (size_t i = 0; i < model->GetInstalledServiceCount() && availableSpots;
++i, --availableSpots) {
const WebIntentPickerModel::InstalledService& svc =
model->GetInstalledServiceAt(i);
scoped_nsobject<NSView> suggestView(
[[IntentRowView alloc] initWithService:&svc
withIndex:i
forController:controller]);
[rows addObject:suggestView];
}
// Special case for the empty view.
size_t count = model->GetSuggestedExtensionCount();
if (count == 0 && availableSpots == kMaxIntentRows)
return nil;
for (size_t i = count; i > 0 && availableSpots; --i, --availableSpots) {
const WebIntentPickerModel::SuggestedExtension& ext =
model->GetSuggestedExtensionAt(i - 1);
scoped_nsobject<NSView> suggestView(
[[IntentRowView alloc] initWithExtension:&ext
withIndex:i-1
forController:controller]);
[rows addObject:suggestView];
}
// Determine optimal width for buttons given localized texts.
scoped_nsobject<NSButton> sizeHelper(
[[NSButton alloc] initWithFrame:NSZeroRect]);
[sizeHelper setAlignment:NSCenterTextAlignment];
[sizeHelper setButtonType:NSMomentaryPushInButton];
[sizeHelper setBezelStyle:NSRegularSquareBezelStyle];
[sizeHelper setTitle:
l10n_util::GetNSStringWithFixup(IDS_INTENT_PICKER_INSTALL_EXTENSION)];
[sizeHelper sizeToFit];
CGFloat buttonWidth = NSWidth([sizeHelper frame]);
[sizeHelper setTitle:
l10n_util::GetNSStringWithFixup(IDS_INTENT_PICKER_SELECT_INTENT)];
[sizeHelper sizeToFit];
buttonWidth = std::max(buttonWidth, NSWidth([sizeHelper frame]));
for (IntentRowView* row in [rows reverseObjectEnumerator]) {
[row adjustButtonSize:buttonWidth];
offset += [self addStackedView:row
toSubviews:subviews
atOffset:offset];
}
[self setSubviews:subviews];
NSRect contentFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0,
WebIntentPicker::kWindowMinWidth, offset);
[self setFrame:contentFrame];
controller_ = controller;
}
return self;
}
- (void)startThrobberForRow:(NSInteger)index {
for (IntentRowView* row in [self subviews]) {
if ([row isMemberOfClass:[IntentRowView class]]) {
[row setEnabled:NO];
if ([row tag] == index) {
[row startThrobber];
}
}
}
}
- (void)stopThrobber {
for (IntentRowView* row in [self subviews]) {
if ([row isMemberOfClass:[IntentRowView class]]) {
[row stopThrobber];
[row setEnabled:YES];
}
}
}
- (IBAction)installExtension:(id)sender {
[controller_ installExtension:sender];
}
- (CGFloat)addStackedView:(NSView*)view
toSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset {
if (view == nil)
return 0.0;
NSPoint frameOrigin = [view frame].origin;
frameOrigin.y = offset;
[view setFrameOrigin:frameOrigin];
[subviews addObject:view];
return NSHeight([view frame]);
}
@end
@implementation WebIntentPickerSheetController
- (id)initWithPicker:(WebIntentPickerCocoa*)picker {
// Use an arbitrary height because it will reflect the size of the content.
NSRect contentRect = NSMakeRect(
0, 0, WebIntentPicker::kWindowMinWidth, kVerticalSpacing);
// |window| is retained by the ConstrainedWindowMacDelegateCustomSheet when
// the sheet is initialized.
scoped_nsobject<NSWindow> window(
[[NSWindow alloc] initWithContentRect:contentRect
styleMask:NSTitledWindowMask
backing:NSBackingStoreBuffered
defer:YES]);
if ((self = [super initWithWindow:window.get()])) {
picker_ = picker;
if (picker)
model_ = picker->model();
inlineDispositionTitleField_.reset([[NSTextField alloc] init]);
ConfigureTextFieldAsLabel(inlineDispositionTitleField_);
[inlineDispositionTitleField_ setFont:
[NSFont boldSystemFontOfSize:[NSFont systemFontSize]]];
flipView_.reset([[WebIntentsContentView alloc] init]);
[flipView_ setAutoresizingMask:NSViewMinYMargin];
[[[self window] contentView] setSubviews:@[flipView_]];
[self performLayoutWithModel:model_];
}
return self;
}
// Handle default OSX dialog cancel mechanisms. (Cmd-.)
- (void)cancelOperation:(id)sender {
if (picker_)
picker_->OnCancelled();
[self closeSheet];
}
- (void)chooseAnotherService:(id)sender {
if (picker_)
picker_->OnChooseAnotherService();
}
- (void)sheetDidEnd:(NSWindow*)sheet
returnCode:(int)returnCode
contextInfo:(void*)contextInfo {
if (picker_)
picker_->OnSheetDidEnd(sheet);
}
- (void)setInlineDispositionTabContents:(TabContents*)tabContents {
contents_ = tabContents;
}
- (void)setInlineDispositionFrameSize:(NSSize)inlineContentSize {
DCHECK(contents_);
NSView* webContentView = contents_->web_contents()->GetNativeView();
// Make sure inline content size is never shrunk.
inlineContentSize = NSMakeSize(
std::max(NSWidth([webContentView frame]), inlineContentSize.width),
std::max(NSHeight([webContentView frame]), inlineContentSize.height));
// Compute container size to fit all elements, including padding.
NSSize containerSize = inlineContentSize;
containerSize.height +=
[webContentView frame].origin.y + WebIntentPicker::kContentAreaBorder;
containerSize.width += 2 * WebIntentPicker::kContentAreaBorder;
// Ensure minimum container width.
containerSize.width =
std::max(CGFloat(WebIntentPicker::kWindowMinWidth), containerSize.width);
// Resize web contents.
[webContentView setFrameSize:inlineContentSize];
[self setContainerSize:containerSize];
}
- (void)setContainerSize:(NSSize)containerSize {
// Resize container views
NSRect frame = NSMakeRect(0, 0, 0, 0);
frame.size = containerSize;
[[[self window] contentView] setFrame:frame];
[flipView_ setFrame:frame];
// Resize and reposition dialog window.
frame.size = [[[self window] contentView] convertSize:containerSize
toView:nil];
frame = [[self window] frameRectForContentRect:frame];
// Readjust window position to keep top in place and center horizontally.
NSRect windowFrame = [[self window] frame];
windowFrame.origin.x -= (NSWidth(frame) - NSWidth(windowFrame)) / 2.0;
windowFrame.origin.y -= (NSHeight(frame) - NSHeight(windowFrame));
windowFrame.size = frame.size;
[[self window] setFrame:windowFrame display:YES animate:NO];
}
// Pop up a new tab with the Chrome Web Store.
- (IBAction)showChromeWebStore:(id)sender {
DCHECK(picker_);
picker_->OnSuggestionsLinkClicked(
event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]));
}
// A picker button has been pressed - invoke corresponding service.
- (IBAction)invokeService:(id)sender {
DCHECK(picker_);
picker_->OnServiceChosen([sender tag]);
}
- (IBAction)openExtensionLink:(id)sender {
DCHECK(model_);
DCHECK(picker_);
const WebIntentPickerModel::SuggestedExtension& extension =
model_->GetSuggestedExtensionAt([sender tag]);
picker_->OnExtensionLinkClicked(extension.id,
event_utils::WindowOpenDispositionFromNSEvent([NSApp currentEvent]));
}
- (IBAction)installExtension:(id)sender {
DCHECK(model_);
DCHECK(picker_);
const WebIntentPickerModel::SuggestedExtension& extension =
model_->GetSuggestedExtensionAt([sender tag]);
if (picker_) {
[intentView_ startThrobberForRow:[sender tag]];
[closeButton_ setEnabled:NO];
picker_->OnExtensionInstallRequested(extension.id);
}
}
- (CGFloat)addStackedView:(NSView*)view
toSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset {
if (view == nil)
return 0.0;
NSPoint frameOrigin = [view frame].origin;
frameOrigin.y = offset;
[view setFrameOrigin:frameOrigin];
[subviews addObject:view];
return NSHeight([view frame]);
}
// Adds a link to the Chrome Web Store, to obtain further intent handlers.
// Returns the y position delta for the next offset.
- (CGFloat)addCwsButtonToSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset {
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
NSImage* iconImage = rb.GetNativeImageNamed(IDR_WEBSTORE_ICON_16).ToNSImage();
NSRect imageFrame;
imageFrame.origin = NSMakePoint(WebIntentPicker::kContentAreaBorder, offset);
imageFrame.size = [iconImage size];
scoped_nsobject<NSImageView> iconView(
[[NSImageView alloc] initWithFrame:imageFrame]);
[iconView setImage:iconImage];
[iconView setImageFrameStyle:NSImageFrameNone];
const CGFloat kCWSIconPadding = 4.0; // Same spacing as for service options.
NSRect frame = NSMakeRect(WebIntentPicker::kContentAreaBorder +
NSWidth(imageFrame) + kCWSIconPadding,
offset, 100, 10);
NSString* string = l10n_util::GetNSStringWithFixup(
IDS_FIND_MORE_INTENT_HANDLER_MESSAGE);
scoped_nsobject<NSButton> button(CreateHyperlinkButton(string, frame));
[button setTarget:self];
[button setAction:@selector(showChromeWebStore:)];
[subviews addObjectsFromArray:@[iconView, button]];
// Call size-to-fit to fixup for the localized string.
[GTMUILocalizerAndLayoutTweaker sizeToFitView:button];
return NSHeight([button frame]);
}
- (void)addCloseButtonToSubviews:(NSMutableArray*)subviews {
const CGFloat kButtonPadding = 4.0; // whitespace inside button frame.
if (!closeButton_.get()) {
NSRect buttonFrame = NSMakeRect(
WebIntentPicker::kContentAreaBorder + kTextWidth + kButtonPadding,
WebIntentPicker::kContentAreaBorder - kButtonPadding,
kCloseButtonSize, kCloseButtonSize);
closeButton_.reset(
[[HoverCloseButton alloc] initWithFrame:buttonFrame]);
// Anchor close button to upper right.
// (NSViewMaxYMargin since parent view is flipped.)
[closeButton_ setAutoresizingMask:NSViewMaxYMargin|NSViewMinXMargin];
[closeButton_ setTarget:self];
[closeButton_ setAction:@selector(cancelOperation:)];
[[closeButton_ cell] setKeyEquivalent:@"\e"];
}
[subviews addObject:closeButton_];
}
// Adds a header (icon and explanatory text) to picker bubble.
// Returns the y position delta for the next offset.
- (CGFloat)addHeaderToSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset {
// Create a new text field if we don't have one yet.
// TODO(groby): This should not be necessary since the controller sends this
// string.
if (!actionTextField_.get()) {
NSString* nsString =
l10n_util::GetNSStringWithFixup(IDS_CHOOSE_INTENT_HANDLER_MESSAGE);
[self setActionString:nsString];
}
scoped_nsobject<HeaderView> header([[HeaderView alloc] init]);
[header setTitle:[actionTextField_ stringValue]];
string16 labelText;
if (model_ && model_->GetInstalledServiceCount() == 0)
labelText = model_->GetSuggestionsLinkText();
[header setSubtitle:base::SysUTF16ToNSString(labelText)];
[header performLayout];
NSRect frame = [header frame];
frame.origin.y = offset;
[header setFrame:frame];
[subviews addObject:header];
return NSHeight(frame);
}
- (CGFloat)addInlineHtmlToSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset {
if (!contents_)
return 0;
// Determine a good size for the inline disposition window.
gfx::Size size = picker_->GetMinInlineDispositionSize();
NSView* webContentView = contents_->web_contents()->GetNativeView();
NSRect contentFrame = NSMakeRect(
WebIntentPicker::kContentAreaBorder,
offset,
std::max(NSWidth([webContentView frame]),CGFloat(size.width())),
std::max(NSHeight([webContentView frame]),CGFloat(size.height())));
[webContentView setFrame:contentFrame];
[subviews addObject:webContentView];
return NSHeight(contentFrame);
}
- (CGFloat)addAnotherServiceLinkToSubviews:(NSMutableArray*)subviews
atOffset:(CGFloat)offset {
DCHECK(model_);
DCHECK(model_->IsInlineDisposition());
GURL url = model_->inline_disposition_url();
const WebIntentPickerModel::InstalledService* service =
model_->GetInstalledServiceWithURL(url);
DCHECK(service);
CGFloat originalOffset = offset;
// Icon for current service.
scoped_nsobject<NSImageView> icon;
NSRect imageFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, offset,
0, 0);
icon.reset([[NSImageView alloc] initWithFrame:imageFrame]);
[icon setImage:service->favicon.ToNSImage()];
[icon setImageFrameStyle:NSImageFrameNone];
[icon setEnabled:YES];
imageFrame.size = [service->favicon.ToNSImage() size];
[icon setFrame:imageFrame];
[subviews addObject:icon];
// Resize control to fit text
NSRect textFrame =
NSMakeRect(NSMaxX(imageFrame) + 4,
offset,
WebIntentPicker::kTitleLinkMaxWidth, 1);
[inlineDispositionTitleField_ setFrame:textFrame];
[subviews addObject:inlineDispositionTitleField_];
[GTMUILocalizerAndLayoutTweaker sizeToFitView:inlineDispositionTitleField_];
textFrame = [inlineDispositionTitleField_ frame];
// Add link for "choose another service" if other suggestions are available
// or if more than one (the current) service is installed.
if (model_->show_use_another_service() &&
(model_->GetInstalledServiceCount() > 1 ||
model_->GetSuggestedExtensionCount())) {
NSRect frame = NSMakeRect(
NSMaxX(textFrame) + WebIntentPicker::kContentAreaBorder, offset,
1, 1);
NSString* string = l10n_util::GetNSStringWithFixup(
IDS_INTENT_PICKER_USE_ALTERNATE_SERVICE);
scoped_nsobject<NSButton> button(CreateHyperlinkButton(string, frame));
[[button cell] setControlSize:NSRegularControlSize];
[[button cell] setFont:
[NSFont controlContentFontOfSize:[NSFont systemFontSize]]];
[button setTarget:self];
[button setAction:@selector(chooseAnotherService:)];
[subviews addObject:button];
// Call size-to-fit to fixup for the localized string.
[GTMUILocalizerAndLayoutTweaker sizeToFitView:button];
// Right-align the "use another service" button.
frame = [button frame];
frame.origin.x = WebIntentPicker::kWindowMinWidth - NSWidth(frame) -
2 * WebIntentPicker::kContentAreaBorder - kCloseButtonSize;
[button setFrame:frame];
[button setAutoresizingMask:NSViewMinXMargin];
// And finally, make sure the link and the title are horizontally centered.
frame = [button frame];
CGFloat height = std::max(NSHeight(textFrame), NSHeight(frame));
frame.origin.y += (height - NSHeight(frame)) / 2.0;
frame.size.height = height;
textFrame.origin.y += (height - NSHeight(textFrame)) / 2.0;
textFrame.size.height = height;
[button setFrame:frame];
[inlineDispositionTitleField_ setFrame:textFrame];
}
offset += NSHeight(textFrame) + kVerticalSpacing;
scoped_nsobject<NSBox> spacer;
NSRect frame = NSMakeRect(0, offset, WebIntentPicker::kWindowMinWidth, 1.0);
spacer.reset([[NSBox alloc] initWithFrame:frame]);
[spacer setBoxType:NSBoxSeparator];
[spacer setAlphaValue:0.2];
[spacer setAutoresizingMask:NSViewWidthSizable];
[subviews addObject: spacer];
return offset + kVerticalSpacing - originalOffset;
}
- (NSView*)createEmptyView {
NSRect titleFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder,
WebIntentPicker::kContentAreaBorder,
kTextWidth, 1);
scoped_nsobject<NSTextField> title(
[[NSTextField alloc] initWithFrame:titleFrame]);
ConfigureTextFieldAsLabel(title);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
gfx::Font titleFont = rb.GetFont(ConstrainedWindowConstants::kTitleFontStyle);
titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD);
[title setFont:titleFont.GetNativeFont()];
[title setStringValue:
l10n_util::GetNSStringWithFixup(IDS_INTENT_PICKER_NO_SERVICES_TITLE)];
titleFrame.size.height +=
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:title];
NSRect bodyFrame = titleFrame;
bodyFrame.origin.y +=
NSHeight(titleFrame) + WebIntentPicker::kContentAreaBorder;
scoped_nsobject<NSTextField> body(
[[NSTextField alloc] initWithFrame:bodyFrame]);
ConfigureTextFieldAsLabel(body);
[body setStringValue:
l10n_util::GetNSStringWithFixup(IDS_INTENT_PICKER_NO_SERVICES)];
bodyFrame.size.height +=
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:body];
NSRect viewFrame = NSMakeRect(
0,
WebIntentPicker::kContentAreaBorder,
std::max(NSWidth(bodyFrame), NSWidth(titleFrame)) +
2 * WebIntentPicker::kContentAreaBorder,
NSHeight(titleFrame) + NSHeight(bodyFrame) + kVerticalSpacing);
titleFrame.origin.y = NSHeight(viewFrame) - NSHeight(titleFrame);
bodyFrame.origin.y = 0;
[title setFrame:titleFrame];
[body setFrame:bodyFrame];
NSView* view = [[NSView alloc] initWithFrame:viewFrame];
[view setSubviews:@[title, body]];
return view;
}
- (void)performLayoutWithModel:(WebIntentPickerModel*)model {
model_ = model;
// |offset| is the Y position that should be drawn at next.
CGFloat offset = WebIntentPicker::kContentAreaBorder;
// Keep the new subviews in an array that gets replaced at the end.
NSMutableArray* subviews = [NSMutableArray array];
// Indicator that we have neither suggested nor installed services,
// and we're not in the wait stage any more either.
BOOL isEmpty = model_ &&
!model_->IsWaitingForSuggestions() &&
!model_->GetInstalledServiceCount() &&
!model_->GetSuggestedExtensionCount();
if (model_ && model_->IsWaitingForSuggestions()) {
if (!waitingView_.get())
waitingView_.reset([[WaitingView alloc] init]);
[subviews addObject:waitingView_];
offset += NSHeight([waitingView_ frame]);
} else if (isEmpty) {
scoped_nsobject<NSView> emptyView([self createEmptyView]);
[subviews addObject:emptyView];
offset += NSHeight([emptyView frame]);
} else if (contents_) {
offset += [self addAnotherServiceLinkToSubviews:subviews
atOffset:offset];
offset += [self addInlineHtmlToSubviews:subviews atOffset:offset];
} else {
offset += [self addHeaderToSubviews:subviews atOffset:offset];
if (model) {
intentView_.reset(
[[IntentView alloc] initWithModel:model forController:self]);
offset += [self addStackedView:intentView_
toSubviews:subviews
atOffset:offset];
}
offset += [self addCwsButtonToSubviews:subviews atOffset:offset];
}
// Add the bottom padding.
offset += WebIntentPicker::kContentAreaBorder;
// Resize to fit.
[self setContainerSize:NSMakeSize(WebIntentPicker::kWindowMinWidth, offset)];
[self addCloseButtonToSubviews:subviews];
// Replace the window's content.
[flipView_ setSubviews:subviews];
}
- (void)setActionString:(NSString*)actionString {
NSRect textFrame;
if (!actionTextField_.get()) {
textFrame = NSMakeRect(WebIntentPicker::kContentAreaBorder, 0,
kTextWidth, 1);
actionTextField_.reset([[NSTextField alloc] initWithFrame:textFrame]);
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
ConfigureTextFieldAsLabel(actionTextField_);
gfx::Font titleFont = rb.GetFont(
ConstrainedWindowConstants::kTitleFontStyle);
titleFont = titleFont.DeriveFont(0, gfx::Font::BOLD);
[actionTextField_ setFont:titleFont.GetNativeFont()];
} else {
textFrame = [actionTextField_ frame];
}
[actionTextField_ setStringValue:actionString];
textFrame.size.height +=
[GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:
actionTextField_];
[actionTextField_ setFrame:textFrame];
}
- (void)setInlineDispositionTitle:(NSString*)title {
NSFont* nsfont = [inlineDispositionTitleField_ font];
gfx::Font font(
base::SysNSStringToUTF8([nsfont fontName]), [nsfont pointSize]);
NSString* elidedTitle = base::SysUTF16ToNSString(ui::ElideText(
base::SysNSStringToUTF16(title),
font, WebIntentPicker::kTitleLinkMaxWidth, ui::ELIDE_AT_END));
[inlineDispositionTitleField_ setStringValue:elidedTitle];
}
- (void)stopThrobber {
[closeButton_ setEnabled:YES];
[intentView_ stopThrobber];
}
- (void)closeSheet {
[NSApp endSheet:[self window]];
}
@end // WebIntentPickerSheetController
|