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 #include "chrome/browser/ui/cocoa/infobars/translate_message_infobar_controller.
h" | 5 #include "chrome/browser/ui/cocoa/infobars/translate_message_infobar_controller.
h" |
6 | 6 |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" | 8 #import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h" |
9 | 9 |
10 using InfoBarUtilities::MoveControl; | 10 using InfoBarUtilities::MoveControl; |
11 | 11 |
12 @implementation TranslateMessageInfobarController | 12 @implementation TranslateMessageInfobarController |
13 | 13 |
14 - (void)layout { | 14 - (void)layout { |
15 [self removeOkCancelButtons]; | 15 [self removeOkCancelButtons]; |
16 MoveControl( | 16 MoveControl( |
17 label1_, translateMessageButton_, spaceBetweenControls_ * 2, true); | 17 label1_, translateMessageButton_, spaceBetweenControls_ * 2, true); |
18 TranslateInfoBarDelegate* delegate = [self delegate]; | 18 translate::TranslateInfoBarDelegate* delegate = [self delegate]; |
19 if ([self delegate]->ShouldShowMessageInfoBarButton()) { | 19 if ([self delegate]->ShouldShowMessageInfoBarButton()) { |
20 base::string16 buttonText = delegate->GetMessageInfoBarButtonText(); | 20 base::string16 buttonText = delegate->GetMessageInfoBarButtonText(); |
21 [translateMessageButton_ setTitle:base::SysUTF16ToNSString(buttonText)]; | 21 [translateMessageButton_ setTitle:base::SysUTF16ToNSString(buttonText)]; |
22 [translateMessageButton_ sizeToFit]; | 22 [translateMessageButton_ sizeToFit]; |
23 } | 23 } |
24 } | 24 } |
25 | 25 |
26 - (void)adjustOptionsButtonSizeAndVisibilityForView:(NSView*)lastView { | 26 - (void)adjustOptionsButtonSizeAndVisibilityForView:(NSView*)lastView { |
27 // Do nothing, but stop the options button from showing up. | 27 // Do nothing, but stop the options button from showing up. |
28 } | 28 } |
29 | 29 |
30 - (NSArray*)visibleControls { | 30 - (NSArray*)visibleControls { |
31 NSMutableArray* visibleControls = | 31 NSMutableArray* visibleControls = |
32 [NSMutableArray arrayWithObjects:label1_.get(), nil]; | 32 [NSMutableArray arrayWithObjects:label1_.get(), nil]; |
33 if ([self delegate]->ShouldShowMessageInfoBarButton()) | 33 if ([self delegate]->ShouldShowMessageInfoBarButton()) |
34 [visibleControls addObject:translateMessageButton_]; | 34 [visibleControls addObject:translateMessageButton_]; |
35 return visibleControls; | 35 return visibleControls; |
36 } | 36 } |
37 | 37 |
38 - (void)loadLabelText { | 38 - (void)loadLabelText { |
39 TranslateInfoBarDelegate* delegate = [self delegate]; | 39 translate::TranslateInfoBarDelegate* delegate = [self delegate]; |
40 base::string16 messageText = delegate->GetMessageInfoBarText(); | 40 base::string16 messageText = delegate->GetMessageInfoBarText(); |
41 NSString* string1 = base::SysUTF16ToNSString(messageText); | 41 NSString* string1 = base::SysUTF16ToNSString(messageText); |
42 [label1_ setStringValue:string1]; | 42 [label1_ setStringValue:string1]; |
43 } | 43 } |
44 | 44 |
45 - (bool)verifyLayout { | 45 - (bool)verifyLayout { |
46 if (![optionsPopUp_ isHidden]) | 46 if (![optionsPopUp_ isHidden]) |
47 return false; | 47 return false; |
48 return [super verifyLayout]; | 48 return [super verifyLayout]; |
49 } | 49 } |
50 | 50 |
51 - (BOOL)shouldShowOptionsPopUp { | 51 - (BOOL)shouldShowOptionsPopUp { |
52 return NO; | 52 return NO; |
53 } | 53 } |
54 | 54 |
55 @end | 55 @end |
OLD | NEW |