| OLD | NEW |
| (Empty) |
| 1 // Copyright 2013 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 #import "chrome/browser/ui/cocoa/autofill/autofill_header.h" | |
| 6 | |
| 7 #include "base/strings/sys_string_conversions.h" | |
| 8 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" | |
| 9 #include "chrome/browser/ui/chrome_style.h" | |
| 10 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 // Height of the account chooser. | |
| 15 const CGFloat kAccountChooserHeight = 20.0; | |
| 16 | |
| 17 } // namespace | |
| 18 | |
| 19 @implementation AutofillHeader | |
| 20 | |
| 21 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate { | |
| 22 if (self = [super initWithNibName:nil bundle:nil]) { | |
| 23 delegate_ = delegate; | |
| 24 | |
| 25 // Set dialog title. | |
| 26 title_.reset([[NSTextField alloc] initWithFrame:NSZeroRect]); | |
| 27 [title_ setEditable:NO]; | |
| 28 [title_ setBordered:NO]; | |
| 29 [title_ setDrawsBackground:NO]; | |
| 30 [title_ setFont:[NSFont systemFontOfSize:15.0]]; | |
| 31 [title_ setStringValue:base::SysUTF16ToNSString(delegate_->DialogTitle())]; | |
| 32 [title_ sizeToFit]; | |
| 33 | |
| 34 base::scoped_nsobject<NSView> view( | |
| 35 [[NSView alloc] initWithFrame:NSZeroRect]); | |
| 36 [self setView:view]; | |
| 37 } | |
| 38 return self; | |
| 39 } | |
| 40 | |
| 41 - (void)update { | |
| 42 [title_ setStringValue:base::SysUTF16ToNSString(delegate_->DialogTitle())]; | |
| 43 [title_ sizeToFit]; | |
| 44 } | |
| 45 | |
| 46 - (NSSize)preferredSize { | |
| 47 CGFloat height = | |
| 48 chrome_style::kTitleTopPadding + | |
| 49 kAccountChooserHeight + | |
| 50 autofill::kDetailVerticalPadding; | |
| 51 | |
| 52 // The returned width is unused, and there's no simple way to compute the | |
| 53 // account chooser's width, so just return 0 for the width. | |
| 54 return NSMakeSize(0, height); | |
| 55 } | |
| 56 | |
| 57 - (void)performLayout { | |
| 58 [title_ setFrameOrigin:NSMakePoint(chrome_style::kHorizontalPadding, | |
| 59 autofill::kDetailVerticalPadding)]; | |
| 60 } | |
| 61 | |
| 62 @end | |
| OLD | NEW |