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 2dea98b72aea51faf36893bec864a38636d153c6..fe68e9160e4a8e2f31d6b34555191b4af4b90938 100644 |
--- a/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
+++ b/chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.mm |
@@ -16,6 +16,7 @@ |
#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_input_field.h" |
+#import "chrome/browser/ui/cocoa/autofill/autofill_loading_shield_controller.h" |
#import "chrome/browser/ui/cocoa/autofill/autofill_main_container.h" |
#import "chrome/browser/ui/cocoa/autofill/autofill_overlay_controller.h" |
#import "chrome/browser/ui/cocoa/autofill/autofill_section_container.h" |
@@ -233,25 +234,6 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
} // autofill |
-#pragma mark "Loading" Shield |
- |
-@interface AutofillOpaqueView : NSView |
-@end |
- |
-@implementation AutofillOpaqueView |
- |
-- (BOOL)isOpaque { |
- return YES; |
-} |
- |
-- (void)drawRect:(NSRect)dirtyRect { |
- [[[self window] backgroundColor] setFill]; |
- [NSBezierPath fillRect:[self bounds]]; |
-} |
- |
-@end |
- |
- |
#pragma mark Field Editor |
@interface AutofillDialogFieldEditor : NSTextView |
@@ -352,20 +334,9 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
initWithFrame:headerRect |
delegate:autofillDialog->delegate()]); |
- loadingShieldTextField_.reset( |
- [[NSTextField alloc] initWithFrame:NSZeroRect]); |
- ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
- NSFont* loadingFont = rb.GetFont( |
- ui::ResourceBundle::BaseFont).DeriveFont(15).GetNativeFont(); |
- [loadingShieldTextField_ setFont:loadingFont]; |
- [loadingShieldTextField_ setEditable:NO]; |
- [loadingShieldTextField_ setBordered:NO]; |
- [loadingShieldTextField_ setDrawsBackground:NO]; |
- |
- base::scoped_nsobject<AutofillOpaqueView> loadingShieldView( |
- [[AutofillOpaqueView alloc] initWithFrame:NSZeroRect]); |
- [loadingShieldView setHidden:YES]; |
- [loadingShieldView addSubview:loadingShieldTextField_]; |
+ loadingShieldController_.reset( |
+ [[AutofillLoadingShieldController alloc] init]); |
+ [[loadingShieldController_ view] setHidden:YES]; |
overlayController_.reset( |
[[AutofillOverlayController alloc] initWithDelegate: |
@@ -383,7 +354,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
titleTextField_, |
[mainContainer_ view], |
[signInContainer_ view], |
- loadingShieldView, |
+ [loadingShieldController_ view], |
[overlayController_ view]]]; |
[flippedContentView setAutoresizingMask: |
(NSViewWidthSizable | NSViewHeightSizable)]; |
@@ -499,14 +470,8 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
[[signInContainer_ view] setFrame:mainRect]; |
} |
- // Loading shield has text centered in the content rect. |
- NSRect textFrame = [loadingShieldTextField_ frame]; |
- textFrame.origin.x = |
- std::ceil((NSWidth(contentRect) - NSWidth(textFrame)) / 2.0); |
- textFrame.origin.y = |
- std::ceil((NSHeight(contentRect) - NSHeight(textFrame)) / 2.0); |
- [loadingShieldTextField_ setFrame:textFrame]; |
- [[loadingShieldTextField_ superview] setFrame:contentRect]; |
+ [[loadingShieldController_ view] setFrame:contentRect]; |
+ [loadingShieldController_ performLayout]; |
[[overlayController_ view] setFrame:contentRect]; |
[overlayController_ performLayout]; |
@@ -558,14 +523,12 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
[accountChooser_ update]; |
[mainContainer_ updateLegalDocuments]; |
+ autofill::AutofillDialogViewDelegate* delegate = autofillDialog_->delegate(); |
NSString* newLoadingMessage = @""; |
- if (autofillDialog_->delegate()->ShouldShowSpinner()) |
- newLoadingMessage = l10n_util::GetNSStringWithFixup(IDS_TAB_LOADING_TITLE); |
- if (![newLoadingMessage isEqualToString: |
- [loadingShieldTextField_ stringValue]]) { |
- NSView* loadingShieldView = [loadingShieldTextField_ superview]; |
- [loadingShieldTextField_ setStringValue:newLoadingMessage]; |
- [loadingShieldTextField_ sizeToFit]; |
+ if (delegate->ShouldShowSpinner()) |
+ newLoadingMessage = base::SysUTF16ToNSString(delegate->SpinnerText()); |
+ if (![newLoadingMessage isEqualToString:[loadingShieldController_ message]]) { |
+ [loadingShieldController_ setMessage:newLoadingMessage]; |
groby-ooo-7-16
2013/11/15 23:03:38
Should that just move into the setMessage: call?
Ilya Sherman
2013/11/16 00:31:13
Restructured this so that most of this logic is no
|
BOOL showShield = ([newLoadingMessage length] != 0); |
@@ -574,7 +537,7 @@ void AutofillDialogCocoa::OnConstrainedWindowClosed( |
// No need to remember previous state, because the loading shield |
// always flows through to the main container. |
[[mainContainer_ view] setHidden:showShield]; |
- [loadingShieldView setHidden:!showShield]; |
+ [[loadingShieldController_ view] setHidden:!showShield]; |
[self requestRelayout]; |
} |
} |