OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 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/cocoa/translate/translate_message_infobar_controller.h" | 5 #include "chrome/browser/cocoa/translate/translate_message_infobar_controller.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 | 8 |
9 using TranslateInfoBarUtilities::MoveControl; | 9 using TranslateInfoBarUtilities::MoveControl; |
10 | 10 |
11 @implementation TranslateMessageInfobarController | 11 @implementation TranslateMessageInfobarController |
12 | 12 |
13 - (id)initWithDelegate:(InfoBarDelegate*)delegate { | 13 - (id)initWithDelegate:(InfoBarDelegate*)delegate { |
14 if ((self = [super initWithDelegate:delegate])) { | 14 if ((self = [super initWithDelegate:delegate])) { |
15 TranslateInfoBarDelegate* delegate = [self delegate]; | 15 TranslateInfoBarDelegate* delegate = [self delegate]; |
16 if (delegate->IsError()) | 16 if (delegate->IsError()) |
17 state_ = TranslateInfoBarDelegate::kTranslationError; | 17 state_ = TranslateInfoBarDelegate::TRANSLATION_ERROR; |
18 else | 18 else |
19 state_ = TranslateInfoBarDelegate::kTranslating; | 19 state_ = TranslateInfoBarDelegate::TRANSLATING; |
20 } | 20 } |
21 return self; | 21 return self; |
22 } | 22 } |
23 | 23 |
24 - (void)layout { | 24 - (void)layout { |
25 [optionsPopUp_ setHidden:YES]; | 25 [optionsPopUp_ setHidden:YES]; |
26 [self removeOkCancelButtons]; | 26 [self removeOkCancelButtons]; |
27 MoveControl(label1_, tryAgainButton_, spaceBetweenControls_ * 2, true); | 27 MoveControl(label1_, tryAgainButton_, spaceBetweenControls_ * 2, true); |
28 TranslateInfoBarDelegate* delegate = [self delegate]; | 28 TranslateInfoBarDelegate* delegate = [self delegate]; |
29 if (delegate->IsError()) | 29 if (delegate->IsError()) |
30 MoveControl(label1_, tryAgainButton_, spaceBetweenControls_ * 2, true); | 30 MoveControl(label1_, tryAgainButton_, spaceBetweenControls_ * 2, true); |
31 } | 31 } |
32 | 32 |
33 - (void)adjustOptionsButtonSizeAndVisibilityForView:(NSView*)lastView { | 33 - (void)adjustOptionsButtonSizeAndVisibilityForView:(NSView*)lastView { |
34 // Do nothing, but stop the options button from showing up. | 34 // Do nothing, but stop the options button from showing up. |
35 } | 35 } |
36 | 36 |
37 - (NSArray*)visibleControls { | 37 - (NSArray*)visibleControls { |
38 NSMutableArray* visibleControls = | 38 NSMutableArray* visibleControls = |
39 [NSMutableArray arrayWithObjects:label1_.get(), nil]; | 39 [NSMutableArray arrayWithObjects:label1_.get(), nil]; |
40 if (state_ == TranslateInfoBarDelegate::kTranslationError) | 40 if (state_ == TranslateInfoBarDelegate::TRANSLATION_ERROR) |
41 [visibleControls addObject:tryAgainButton_]; | 41 [visibleControls addObject:tryAgainButton_]; |
42 return visibleControls; | 42 return visibleControls; |
43 } | 43 } |
44 | 44 |
45 - (void)loadLabelText { | 45 - (void)loadLabelText { |
46 TranslateInfoBarDelegate* delegate = [self delegate]; | 46 TranslateInfoBarDelegate* delegate = [self delegate]; |
47 string16 messageText = delegate->GetMessageInfoBarText(); | 47 string16 messageText = delegate->GetMessageInfoBarText(); |
48 NSString* string1 = base::SysUTF16ToNSString(messageText); | 48 NSString* string1 = base::SysUTF16ToNSString(messageText); |
49 [label1_ setStringValue:string1]; | 49 [label1_ setStringValue:string1]; |
50 } | 50 } |
51 | 51 |
52 - (bool)verifyLayout { | 52 - (bool)verifyLayout { |
53 if (![optionsPopUp_ isHidden]) | 53 if (![optionsPopUp_ isHidden]) |
54 return false; | 54 return false; |
55 return [super verifyLayout]; | 55 return [super verifyLayout]; |
56 } | 56 } |
57 | 57 |
58 @end | 58 @end |
OLD | NEW |