Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(201)

Side by Side Diff: chrome/browser/cocoa/translate/translate_message_infobar_controller.mm

Issue 2815013: Refactor the translate infobars on mac to match the new windows code. (Closed)
Patch Set: Move unittest stuff back to class files Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/translate/translate_message_infobar_controller.h ('k') | chrome/browser/cocoa/translate_infobar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698