1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include "chrome/browser/ui/cocoa/translate/translate_message_infobar_controller.h" 6 7 #include "base/sys_string_conversions.h" 8 9 using TranslateInfoBarUtilities::MoveControl; 10 11 @implementation TranslateMessageInfobarController 12 13 - (void)layout { 14 [self removeOkCancelButtons]; 15 MoveControl(label1_, translateMessageButton_, spaceBetweenControls_ * 2, true); 16 TranslateInfoBarDelegate* delegate = [self delegate]; 17 if ([self delegate]->ShouldShowMessageInfoBarButton()) { 18 string16 buttonText = delegate->GetMessageInfoBarButtonText(); 19 [translateMessageButton_ setTitle:base::SysUTF16ToNSString(buttonText)]; 20 [translateMessageButton_ sizeToFit]; 21 } 22 } 23 24 - (void)adjustOptionsButtonSizeAndVisibilityForView:(NSView*)lastView { 25 // Do nothing, but stop the options button from showing up. 26 } 27 28 - (NSArray*)visibleControls { 29 NSMutableArray* visibleControls = 30 [NSMutableArray arrayWithObjects:label1_.get(), nil]; 31 if ([self delegate]->ShouldShowMessageInfoBarButton()) 32 [visibleControls addObject:translateMessageButton_]; 33 return visibleControls; 34 } 35 36 - (void)loadLabelText { 37 TranslateInfoBarDelegate* delegate = [self delegate]; 38 string16 messageText = delegate->GetMessageInfoBarText(); 39 NSString* string1 = base::SysUTF16ToNSString(messageText); 40 [label1_ setStringValue:string1]; 41 } 42 43 - (bool)verifyLayout { 44 if (![optionsPopUp_ isHidden]) 45 return false; 46 return [super verifyLayout]; 47 } 48 49 - (BOOL)shouldShowOptionsPopUp { 50 return NO; 51 } 52 53 @end 54