OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/autofill/autofill_dialog_cocoa.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/mac/bundle_locations.h" | 8 #include "base/mac/bundle_locations.h" |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 - (NSSize)preferredSize { | 335 - (NSSize)preferredSize { |
336 NSSize contentSize; | 336 NSSize contentSize; |
337 // TODO(groby): Currently, keep size identical to main container. | 337 // TODO(groby): Currently, keep size identical to main container. |
338 // Change to allow autoresize of web contents. | 338 // Change to allow autoresize of web contents. |
339 contentSize = [mainContainer_ preferredSize]; | 339 contentSize = [mainContainer_ preferredSize]; |
340 | 340 |
341 NSSize headerSize = NSMakeSize(contentSize.width, kAccountChooserHeight); | 341 NSSize headerSize = NSMakeSize(contentSize.width, kAccountChooserHeight); |
342 NSSize size = NSMakeSize( | 342 NSSize size = NSMakeSize( |
343 std::max(contentSize.width, headerSize.width), | 343 std::max(contentSize.width, headerSize.width), |
344 contentSize.height + headerSize.height + kDetailTopPadding); | 344 contentSize.height + headerSize.height + autofill::kDetailTopPadding); |
345 size.width += 2 * chrome_style::kHorizontalPadding; | 345 size.width += 2 * chrome_style::kHorizontalPadding; |
346 size.height += chrome_style::kClientBottomPadding + | 346 size.height += chrome_style::kClientBottomPadding + |
347 chrome_style::kTitleTopPadding; | 347 chrome_style::kTitleTopPadding; |
348 | 348 |
349 // Show as much of the main view as is possible without going past the | 349 // Show as much of the main view as is possible without going past the |
350 // bottom of the browser window. | 350 // bottom of the browser window. |
351 NSRect dialogFrameRect = [[self window] frame]; | 351 NSRect dialogFrameRect = [[self window] frame]; |
352 NSRect browserFrameRect = | 352 NSRect browserFrameRect = |
353 [webContents_->GetView()->GetTopLevelNativeWindow() frame]; | 353 [webContents_->GetView()->GetTopLevelNativeWindow() frame]; |
354 dialogFrameRect.size.height = | 354 dialogFrameRect.size.height = |
355 NSMaxY(dialogFrameRect) - NSMinY(browserFrameRect); | 355 NSMaxY(dialogFrameRect) - NSMinY(browserFrameRect); |
356 dialogFrameRect = [[self window] contentRectForFrameRect:dialogFrameRect]; | 356 dialogFrameRect = [[self window] contentRectForFrameRect:dialogFrameRect]; |
357 size.height = std::min(NSHeight(dialogFrameRect), size.height); | 357 size.height = std::min(NSHeight(dialogFrameRect), size.height); |
358 | 358 |
359 if (![[overlayController_ view] isHidden]) { | 359 if (![[overlayController_ view] isHidden]) { |
360 CGFloat height = [overlayController_ heightForWidth:size.width]; | 360 CGFloat height = [overlayController_ heightForWidth:size.width]; |
361 // TODO(groby): This currently reserves size on top of the overlay image | 361 // TODO(groby): This currently reserves size on top of the overlay image |
362 // equivalent to the height of the header. Clarify with UX what the final | 362 // equivalent to the height of the header. Clarify with UX what the final |
363 // padding will be. | 363 // padding will be. |
364 if (height != 0.0) { | 364 if (height != 0.0) { |
365 size.height = height + headerSize.height + kDetailTopPadding; | 365 size.height = height + headerSize.height + autofill::kDetailTopPadding; |
366 } | 366 } |
367 } | 367 } |
368 | 368 |
369 return size; | 369 return size; |
370 } | 370 } |
371 | 371 |
372 - (void)performLayout { | 372 - (void)performLayout { |
373 NSRect contentRect = NSZeroRect; | 373 NSRect contentRect = NSZeroRect; |
374 contentRect.size = [self preferredSize]; | 374 contentRect.size = [self preferredSize]; |
375 NSRect clientRect = NSInsetRect( | 375 NSRect clientRect = NSInsetRect( |
376 contentRect, chrome_style::kHorizontalPadding, 0); | 376 contentRect, chrome_style::kHorizontalPadding, 0); |
377 clientRect.origin.y = chrome_style::kClientBottomPadding; | 377 clientRect.origin.y = chrome_style::kClientBottomPadding; |
378 clientRect.size.height -= chrome_style::kTitleTopPadding + | 378 clientRect.size.height -= chrome_style::kTitleTopPadding + |
379 chrome_style::kClientBottomPadding; | 379 chrome_style::kClientBottomPadding; |
380 | 380 |
381 NSRect headerRect, mainRect, dummyRect; | 381 NSRect headerRect, mainRect, dummyRect; |
382 NSDivideRect(clientRect, &headerRect, &mainRect, | 382 NSDivideRect(clientRect, &headerRect, &mainRect, |
383 kAccountChooserHeight, NSMinYEdge); | 383 kAccountChooserHeight, NSMinYEdge); |
384 NSDivideRect(mainRect, &dummyRect, &mainRect, | 384 NSDivideRect(mainRect, &dummyRect, &mainRect, |
385 kDetailTopPadding, NSMinYEdge); | 385 autofill::kDetailTopPadding, NSMinYEdge); |
386 | 386 |
387 [accountChooser_ setFrame:headerRect]; | 387 [accountChooser_ setFrame:headerRect]; |
388 if ([[signInContainer_ view] isHidden]) { | 388 if ([[signInContainer_ view] isHidden]) { |
389 [[mainContainer_ view] setFrame:mainRect]; | 389 [[mainContainer_ view] setFrame:mainRect]; |
390 [mainContainer_ performLayout]; | 390 [mainContainer_ performLayout]; |
391 } else { | 391 } else { |
392 [[signInContainer_ view] setFrame:mainRect]; | 392 [[signInContainer_ view] setFrame:mainRect]; |
393 } | 393 } |
394 | 394 |
395 // Loading shield has text centered in the content rect. | 395 // Loading shield has text centered in the content rect. |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
529 } | 529 } |
530 | 530 |
531 - (void)activateFieldForInput:(const autofill::DetailInput&)input { | 531 - (void)activateFieldForInput:(const autofill::DetailInput&)input { |
532 for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) { | 532 for (size_t i = autofill::SECTION_MIN; i <= autofill::SECTION_MAX; ++i) { |
533 autofill::DialogSection section = static_cast<autofill::DialogSection>(i); | 533 autofill::DialogSection section = static_cast<autofill::DialogSection>(i); |
534 [[mainContainer_ sectionForId:section] activateFieldForInput:input]; | 534 [[mainContainer_ sectionForId:section] activateFieldForInput:input]; |
535 } | 535 } |
536 } | 536 } |
537 | 537 |
538 @end | 538 @end |
OLD | NEW |