OLD | NEW |
---|---|
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/message_loop/message_loop.h" | 6 #include "base/message_loop/message_loop.h" |
7 #include "base/strings/sys_string_conversions.h" | 7 #include "base/strings/sys_string_conversions.h" |
8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" | 8 #include "chrome/browser/ui/autofill/autofill_dialog_models.h" |
9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" | 9 #include "chrome/browser/ui/autofill/autofill_dialog_types.h" |
10 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" | 10 #include "chrome/browser/ui/autofill/card_unmask_prompt_controller.h" |
11 #include "chrome/browser/ui/chrome_style.h" | |
11 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h" | 12 #import "chrome/browser/ui/cocoa/autofill/autofill_tooltip_controller.h" |
12 #include "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h" | 13 #include "chrome/browser/ui/cocoa/autofill/card_unmask_prompt_view_bridge.h" |
13 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" | 14 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_button.h" |
14 #include "chrome/browser/ui/chrome_style.h" | |
15 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u tils.h" | 15 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_control_u tils.h" |
16 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" | 16 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh eet.h" |
17 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" | 17 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_wi ndow.h" |
18 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" | 18 #import "chrome/browser/ui/cocoa/key_equivalent_constants.h" |
19 #import "chrome/browser/ui/cocoa/l10n_util.h" | |
19 #include "grit/generated_resources.h" | 20 #include "grit/generated_resources.h" |
20 #include "grit/theme_resources.h" | 21 #include "grit/theme_resources.h" |
21 #include "skia/ext/skia_utils_mac.h" | 22 #include "skia/ext/skia_utils_mac.h" |
22 #include "ui/base/cocoa/window_size_constants.h" | 23 #include "ui/base/cocoa/window_size_constants.h" |
23 #include "ui/base/l10n/l10n_util.h" | 24 #include "ui/base/l10n/l10n_util.h" |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 const CGFloat kButtonGap = 6.0f; | 28 const CGFloat kButtonGap = 6.0f; |
28 const CGFloat kDialogContentMinWidth = 210.0f; | 29 const CGFloat kDialogContentMinWidth = 210.0f; |
29 const CGFloat kCvcInputWidth = 64.0f; | 30 const CGFloat kCvcInputWidth = 64.0f; |
31 const SkColor kPermanentErrorTextColor = 0xffffffff; | |
groby-ooo-7-16
2015/03/26 01:35:27
SkColor_WHITE;
bondd
2015/03/26 02:54:29
Done.
| |
32 const SkColor kPermanentErrorBackgroundColor = 0xffd32f2f; | |
groby-ooo-7-16
2015/03/26 01:35:27
SkColorSetRGB(0xd3, 0x2f, 0x2f)
bondd
2015/03/26 02:54:29
Done.
| |
30 const ui::ResourceBundle::FontStyle kProgressFontStyle = | 33 const ui::ResourceBundle::FontStyle kProgressFontStyle = |
31 chrome_style::kTitleFontStyle; | 34 chrome_style::kTitleFontStyle; |
32 const ui::ResourceBundle::FontStyle kErrorFontStyle = | 35 const ui::ResourceBundle::FontStyle kErrorFontStyle = |
33 chrome_style::kTextFontStyle; | 36 chrome_style::kTextFontStyle; |
34 | 37 |
35 } // namespace | 38 } // namespace |
36 | 39 |
37 namespace autofill { | 40 namespace autofill { |
38 | 41 |
39 // static | 42 // static |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
81 [view_controller_ setProgressOverlayText: | 84 [view_controller_ setProgressOverlayText: |
82 l10n_util::GetStringUTF16( | 85 l10n_util::GetStringUTF16( |
83 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_SUCCESS)]; | 86 IDS_AUTOFILL_CARD_UNMASK_VERIFICATION_SUCCESS)]; |
84 | 87 |
85 base::MessageLoop::current()->PostDelayedTask( | 88 base::MessageLoop::current()->PostDelayedTask( |
86 FROM_HERE, base::Bind(&CardUnmaskPromptViewBridge::PerformClose, | 89 FROM_HERE, base::Bind(&CardUnmaskPromptViewBridge::PerformClose, |
87 weak_ptr_factory_.GetWeakPtr()), | 90 weak_ptr_factory_.GetWeakPtr()), |
88 base::TimeDelta::FromSeconds(1)); | 91 base::TimeDelta::FromSeconds(1)); |
89 } else { | 92 } else { |
90 [view_controller_ setProgressOverlayText:base::string16()]; | 93 [view_controller_ setProgressOverlayText:base::string16()]; |
91 // TODO(bondd): Views version never hides |errorLabel_|. When Views decides | 94 |
92 // when to hide it then do the same thing here. | 95 if (allow_retry) { |
93 [view_controller_ setRetriableErrorMessage:error_message]; | 96 // TODO(bondd): Views version never hides |errorLabel_|. When Views |
97 // decides when to hide it then do the same thing here. | |
98 [view_controller_ setRetriableErrorMessage:error_message]; | |
99 } else { | |
100 [view_controller_ setPermanentErrorMessage:error_message]; | |
101 [view_controller_ setRetriableErrorMessage:base::string16()]; | |
groby-ooo-7-16
2015/03/26 01:35:27
Shouldn't -setPermanentErrorMessage automatically
bondd
2015/03/26 02:54:28
Done. This gets rid of the -performLayout call too
| |
102 } | |
103 [view_controller_ performLayout]; | |
94 } | 104 } |
95 } | 105 } |
96 | 106 |
97 void CardUnmaskPromptViewBridge::OnConstrainedWindowClosed( | 107 void CardUnmaskPromptViewBridge::OnConstrainedWindowClosed( |
98 ConstrainedWindowMac* window) { | 108 ConstrainedWindowMac* window) { |
99 if (controller_) | 109 if (controller_) |
100 controller_->OnUnmaskDialogClosed(); | 110 controller_->OnUnmaskDialogClosed(); |
101 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 111 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
102 } | 112 } |
103 | 113 |
104 CardUnmaskPromptController* CardUnmaskPromptViewBridge::GetController() { | 114 CardUnmaskPromptController* CardUnmaskPromptViewBridge::GetController() { |
105 return controller_; | 115 return controller_; |
106 } | 116 } |
107 | 117 |
108 void CardUnmaskPromptViewBridge::PerformClose() { | 118 void CardUnmaskPromptViewBridge::PerformClose() { |
109 constrained_window_->CloseWebContentsModalDialog(); | 119 constrained_window_->CloseWebContentsModalDialog(); |
110 } | 120 } |
111 | 121 |
112 } // autofill | 122 } // autofill |
113 | 123 |
114 #pragma mark CardUnmaskPromptViewCocoa | 124 #pragma mark CardUnmaskPromptViewCocoa |
115 | 125 |
116 @implementation CardUnmaskPromptViewCocoa { | 126 @implementation CardUnmaskPromptViewCocoa { |
127 base::scoped_nsobject<NSBox> permanentErrorBox_; | |
117 base::scoped_nsobject<NSView> inputRowView_; | 128 base::scoped_nsobject<NSView> inputRowView_; |
118 base::scoped_nsobject<NSView> storageView_; | 129 base::scoped_nsobject<NSView> storageView_; |
119 | 130 |
120 base::scoped_nsobject<NSTextField> titleLabel_; | 131 base::scoped_nsobject<NSTextField> titleLabel_; |
132 base::scoped_nsobject<NSTextField> permanentErrorLabel_; | |
121 base::scoped_nsobject<NSTextField> instructionsLabel_; | 133 base::scoped_nsobject<NSTextField> instructionsLabel_; |
122 base::scoped_nsobject<NSTextField> cvcInput_; | 134 base::scoped_nsobject<NSTextField> cvcInput_; |
123 base::scoped_nsobject<NSPopUpButton> monthPopup_; | 135 base::scoped_nsobject<NSPopUpButton> monthPopup_; |
124 base::scoped_nsobject<NSPopUpButton> yearPopup_; | 136 base::scoped_nsobject<NSPopUpButton> yearPopup_; |
125 base::scoped_nsobject<NSButton> cancelButton_; | 137 base::scoped_nsobject<NSButton> cancelButton_; |
126 base::scoped_nsobject<NSButton> verifyButton_; | 138 base::scoped_nsobject<NSButton> verifyButton_; |
127 base::scoped_nsobject<NSButton> storageCheckbox_; | 139 base::scoped_nsobject<NSButton> storageCheckbox_; |
128 base::scoped_nsobject<AutofillTooltipController> storageTooltip_; | 140 base::scoped_nsobject<AutofillTooltipController> storageTooltip_; |
129 base::scoped_nsobject<NSTextField> errorLabel_; | 141 base::scoped_nsobject<NSTextField> errorLabel_; |
130 base::scoped_nsobject<NSTextField> progressOverlayLabel_; | 142 base::scoped_nsobject<NSTextField> progressOverlayLabel_; |
131 | 143 |
132 int monthPopupDefaultIndex_; | 144 int monthPopupDefaultIndex_; |
133 int yearPopupDefaultIndex_; | 145 int yearPopupDefaultIndex_; |
134 | 146 |
135 // Owns |self|. | 147 // Owns |self|. |
136 autofill::CardUnmaskPromptViewBridge* bridge_; | 148 autofill::CardUnmaskPromptViewBridge* bridge_; |
137 } | 149 } |
138 | 150 |
139 + (NSPopUpButton*)buildDatePopupWithModel:(ui::ComboboxModel&)model { | 151 + (NSPopUpButton*)buildDatePopupWithModel:(ui::ComboboxModel&)model { |
140 NSPopUpButton* popup = | 152 NSPopUpButton* popup = |
141 [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO]; | 153 [[NSPopUpButton alloc] initWithFrame:NSZeroRect pullsDown:NO]; |
142 | 154 |
143 for (int i = 0; i < model.GetItemCount(); ++i) { | 155 for (int i = 0; i < model.GetItemCount(); ++i) { |
144 [popup addItemWithTitle:base::SysUTF16ToNSString(model.GetItemAt(i))]; | 156 [popup addItemWithTitle:base::SysUTF16ToNSString(model.GetItemAt(i))]; |
145 } | 157 } |
146 [popup sizeToFit]; | 158 [popup sizeToFit]; |
147 return popup; | 159 return popup; |
148 } | 160 } |
149 | 161 |
150 // Sets |textField|'s frame size to minimum dimensions needed to display its | |
151 // text without exceeding |width|. Text will wrap onto multiple lines if | |
152 // necessary. Frame width may end up being less than |width| if the text fits | |
153 // in a smaller area. | |
154 + (void)sizeTextField:(NSTextField*)textField toFitWidth:(CGFloat)width { | |
155 NSSize frameSize = | |
156 [[textField cell] cellSizeForBounds:NSMakeRect(0, 0, width, CGFLOAT_MAX)]; | |
157 [textField setFrameSize:frameSize]; | |
158 } | |
159 | |
160 // Set |view|'s frame to the minimum dimensions required to contain all of its | 162 // Set |view|'s frame to the minimum dimensions required to contain all of its |
161 // subviews. | 163 // subviews. |
162 + (void)sizeToFitView:(NSView*)view { | 164 + (void)sizeToFitView:(NSView*)view { |
163 NSRect frame = NSZeroRect; | 165 NSRect frame = NSZeroRect; |
164 for (NSView* child in [view subviews]) { | 166 for (NSView* child in [view subviews]) { |
165 frame = NSUnionRect(frame, [child frame]); | 167 frame = NSUnionRect(frame, [child frame]); |
166 } | 168 } |
167 [view setFrame:frame]; | 169 [view setFrame:frame]; |
168 } | 170 } |
169 | 171 |
(...skipping 28 matching lines...) Expand all Loading... | |
198 [inputRowView_ setHidden:!text.empty()]; | 200 [inputRowView_ setHidden:!text.empty()]; |
199 [self updateVerifyButtonEnabled]; | 201 [self updateVerifyButtonEnabled]; |
200 } | 202 } |
201 | 203 |
202 - (void)setRetriableErrorMessage:(const base::string16&)text { | 204 - (void)setRetriableErrorMessage:(const base::string16&)text { |
203 NSAttributedString* attributedString = | 205 NSAttributedString* attributedString = |
204 constrained_window::GetAttributedLabelString( | 206 constrained_window::GetAttributedLabelString( |
205 SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment, | 207 SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment, |
206 NSLineBreakByWordWrapping); | 208 NSLineBreakByWordWrapping); |
207 [errorLabel_ setAttributedStringValue:attributedString]; | 209 [errorLabel_ setAttributedStringValue:attributedString]; |
208 [self performLayoutAndDisplay:YES]; | 210 } |
211 | |
212 - (void)setPermanentErrorMessage:(const base::string16&)text { | |
213 if (!text.empty()) { | |
214 if (!permanentErrorBox_) { | |
215 permanentErrorBox_.reset([[NSBox alloc] initWithFrame:NSZeroRect]); | |
216 [permanentErrorBox_ setBoxType:NSBoxCustom]; | |
217 [permanentErrorBox_ setBorderType:NSNoBorder]; | |
218 [permanentErrorBox_ setTitlePosition:NSNoTitle]; | |
219 [permanentErrorBox_ setFillColor:gfx::SkColorToCalibratedNSColor( | |
220 kPermanentErrorBackgroundColor)]; | |
221 | |
222 permanentErrorLabel_.reset([constrained_window::CreateLabel() retain]); | |
223 [permanentErrorLabel_ setAutoresizingMask:NSViewWidthSizable]; | |
224 [permanentErrorLabel_ setTextColor:gfx::SkColorToCalibratedNSColor( | |
225 kPermanentErrorTextColor)]; | |
226 | |
227 [permanentErrorBox_ addSubview:permanentErrorLabel_]; | |
228 [[self view] addSubview:permanentErrorBox_]; | |
229 } | |
230 | |
231 NSAttributedString* attributedString = | |
232 constrained_window::GetAttributedLabelString( | |
233 SysUTF16ToNSString(text), kErrorFontStyle, NSNaturalTextAlignment, | |
234 NSLineBreakByWordWrapping); | |
235 [permanentErrorLabel_ setAttributedStringValue:attributedString]; | |
236 } | |
237 | |
238 [permanentErrorBox_ setHidden:text.empty()]; | |
209 } | 239 } |
210 | 240 |
211 - (void)updateVerifyButtonEnabled { | 241 - (void)updateVerifyButtonEnabled { |
212 autofill::CardUnmaskPromptController* controller = bridge_->GetController(); | 242 autofill::CardUnmaskPromptController* controller = bridge_->GetController(); |
213 DCHECK(controller); | 243 DCHECK(controller); |
214 | 244 |
215 BOOL enable = | 245 BOOL enable = |
216 ![inputRowView_ isHidden] && | 246 ![inputRowView_ isHidden] && |
217 controller->InputCvcIsValid( | 247 controller->InputCvcIsValid( |
218 base::SysNSStringToUTF16([cvcInput_ stringValue])) && | 248 base::SysNSStringToUTF16([cvcInput_ stringValue])) && |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))]; | 305 IDS_AUTOFILL_CARD_UNMASK_PROMPT_STORAGE_TOOLTIP))]; |
276 [view addSubview:[storageTooltip_ view]]; | 306 [view addSubview:[storageTooltip_ view]]; |
277 [[storageTooltip_ view] setFrameOrigin: | 307 [[storageTooltip_ view] setFrameOrigin: |
278 NSMakePoint(NSMaxX([storageCheckbox_ frame]) + kButtonGap, 0)]; | 308 NSMakePoint(NSMaxX([storageCheckbox_ frame]) + kButtonGap, 0)]; |
279 | 309 |
280 [CardUnmaskPromptViewCocoa sizeToFitView:view]; | 310 [CardUnmaskPromptViewCocoa sizeToFitView:view]; |
281 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:view]; | 311 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:view]; |
282 return view; | 312 return view; |
283 } | 313 } |
284 | 314 |
285 // TODO(bondd): Add an ASCII diagram of the layout. | 315 // +------------------------------------------------+ |
316 // | titleLabel_ (Single line.) | | |
317 // |------------------------------------------------| | |
318 // | permanentErrorBox_ (Multiline, may be hidden.) | | |
319 // |------------------------------------------------| | |
320 // | instructionsLabel_ (Multiline.) | | |
321 // |------------------------------------------------| | |
322 // | monthPopup_ yearPopup_ cvcInput_ cvcImage | | |
323 // | (All enclosed in inputRowView_. Month and | | |
324 // | year may be hidden.) | | |
325 // |------------------------------------------------| | |
326 // | errorLabel_ (Multiline. Always takes up space | | |
327 // | for one line even if empty.) | | |
328 // |------------------------------------------------| | |
329 // | [Cancel] [Verify] | | |
330 // |------------------------------------------------| | |
331 // | storageCheckbox_ storageTooltip_ | | |
332 // | (Both enclosed in storageView_.) | | |
333 // +------------------------------------------------+ | |
286 - (void)performLayoutAndDisplay:(BOOL)display { | 334 - (void)performLayoutAndDisplay:(BOOL)display { |
287 // Calculate dialog content width. | 335 // Calculate dialog content width. |
288 CGFloat contentWidth = | 336 CGFloat contentWidth = |
289 std::max(NSWidth([titleLabel_ frame]), NSWidth([inputRowView_ frame])); | 337 std::max(NSWidth([titleLabel_ frame]), NSWidth([inputRowView_ frame])); |
290 contentWidth = std::max(contentWidth, NSWidth([storageView_ frame])); | 338 contentWidth = std::max(contentWidth, NSWidth([storageView_ frame])); |
291 contentWidth = std::max(contentWidth, kDialogContentMinWidth); | 339 contentWidth = std::max(contentWidth, kDialogContentMinWidth); |
292 | 340 |
293 [storageView_ | 341 [storageView_ |
294 setFrameOrigin:NSMakePoint(0, chrome_style::kClientBottomPadding)]; | 342 setFrameOrigin:NSMakePoint(0, chrome_style::kClientBottomPadding)]; |
295 | 343 |
296 [verifyButton_ setFrameOrigin: | 344 [verifyButton_ setFrameOrigin: |
297 NSMakePoint(contentWidth - NSWidth([verifyButton_ frame]), | 345 NSMakePoint(contentWidth - NSWidth([verifyButton_ frame]), |
298 NSMaxY([storageView_ frame]) + chrome_style::kRowPadding)]; | 346 NSMaxY([storageView_ frame]) + chrome_style::kRowPadding)]; |
299 | 347 |
300 [cancelButton_ | 348 [cancelButton_ |
301 setFrameOrigin:NSMakePoint(NSMinX([verifyButton_ frame]) - kButtonGap - | 349 setFrameOrigin:NSMakePoint(NSMinX([verifyButton_ frame]) - kButtonGap - |
302 NSWidth([cancelButton_ frame]), | 350 NSWidth([cancelButton_ frame]), |
303 NSMinY([verifyButton_ frame]))]; | 351 NSMinY([verifyButton_ frame]))]; |
304 | 352 |
305 [errorLabel_ setFrameOrigin:NSMakePoint(0, NSMaxY([cancelButton_ frame]) + | 353 [errorLabel_ setFrame:NSMakeRect(0, NSMaxY([cancelButton_ frame]) + |
306 chrome_style::kRowPadding)]; | 354 chrome_style::kRowPadding, |
307 [CardUnmaskPromptViewCocoa sizeTextField:errorLabel_ toFitWidth:contentWidth]; | 355 contentWidth, 0)]; |
356 cocoa_l10n_util::WrapOrSizeToFit(errorLabel_); | |
308 | 357 |
309 [inputRowView_ setFrameOrigin:NSMakePoint(0, NSMaxY([errorLabel_ frame]) + | 358 [inputRowView_ setFrameOrigin:NSMakePoint(0, NSMaxY([errorLabel_ frame]) + |
310 chrome_style::kRowPadding)]; | 359 chrome_style::kRowPadding)]; |
311 | 360 |
312 [instructionsLabel_ | 361 [instructionsLabel_ setFrame:NSMakeRect(0, NSMaxY([inputRowView_ frame]) + |
313 setFrameOrigin:NSMakePoint(0, NSMaxY([inputRowView_ frame]) + | 362 chrome_style::kRowPadding, |
314 chrome_style::kRowPadding)]; | 363 contentWidth, 0)]; |
315 [CardUnmaskPromptViewCocoa sizeTextField:instructionsLabel_ | 364 cocoa_l10n_util::WrapOrSizeToFit(instructionsLabel_); |
316 toFitWidth:contentWidth]; | |
317 | 365 |
318 [titleLabel_ | 366 // Layout permanent error box. |
319 setFrameOrigin:NSMakePoint(0, NSMaxY([instructionsLabel_ frame]) + | 367 CGFloat minY = NSMaxY([instructionsLabel_ frame]) + chrome_style::kRowPadding; |
320 chrome_style::kRowPadding)]; | 368 if (permanentErrorBox_ && ![permanentErrorBox_ isHidden]) { |
369 [permanentErrorBox_ setFrame:NSMakeRect(0, minY, contentWidth, 0)]; | |
370 cocoa_l10n_util::WrapOrSizeToFit(permanentErrorLabel_); | |
371 [permanentErrorBox_ sizeToFit]; | |
372 minY = NSMaxY([permanentErrorBox_ frame]) + chrome_style::kRowPadding; | |
373 } | |
374 | |
375 [titleLabel_ setFrameOrigin:NSMakePoint(0, minY)]; | |
321 | 376 |
322 // Center progressOverlayLabel_ vertically within inputRowView_ frame. | 377 // Center progressOverlayLabel_ vertically within inputRowView_ frame. |
323 CGFloat progressHeight = ui::ResourceBundle::GetSharedInstance() | 378 CGFloat progressHeight = ui::ResourceBundle::GetSharedInstance() |
324 .GetFont(kProgressFontStyle) | 379 .GetFont(kProgressFontStyle) |
325 .GetHeight(); | 380 .GetHeight(); |
326 [progressOverlayLabel_ | 381 [progressOverlayLabel_ |
327 setFrame:NSMakeRect(0, ceil(NSMidY([inputRowView_ frame]) - | 382 setFrame:NSMakeRect(0, ceil(NSMidY([inputRowView_ frame]) - |
328 progressHeight / 2.0), | 383 progressHeight / 2.0), |
329 contentWidth, progressHeight)]; | 384 contentWidth, progressHeight)]; |
330 | 385 |
331 // Set dialog size. | 386 // Set dialog size. |
332 [[self view] | 387 [[self view] |
333 setFrameSize:NSMakeSize( | 388 setFrameSize:NSMakeSize( |
334 contentWidth + chrome_style::kHorizontalPadding * 2.0, | 389 contentWidth + chrome_style::kHorizontalPadding * 2.0, |
335 NSMaxY([titleLabel_ frame]) + | 390 NSMaxY([titleLabel_ frame]) + |
336 chrome_style::kTitleTopPadding)]; | 391 chrome_style::kTitleTopPadding)]; |
337 | 392 |
338 NSRect frameRect = | 393 NSRect frameRect = |
339 [[[self view] window] frameRectForContentRect:[[self view] frame]]; | 394 [[[self view] window] frameRectForContentRect:[[self view] frame]]; |
340 [[[self view] window] setFrame:frameRect display:display]; | 395 [[[self view] window] setFrame:frameRect display:display]; |
341 } | 396 } |
342 | 397 |
398 - (void)performLayout { | |
399 [self performLayoutAndDisplay:YES]; | |
groby-ooo-7-16
2015/03/26 01:35:27
You call this only once - can you just inline?
bondd
2015/03/26 02:54:29
Done.
| |
400 } | |
401 | |
343 - (void)loadView { | 402 - (void)loadView { |
344 autofill::CardUnmaskPromptController* controller = bridge_->GetController(); | 403 autofill::CardUnmaskPromptController* controller = bridge_->GetController(); |
345 DCHECK(controller); | 404 DCHECK(controller); |
346 | 405 |
347 base::scoped_nsobject<NSBox> mainView( | 406 base::scoped_nsobject<NSBox> mainView( |
348 [[NSBox alloc] initWithFrame:NSZeroRect]); | 407 [[NSBox alloc] initWithFrame:NSZeroRect]); |
349 [mainView setBoxType:NSBoxCustom]; | 408 [mainView setBoxType:NSBoxCustom]; |
350 [mainView setBorderType:NSNoBorder]; | 409 [mainView setBorderType:NSNoBorder]; |
351 [mainView setTitlePosition:NSNoTitle]; | 410 [mainView setTitlePosition:NSNoTitle]; |
352 [mainView | 411 [mainView |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
471 | 530 |
472 // Layout inputRowView_. | 531 // Layout inputRowView_. |
473 [CardUnmaskPromptViewCocoa sizeToFitView:inputRowView_]; | 532 [CardUnmaskPromptViewCocoa sizeToFitView:inputRowView_]; |
474 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:inputRowView_]; | 533 [CardUnmaskPromptViewCocoa verticallyCenterSubviewsInView:inputRowView_]; |
475 | 534 |
476 [self setView:mainView]; | 535 [self setView:mainView]; |
477 [self performLayoutAndDisplay:NO]; | 536 [self performLayoutAndDisplay:NO]; |
478 } | 537 } |
479 | 538 |
480 @end | 539 @end |
OLD | NEW |