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

Side by Side Diff: chrome/browser/ui/cocoa/autofill/autofill_header.mm

Issue 77283002: [rAc OSX] Factor out AutofillHeader class to contain dialog header elements. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile after rebase Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_header.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #import "chrome/browser/ui/cocoa/autofill/autofill_account_chooser.h"
8 #include "base/strings/sys_string_conversions.h"
9 #include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h"
10 #include "chrome/browser/ui/chrome_style.h"
11 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h"
12
13 namespace {
14
15 // Height of the account chooser.
16 const CGFloat kAccountChooserHeight = 20.0;
17
18 } // namespace
19
20 @implementation AutofillHeader
21
22 - (id)initWithDelegate:(autofill::AutofillDialogViewDelegate*)delegate {
23 if (self = [super initWithNibName:nil bundle:nil]) {
24 delegate_ = delegate;
25
26 accountChooser_.reset(
27 [[AutofillAccountChooser alloc] initWithFrame:NSZeroRect
28 delegate:delegate]);
29
30 // Set dialog title.
31 title_.reset([[NSTextField alloc] initWithFrame:NSZeroRect]);
32 [title_ setEditable:NO];
33 [title_ setBordered:NO];
34 [title_ setDrawsBackground:NO];
35 [title_ setFont:[NSFont systemFontOfSize:15.0]];
36 [title_ setStringValue:base::SysUTF16ToNSString(delegate_->DialogTitle())];
37 [title_ sizeToFit];
38
39 base::scoped_nsobject<NSView> view(
40 [[NSView alloc] initWithFrame:NSZeroRect]);
41 [view setSubviews:@[accountChooser_, title_]];
42 [self setView:view];
43 }
44 return self;
45 }
46
47 - (NSView*)anchorView {
48 return [[accountChooser_ subviews] objectAtIndex:1];
49 }
50
51 - (void)update {
52 [accountChooser_ update];
53
54 [title_ setStringValue:base::SysUTF16ToNSString(delegate_->DialogTitle())];
55 [title_ sizeToFit];
56 }
57
58 - (CGFloat)heightForWidth:(int)width {
59 return chrome_style::kTitleTopPadding +
60 kAccountChooserHeight +
61 autofill::kDetailVerticalPadding;
62 }
63
64 - (NSSize)preferredSize {
65 NOTREACHED(); // Only implemented as part of AutofillLayout protocol.
66 return NSZeroSize;
67 }
68
69 - (void)performLayout {
70 NSRect bounds = [[self view] bounds];
71
72 [title_ setFrameOrigin:NSMakePoint(chrome_style::kHorizontalPadding,
73 autofill::kDetailVerticalPadding)];
74
75 CGFloat accountChooserLeftX =
76 NSMaxX([title_ frame]) + chrome_style::kHorizontalPadding;
77 CGFloat accountChooserWidth =
78 NSMaxX(bounds) - chrome_style::kHorizontalPadding - accountChooserLeftX;
79 NSRect accountChooserFrame =
80 NSMakeRect(accountChooserLeftX, autofill::kDetailVerticalPadding,
81 accountChooserWidth, kAccountChooserHeight);
82 [accountChooser_ setFrame:accountChooserFrame];
83 [accountChooser_ performLayout];
84 }
85
86 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/autofill/autofill_header.h ('k') | chrome/chrome_browser_ui.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698