OLD | NEW |
(Empty) | |
| 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/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 - (id)initWithDelegate:(InfoBarDelegate*)delegate { |
| 14 if ((self = [super initWithDelegate:delegate])) { |
| 15 TranslateInfoBarDelegate2* delegate = [self delegate]; |
| 16 if (delegate->IsError()) |
| 17 state_ = TranslateInfoBarDelegate2::TRANSLATION_ERROR; |
| 18 else |
| 19 state_ = TranslateInfoBarDelegate2::TRANSLATING; |
| 20 } |
| 21 return self; |
| 22 } |
| 23 |
| 24 - (void)layout { |
| 25 [optionsPopUp_ setHidden:YES]; |
| 26 [self removeOkCancelButtons]; |
| 27 MoveControl(label1_, tryAgainButton_, spaceBetweenControls_ * 2, true); |
| 28 TranslateInfoBarDelegate2* delegate = [self delegate]; |
| 29 if (delegate->IsError()) |
| 30 MoveControl(label1_, tryAgainButton_, spaceBetweenControls_ * 2, true); |
| 31 } |
| 32 |
| 33 - (NSArray*)visibleControls { |
| 34 NSMutableArray* visibleControls = |
| 35 [NSMutableArray arrayWithObjects:label1_.get(), nil]; |
| 36 if (state_ == TranslateInfoBarDelegate2::TRANSLATION_ERROR) |
| 37 [visibleControls addObject:tryAgainButton_]; |
| 38 return visibleControls; |
| 39 } |
| 40 |
| 41 - (void)loadLabelText { |
| 42 TranslateInfoBarDelegate2* delegate = [self delegate]; |
| 43 string16 messageText = delegate->GetMessageInfoBarText(); |
| 44 NSString* string1 = base::SysUTF16ToNSString(messageText); |
| 45 [label1_ setStringValue:string1]; |
| 46 } |
| 47 |
| 48 - (bool)verifyLayout { |
| 49 if (![optionsPopUp_ isHidden]) |
| 50 return false; |
| 51 return [super verifyLayout]; |
| 52 } |
| 53 |
| 54 @end |
OLD | NEW |