summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/infobars/translate_message_infobar_controller.mm
blob: d210d2128bc46de71621b9e33d38f14e55352d2e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "chrome/browser/ui/cocoa/infobars/translate_message_infobar_controller.h"

#include "base/strings/sys_string_conversions.h"
#import "chrome/browser/ui/cocoa/infobars/infobar_utilities.h"

using InfoBarUtilities::MoveControl;

@implementation TranslateMessageInfobarController

- (void)layout {
  [self removeOkCancelButtons];
  MoveControl(
      label1_, translateMessageButton_, spaceBetweenControls_ * 2, true);
  TranslateInfoBarDelegate* delegate = [self delegate];
  if ([self delegate]->ShouldShowMessageInfoBarButton()) {
    string16 buttonText = delegate->GetMessageInfoBarButtonText();
    [translateMessageButton_ setTitle:base::SysUTF16ToNSString(buttonText)];
    [translateMessageButton_ sizeToFit];
  }
}

- (void)adjustOptionsButtonSizeAndVisibilityForView:(NSView*)lastView {
  // Do nothing, but stop the options button from showing up.
}

- (NSArray*)visibleControls {
  NSMutableArray* visibleControls =
      [NSMutableArray arrayWithObjects:label1_.get(), nil];
  if ([self delegate]->ShouldShowMessageInfoBarButton())
    [visibleControls addObject:translateMessageButton_];
  return visibleControls;
}

- (void)loadLabelText {
  TranslateInfoBarDelegate* delegate = [self delegate];
  string16 messageText = delegate->GetMessageInfoBarText();
  NSString* string1 = base::SysUTF16ToNSString(messageText);
  [label1_ setStringValue:string1];
}

- (bool)verifyLayout {
  if (![optionsPopUp_ isHidden])
    return false;
  return [super verifyLayout];
}

- (BOOL)shouldShowOptionsPopUp {
  return NO;
}

@end