Add new certificateProvider extension API.
[chromium-blink-merge.git] / chrome / browser / ui / cocoa / autofill / autofill_header.mm
blob556bdb3e9b8cc92b141c5a4615536da33405b8d5
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"
12 namespace {
14 // Height of the account chooser.
15 const CGFloat kAccountChooserHeight = 20.0;
17 }  // namespace
19 @implementation AutofillHeader
21 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate {
22   if (self = [super initWithNibName:nil bundle:nil]) {
23     delegate_ = delegate;
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];
34     base::scoped_nsobject<NSView> view(
35         [[NSView alloc] initWithFrame:NSZeroRect]);
36     [self setView:view];
37   }
38   return self;
41 - (void)update {
42   [title_ setStringValue:base::SysUTF16ToNSString(delegate_->DialogTitle())];
43   [title_ sizeToFit];
46 - (NSSize)preferredSize {
47   CGFloat height =
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)];
62 @end