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.
5 #import "chrome/browser/ui/cocoa/autofill/autofill_header.h"
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"
14 // Height of the account chooser.
15 const CGFloat kAccountChooserHeight = 20.0;
19 @implementation AutofillHeader
21 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate {
22 if (self = [super initWithNibName:nil bundle:nil]) {
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())];
34 base::scoped_nsobject<NSView> view(
35 [[NSView alloc] initWithFrame:NSZeroRect]);
42 [title_ setStringValue:base::SysUTF16ToNSString(delegate_->DialogTitle())];
46 - (NSSize)preferredSize {
48 chrome_style::kTitleTopPadding +
49 kAccountChooserHeight +
50 autofill::kDetailVerticalPadding;
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);
57 - (void)performLayout {
58 [title_ setFrameOrigin:NSMakePoint(chrome_style::kHorizontalPadding,
59 autofill::kDetailVerticalPadding)];