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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/translate/translate_message_infobar_controller.mm
diff --git a/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm b/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..108782088b47857b6145510cf903b8e41ec09917
--- /dev/null
+++ b/chrome/browser/cocoa/translate/translate_message_infobar_controller.mm
@@ -0,0 +1,54 @@
+// Copyright (c) 2010 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/cocoa/translate/translate_message_infobar_controller.h"
+
+#include "base/sys_string_conversions.h"
+
+using TranslateInfoBarUtilities::MoveControl;
+
+@implementation TranslateMessageInfobarController
+
+- (id)initWithDelegate:(InfoBarDelegate*)delegate {
+ if ((self = [super initWithDelegate:delegate])) {
+ TranslateInfoBarDelegate2* delegate = [self delegate];
+ if (delegate->IsError())
+ state_ = TranslateInfoBarDelegate2::TRANSLATION_ERROR;
+ else
+ state_ = TranslateInfoBarDelegate2::TRANSLATING;
+ }
+ return self;
+}
+
+- (void)layout {
+ [optionsPopUp_ setHidden:YES];
+ [self removeOkCancelButtons];
+ MoveControl(label1_, tryAgainButton_, spaceBetweenControls_ * 2, true);
+ TranslateInfoBarDelegate2* delegate = [self delegate];
+ if (delegate->IsError())
+ MoveControl(label1_, tryAgainButton_, spaceBetweenControls_ * 2, true);
+}
+
+- (NSArray*)visibleControls {
+ NSMutableArray* visibleControls =
+ [NSMutableArray arrayWithObjects:label1_.get(), nil];
+ if (state_ == TranslateInfoBarDelegate2::TRANSLATION_ERROR)
+ [visibleControls addObject:tryAgainButton_];
+ return visibleControls;
+}
+
+- (void)loadLabelText {
+ TranslateInfoBarDelegate2* 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];
+}
+
+@end
« 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