Index: chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
diff --git a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
index c7f36c807e5a2682756d9b8021dbc9f8117ba4df..36adb8bd611f0f56c99f68c3707ce03ef2334a6d 100644 |
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
@@ -12,9 +12,9 @@ |
#include "base/strings/sys_string_conversions.h" |
#include "chrome/browser/ui/autofill/autofill_dialog_view_delegate.h" |
#include "chrome/browser/ui/chrome_style.h" |
-#import "chrome/browser/ui/cocoa/autofill/autofill_account_chooser.h" |
#import "chrome/browser/ui/cocoa/autofill/autofill_details_container.h" |
#include "chrome/browser/ui/cocoa/autofill/autofill_dialog_constants.h" |
+#import "chrome/browser/ui/cocoa/autofill/autofill_header.h" |
#import "chrome/browser/ui/cocoa/autofill/autofill_input_field.h" |
#import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" |
#import "chrome/browser/ui/cocoa/autofill/autofill_overlay_controller.h" |
@@ -31,11 +31,10 @@ |
#include "ui/base/l10n/l10n_util.h" |
#include "ui/gfx/platform_font.h" |
-const CGFloat kAccountChooserHeight = 20.0; |
const CGFloat kMinimumContentsHeight = 101; |
// Height of all decorations & paddings on main dialog together. |
-const CGFloat kDecorationHeight = kAccountChooserHeight + |
+const CGFloat kDecorationHeight = autofill::kAccountChooserHeight + |
groby-ooo-7-16
2013/11/20 23:51:44
If this is part of the header, why do we need this
Ilya Sherman
2013/11/22 05:01:13
Done.
|
autofill::kDetailVerticalPadding + |
chrome_style::kClientBottomPadding + |
chrome_style::kTitleTopPadding; |
@@ -64,7 +63,7 @@ void AutofillDialogCocoa::Show() { |
DCHECK(!sheet_delegate_.get()); |
sheet_delegate_.reset([[AutofillDialogWindowController alloc] |
initWithWebContents:delegate_->GetWebContents() |
- autofillDialog:this]); |
+ dialog:this]); |
base::scoped_nsobject<CustomConstrainedWindowSheet> sheet( |
[[CustomConstrainedWindowSheet alloc] |
initWithCustomWindow:[sheet_delegate_ window]]); |
@@ -309,7 +308,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
@implementation AutofillDialogWindowController |
- (id)initWithWebContents:(content::WebContents*)webContents |
- autofillDialog:(autofill::AutofillDialogCocoa*)autofillDialog { |
+ dialog:(autofill::AutofillDialogCocoa*)dialog { |
DCHECK(webContents); |
base::scoped_nsobject<ConstrainedWindowCustomWindow> window( |
@@ -319,30 +318,18 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
if ((self = [super initWithWindow:window])) { |
[window setDelegate:self]; |
webContents_ = webContents; |
- autofillDialog_ = autofillDialog; |
+ dialog_ = dialog; |
+ |
+ header_.reset([[AutofillHeader alloc] initWithDelegate:dialog->delegate()]); |
mainContainer_.reset([[AutofillMainContainer alloc] |
- initWithDelegate:autofillDialog->delegate()]); |
+ initWithDelegate:dialog->delegate()]); |
[mainContainer_ setTarget:self]; |
signInContainer_.reset( |
- [[AutofillSignInContainer alloc] initWithDialog:autofillDialog]); |
+ [[AutofillSignInContainer alloc] initWithDialog:dialog]); |
[[signInContainer_ view] setHidden:YES]; |
- // Set dialog title. |
- titleTextField_.reset([[NSTextField alloc] initWithFrame:NSZeroRect]); |
- [titleTextField_ setEditable:NO]; |
- [titleTextField_ setBordered:NO]; |
- [titleTextField_ setDrawsBackground:NO]; |
- [titleTextField_ setFont:[NSFont systemFontOfSize:15.0]]; |
- [titleTextField_ setStringValue: |
- base::SysUTF16ToNSString(autofillDialog->delegate()->DialogTitle())]; |
- [titleTextField_ sizeToFit]; |
- |
- accountChooser_.reset([[AutofillAccountChooser alloc] |
- initWithFrame:NSZeroRect |
- delegate:autofillDialog->delegate()]); |
- |
loadingShieldTextField_.reset( |
[[NSTextField alloc] initWithFrame:NSZeroRect]); |
ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
@@ -360,7 +347,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
overlayController_.reset( |
[[AutofillOverlayController alloc] initWithDelegate: |
- autofillDialog->delegate()]); |
+ dialog->delegate()]); |
[[overlayController_ view] setHidden:YES]; |
// This needs a flipped content view because otherwise the size |
@@ -370,8 +357,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
[[FlippedView alloc] initWithFrame: |
[[[self window] contentView] frame]]); |
[flippedContentView setSubviews: |
- @[accountChooser_, |
- titleTextField_, |
+ @[header_, |
[mainContainer_ view], |
[signInContainer_ view], |
loadingShieldView, |
@@ -379,7 +365,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
[flippedContentView setAutoresizingMask: |
(NSViewWidthSizable | NSViewHeightSizable)]; |
[[[self window] contentView] addSubview:flippedContentView]; |
- [mainContainer_ setAnchorView:[[accountChooser_ subviews] objectAtIndex:1]]; |
+ [mainContainer_ setAnchorView:[header_ anchorView]]; |
} |
return self; |
} |
@@ -455,33 +441,15 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
NSRect contentRect = NSZeroRect; |
contentRect.size = [self preferredSize]; |
NSRect clientRect = contentRect; |
- clientRect.origin.y = chrome_style::kTitleTopPadding; |
- clientRect.size.height -= chrome_style::kTitleTopPadding + |
- chrome_style::kClientBottomPadding; |
- |
- [titleTextField_ setStringValue: |
- base::SysUTF16ToNSString(autofillDialog_->delegate()->DialogTitle())]; |
- [titleTextField_ sizeToFit]; |
- |
- NSRect headerRect, mainRect, titleRect, dummyRect; |
- NSDivideRect(clientRect, &headerRect, &mainRect, |
- kAccountChooserHeight, NSMinYEdge); |
- NSDivideRect(mainRect, &dummyRect, &mainRect, |
- autofill::kDetailVerticalPadding, NSMinYEdge); |
- headerRect = NSInsetRect(headerRect, chrome_style::kHorizontalPadding, 0); |
- NSDivideRect(headerRect, &titleRect, &headerRect, |
- NSWidth([titleTextField_ frame]), NSMinXEdge); |
- |
- // Align baseline of title with bottom of accountChooser. |
- base::scoped_nsobject<NSLayoutManager> layout_manager( |
- [[NSLayoutManager alloc] init]); |
- NSFont* titleFont = [titleTextField_ font]; |
- titleRect.origin.y += NSHeight(titleRect) - |
- [layout_manager defaultBaselineOffsetForFont:titleFont]; |
- [titleTextField_ setFrame:titleRect]; |
- |
- [accountChooser_ setFrame:headerRect]; |
- [accountChooser_ performLayout]; |
+ clientRect.size.height -= chrome_style::kClientBottomPadding; |
+ |
+ CGFloat headerHeight = [header_ heightForWidth:NSWidth(clientRect)]; |
+ NSRect headerRect, mainRect; |
+ NSDivideRect(clientRect, &headerRect, &mainRect, headerHeight, NSMinYEdge); |
+ |
+ [header_ setFrame:headerRect]; |
+ [header_ performLayout]; |
+ |
if ([[signInContainer_ view] isHidden]) { |
[[mainContainer_ view] setFrame:mainRect]; |
[mainContainer_ performLayout]; |
@@ -508,14 +476,14 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
- (IBAction)accept:(id)sender { |
if ([mainContainer_ validate]) |
- autofillDialog_->delegate()->OnAccept(); |
+ dialog_->delegate()->OnAccept(); |
else |
[mainContainer_ makeFirstInvalidInputFirstResponder]; |
} |
- (IBAction)cancel:(id)sender { |
- autofillDialog_->delegate()->OnCancel(); |
- autofillDialog_->PerformClose(); |
+ dialog_->delegate()->OnCancel(); |
+ dialog_->PerformClose(); |
} |
- (void)show { |
@@ -536,8 +504,8 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
} |
- (void)hide { |
- autofillDialog_->delegate()->OnCancel(); |
- autofillDialog_->PerformClose(); |
+ dialog_->delegate()->OnCancel(); |
+ dialog_->PerformClose(); |
} |
- (void)updateNotificationArea { |
@@ -545,11 +513,11 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
} |
- (void)updateAccountChooser { |
- [accountChooser_ update]; |
+ [header_ update]; |
[mainContainer_ updateLegalDocuments]; |
NSString* newLoadingMessage = @""; |
- if (autofillDialog_->delegate()->ShouldShowSpinner()) |
+ if (dialog_->delegate()->ShouldShowSpinner()) |
newLoadingMessage = l10n_util::GetNSStringWithFixup(IDS_TAB_LOADING_TITLE); |
if (![newLoadingMessage isEqualToString: |
[loadingShieldTextField_ stringValue]]) { |