Index: chrome/browser/ui/cocoa/web_intent_sheet_controller.mm |
diff --git a/chrome/browser/ui/cocoa/web_intent_sheet_controller.mm b/chrome/browser/ui/cocoa/web_intent_sheet_controller.mm |
index e4e25f3a97cc8cd1a82898105460f95c737c56a1..1293365f149f9caae05edddd0d1e4db793e58d67 100644 |
--- a/chrome/browser/ui/cocoa/web_intent_sheet_controller.mm |
+++ b/chrome/browser/ui/cocoa/web_intent_sheet_controller.mm |
@@ -72,6 +72,14 @@ const CGFloat kTextWidth = kWindowWidth - |
return button; |
} |
+ |
+// Sets properties on the given |field| to act as title or description labels. |
++ (void)configureTextFieldAsLabel:(NSTextField*)field { |
Nico
2012/05/16 22:02:45
nit: static methods can usually just be static top
groby-ooo-7-16
2012/05/16 23:27:02
Done.
|
+ [field setEditable:NO]; |
+ [field setSelectable:YES]; |
+ [field setDrawsBackground:NO]; |
+ [field setBezeled:NO]; |
+} |
@end |
// This simple NSView subclass is used as the single subview of the page info |
@@ -326,6 +334,7 @@ const CGFloat kTextWidth = kWindowWidth - |
@private |
// Used to forward button clicks. Weak reference. |
WebIntentPickerSheetController* controller_; |
+ scoped_nsobject<NSTextField> suggestionLabel_; |
} |
- (id)initWithModel:(WebIntentPickerModel*)model |
@@ -344,6 +353,11 @@ const CGFloat kTextWidth = kWindowWidth - |
NSMutableArray* subviews = [NSMutableArray array]; |
+ NSRect textFrame = NSMakeRect(0, 0, |
+ kTextWidth, 1); |
+ suggestionLabel_.reset([[NSTextField alloc] initWithFrame:textFrame]); |
+ [WebIntentPickerSheetController configureTextFieldAsLabel:suggestionLabel_]; |
+ |
CGFloat offset = kYMargin; |
for (size_t i = count; i > 0; --i) { |
const WebIntentPickerModel::SuggestedExtension& ext = |
@@ -356,6 +370,12 @@ const CGFloat kTextWidth = kWindowWidth - |
toSubviews:subviews |
atOffset:offset]; |
} |
+ |
+ [self updateSuggestionLabelForModel:model]; |
+ offset += [self addStackedView:suggestionLabel_ |
+ toSubviews:subviews |
+ atOffset:offset]; |
+ |
offset += kYMargin; |
NSRect contentFrame = NSMakeRect(kFramePadding, 0, kWindowWidth, offset); |
@@ -366,6 +386,33 @@ const CGFloat kTextWidth = kWindowWidth - |
return self; |
} |
+- (void)updateSuggestionLabelForModel:(WebIntentPickerModel*)model { |
+ DCHECK(suggestionLabel_.get()); |
+ string16 labelText; |
+ |
+ if (model->GetInstalledServiceCount()!=0) { |
Nico
2012/05/16 22:02:45
spaces around !=
groby-ooo-7-16
2012/05/16 23:27:02
Done.
|
+ if (model->GetInstalledServiceCount() == 0) |
Nico
2012/05/16 22:02:45
wait what? isn't that the negation of the previous
groby-ooo-7-16
2012/05/16 23:27:02
No, it won't. The first condition was wrong. Fixed
|
+ labelText = l10n_util::GetStringUTF16( |
+ IDS_INTENT_PICKER_GET_MORE_SERVICES_NONE_INSTALLED); |
+ else |
+ labelText = l10n_util::GetStringUTF16( |
+ IDS_INTENT_PICKER_GET_MORE_SERVICES); |
+ } |
+ |
+ if (labelText.empty()) { |
+ [suggestionLabel_ setHidden:TRUE]; |
+ } else { |
+ NSRect textFrame = [suggestionLabel_ frame]; |
+ |
+ [suggestionLabel_ setHidden:FALSE]; |
+ [suggestionLabel_ setStringValue:base::SysUTF16ToNSString(labelText)]; |
+ textFrame.size.height += |
+ [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField: |
+ suggestionLabel_]; |
+ [suggestionLabel_ setFrame: textFrame]; |
+ } |
+} |
+ |
- (void)startThrobberForRow:(NSInteger)index { |
for (SingleSuggestionView* row in [self subviews]) { |
[row setEnabled:NO]; |
@@ -491,14 +538,6 @@ const CGFloat kTextWidth = kWindowWidth - |
} |
} |
-// 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]; |
-} |
- |
- (CGFloat)addStackedView:(NSView*)view |
toSubviews:(NSMutableArray*)subviews |
atOffset:(CGFloat)offset { |
@@ -693,7 +732,8 @@ const CGFloat kTextWidth = kWindowWidth - |
kTextWidth, 1); |
actionTextField_.reset([[NSTextField alloc] initWithFrame:textFrame]); |
- [self configureTextFieldAsLabel:actionTextField_.get()]; |
+ [WebIntentPickerSheetController configureTextFieldAsLabel: |
+ actionTextField_]; |
[actionTextField_ setFont:[NSFont systemFontOfSize:kHeaderFontSize]]; |
} else { |
textFrame = [actionTextField_ frame]; |