OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 7 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
8 | 8 |
9 #include "base/mac/bundle_locations.h" | 9 #include "base/mac/bundle_locations.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
325 // The observer can be removed both when closing the browser, and by just | 325 // The observer can be removed both when closing the browser, and by just |
326 // closing the avatar bubble. However, in the case of closing the browser, | 326 // closing the avatar bubble. However, in the case of closing the browser, |
327 // the avatar bubble will also be closed afterwards, resulting in a second | 327 // the avatar bubble will also be closed afterwards, resulting in a second |
328 // attempt to remove the observer. This ensures the observer is only | 328 // attempt to remove the observer. This ensures the observer is only |
329 // removed once. | 329 // removed once. |
330 bool token_observer_registered_; | 330 bool token_observer_registered_; |
331 | 331 |
332 DISALLOW_COPY_AND_ASSIGN(ActiveProfileObserverBridge); | 332 DISALLOW_COPY_AND_ASSIGN(ActiveProfileObserverBridge); |
333 }; | 333 }; |
334 | 334 |
335 // Custom button cell that adds a left padding to a button. | |
groby-ooo-7-16
2014/06/10 19:53:23
If you want to add padding, -drawInteriorWithFrame
noms (inactive)
2014/06/11 15:09:00
Hmm, I might have done it wrong, but -drawInterior
groby-ooo-7-16
2014/06/11 18:11:21
I'm not sure I follow - how is the button indented
noms (inactive)
2014/06/11 19:29:57
Yeah, my bad. This entire CL is "really annoying a
groby-ooo-7-16
2014/06/12 01:48:12
No, you're not. I misunderstood what you want padd
noms (inactive)
2014/06/16 19:17:10
Ok. The -drawInterior was almost perfect, but beca
| |
336 @interface LeftMarginButtonCell : NSButtonCell { | |
337 @protected | |
338 // Padding added to the left margin of the button. | |
339 int leftMarginSpacing_; | |
340 } | |
341 | |
342 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing; | |
343 @end | |
344 | |
345 @implementation LeftMarginButtonCell | |
346 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing { | |
347 if ((self = [super init])) { | |
348 leftMarginSpacing_ = leftMarginSpacing; | |
349 } | |
350 return self; | |
351 } | |
352 | |
353 - (NSRect)drawTitle:(NSAttributedString*)title | |
354 withFrame:(NSRect)frame | |
355 inView:(NSView*)controlView { | |
356 // The title frame origin isn't aware of the left margin spacing added | |
357 // in -drawImage, so it must be added when drawing the title as well. | |
358 frame.origin.x += leftMarginSpacing_; | |
359 frame.size.width -= leftMarginSpacing_; | |
360 return [super drawTitle:title withFrame:frame inView:controlView]; | |
361 } | |
362 | |
363 - (NSSize)cellSize { | |
364 NSSize buttonSize = [super cellSize]; | |
365 buttonSize.width += leftMarginSpacing_; | |
366 return buttonSize; | |
367 } | |
368 | |
369 @end | |
370 | |
371 // Custom button cell that adds a left padding before the button image, and | |
372 // a custom spacing between the button image and title. | |
373 @interface CustomPaddingImageButtonCell : LeftMarginButtonCell { | |
groby-ooo-7-16
2014/06/10 19:53:23
You might want to _just_ keep CustomPaddingImageBu
noms (inactive)
2014/06/11 15:09:00
Hmm, it's a little worse than that (I'm noticing t
groby-ooo-7-16
2014/06/11 18:11:22
You might want to. Also, with the image forced to
noms (inactive)
2014/06/11 19:29:57
Does the sketch above explain the padding? I was t
groby-ooo-7-16
2014/06/12 01:48:11
If you use the drawInteriorWithFrame approach, you
| |
374 @private | |
375 // Spacing between the cell image and title. | |
376 int imageTitleSpacing_; | |
377 } | |
378 | |
379 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing | |
380 imageTitleSpacing:(int)imageTitleSpacing; | |
381 @end | |
382 | |
383 @implementation CustomPaddingImageButtonCell | |
384 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing | |
385 imageTitleSpacing:(int)imageTitleSpacing { | |
386 if ((self = [super initWithLeftMarginSpacing:leftMarginSpacing])) { | |
387 imageTitleSpacing_ = imageTitleSpacing; | |
388 } | |
389 return self; | |
390 } | |
391 | |
392 - (NSRect)drawTitle:(NSAttributedString*)title | |
393 withFrame:(NSRect)frame | |
394 inView:(NSView*)controlView { | |
395 // The title frame origin isn't aware of the left margin spacing added | |
396 // in -drawImage, so it must be added when drawing the title as well. | |
397 frame.origin.x += imageTitleSpacing_; | |
398 frame.size.width -= imageTitleSpacing_; | |
399 return [super drawTitle:title withFrame:frame inView:controlView]; | |
400 } | |
401 | |
402 - (void)drawImage:(NSImage*)image | |
403 withFrame:(NSRect)frame | |
404 inView:(NSView*)controlView { | |
405 frame.origin.x = leftMarginSpacing_; | |
406 [super drawImage:image withFrame:frame inView:controlView]; | |
407 } | |
408 | |
409 - (NSSize)cellSize { | |
410 NSSize buttonSize = [super cellSize]; | |
411 buttonSize.width += imageTitleSpacing_; | |
412 return buttonSize; | |
413 } | |
414 | |
415 @end | |
416 | |
335 // A custom button that has a transparent backround. | 417 // A custom button that has a transparent backround. |
336 @interface TransparentBackgroundButton : NSButton | 418 @interface TransparentBackgroundButton : NSButton |
337 @end | 419 @end |
338 | 420 |
339 @implementation TransparentBackgroundButton | 421 @implementation TransparentBackgroundButton |
340 - (id)initWithFrame:(NSRect)frameRect { | 422 - (id)initWithFrame:(NSRect)frameRect { |
341 if ((self = [super initWithFrame:frameRect])) { | 423 if ((self = [super initWithFrame:frameRect])) { |
342 [self setBordered:NO]; | 424 [self setBordered:NO]; |
343 [self setFont:[NSFont labelFontOfSize:kTextFontSize]]; | 425 [self setFont:[NSFont labelFontOfSize:kTextFontSize]]; |
344 [self setButtonType:NSMomentaryChangeButton]; | 426 [self setButtonType:NSMomentaryChangeButton]; |
345 } | 427 } |
346 return self; | 428 return self; |
347 } | 429 } |
348 | 430 |
349 - (void)drawRect:(NSRect)dirtyRect { | 431 - (void)drawRect:(NSRect)dirtyRect { |
350 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.4f]; | 432 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.6f]; |
351 [backgroundColor setFill]; | 433 [backgroundColor setFill]; |
352 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop); | 434 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop); |
353 [super drawRect:dirtyRect]; | 435 [super drawRect:dirtyRect]; |
354 } | 436 } |
355 @end | 437 @end |
356 | 438 |
357 // A custom image control that shows a "Change" button when moused over. | 439 // A custom image control that shows a "Change" button when moused over. |
358 @interface EditableProfilePhoto : NSImageView { | 440 @interface EditableProfilePhoto : NSImageView { |
359 @private | 441 @private |
360 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. | 442 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
480 @implementation EditableProfileNameButton | 562 @implementation EditableProfileNameButton |
481 - (id)initWithFrame:(NSRect)frameRect | 563 - (id)initWithFrame:(NSRect)frameRect |
482 profile:(Profile*)profile | 564 profile:(Profile*)profile |
483 profileName:(NSString*)profileName | 565 profileName:(NSString*)profileName |
484 editingAllowed:(BOOL)editingAllowed | 566 editingAllowed:(BOOL)editingAllowed |
485 withController:(ProfileChooserController*)controller { | 567 withController:(ProfileChooserController*)controller { |
486 if ((self = [super initWithFrame:frameRect])) { | 568 if ((self = [super initWithFrame:frameRect])) { |
487 profile_ = profile; | 569 profile_ = profile; |
488 controller_ = controller; | 570 controller_ = controller; |
489 | 571 |
490 [self setBordered:NO]; | |
491 [self setFont:[NSFont labelFontOfSize:kTitleFontSize]]; | |
492 [self setAlignment:NSCenterTextAlignment]; | |
493 [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail]; | |
494 [self setTitle:profileName]; | |
495 | |
496 if (editingAllowed) { | 572 if (editingAllowed) { |
497 // Show an "edit" pencil icon when hovering over. In the default state, | 573 // Show an "edit" pencil icon when hovering over. In the default state, |
498 // we need to create an empty placeholder of the correct size, so that | 574 // we need to create an empty placeholder of the correct size, so that |
499 // the text doesn't jump around when the hovered icon appears. | 575 // the text doesn't jump around when the hovered icon appears. |
500 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 576 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
501 NSImage* hoverImage = rb->GetNativeImageNamed( | 577 NSImage* hoverImage = rb->GetNativeImageNamed( |
502 IDR_ICON_PROFILES_EDIT_HOVER).AsNSImage(); | 578 IDR_ICON_PROFILES_EDIT_HOVER).AsNSImage(); |
579 | |
580 // In order to center the button title, we need to add a left padding of | |
581 // the same width as the pencil icon. | |
582 base::scoped_nsobject<LeftMarginButtonCell> cell( | |
583 [[LeftMarginButtonCell alloc] | |
584 initWithLeftMarginSpacing:[hoverImage size].width]); | |
585 [self setCell:cell.get()]; | |
586 | |
503 NSImage* placeholder = [[NSImage alloc] initWithSize:[hoverImage size]]; | 587 NSImage* placeholder = [[NSImage alloc] initWithSize:[hoverImage size]]; |
504 [self setDefaultImage:placeholder]; | 588 [self setDefaultImage:placeholder]; |
505 [self setHoverImage:hoverImage]; | 589 [self setHoverImage:hoverImage]; |
506 [self setAlternateImage: | 590 [self setAlternateImage: |
507 rb->GetNativeImageNamed(IDR_ICON_PROFILES_EDIT_PRESSED).AsNSImage()]; | 591 rb->GetNativeImageNamed(IDR_ICON_PROFILES_EDIT_PRESSED).AsNSImage()]; |
508 [self setImagePosition:NSImageRight]; | 592 [self setImagePosition:NSImageRight]; |
509 [self setTarget:self]; | 593 [self setTarget:self]; |
510 [self setAction:@selector(showEditableView:)]; | 594 [self setAction:@selector(showEditableView:)]; |
511 | 595 |
512 // We need to subtract the width of the bezel from the frame rect, so that | 596 // We need to subtract the width of the bezel from the frame rect, so that |
(...skipping 10 matching lines...) Expand all Loading... | |
523 [profileNameTextField_ setAlignment:NSCenterTextAlignment]; | 607 [profileNameTextField_ setAlignment:NSCenterTextAlignment]; |
524 [[profileNameTextField_ cell] setWraps:NO]; | 608 [[profileNameTextField_ cell] setWraps:NO]; |
525 [[profileNameTextField_ cell] setLineBreakMode: | 609 [[profileNameTextField_ cell] setLineBreakMode: |
526 NSLineBreakByTruncatingTail]; | 610 NSLineBreakByTruncatingTail]; |
527 [profileNameTextField_ setDelegate:self]; | 611 [profileNameTextField_ setDelegate:self]; |
528 [self addSubview:profileNameTextField_]; | 612 [self addSubview:profileNameTextField_]; |
529 | 613 |
530 // Hide the textfield until the user clicks on the button. | 614 // Hide the textfield until the user clicks on the button. |
531 [profileNameTextField_ setHidden:YES]; | 615 [profileNameTextField_ setHidden:YES]; |
532 } | 616 } |
617 | |
618 [self setBordered:NO]; | |
619 [self setFont:[NSFont labelFontOfSize:kTitleFontSize]]; | |
620 [self setAlignment:NSCenterTextAlignment]; | |
621 [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail]; | |
622 [self setTitle:profileName]; | |
533 } | 623 } |
534 return self; | 624 return self; |
535 } | 625 } |
536 | 626 |
537 // NSTextField objects send an NSNotification to a delegate if | 627 // NSTextField objects send an NSNotification to a delegate if |
538 // it implements this method: | 628 // it implements this method: |
539 - (void)controlTextDidEndEditing:(NSNotification *)obj { | 629 - (void)controlTextDidEndEditing:(NSNotification *)obj { |
540 NSString* text = [profileNameTextField_ stringValue]; | 630 NSString* text = [profileNameTextField_ stringValue]; |
541 // Empty profile names are not allowed, and are treated as a cancel. | 631 // Empty profile names are not allowed, and are treated as a cancel. |
542 if ([text length] > 0) { | 632 if ([text length] > 0) { |
543 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text)); | 633 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text)); |
544 [controller_ | 634 [controller_ |
545 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME]; | 635 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME]; |
546 [self setTitle:text]; | 636 [self setTitle:text]; |
547 } | 637 } |
638 | |
639 [[self window] makeFirstResponder:nil]; | |
groby-ooo-7-16
2014/06/10 19:53:23
Are you sure you want the window to be first respo
noms (inactive)
2014/06/11 15:09:00
Giant incoming comment:
If I do what you suggeste
noms (inactive)
2014/06/11 15:09:00
Setting the next UI element to be the first respon
groby-ooo-7-16
2014/06/11 18:11:21
You know that you can actually specify the key vie
groby-ooo-7-16
2014/06/11 18:11:21
That's odd. Pressing the button should make the te
noms (inactive)
2014/06/11 19:29:57
I completely agree it should (which is why the cod
groby-ooo-7-16
2014/06/12 01:48:11
So there's something different if you don't change
noms (inactive)
2014/06/16 19:17:10
DONE! \o/
| |
548 [profileNameTextField_ setHidden:YES]; | 640 [profileNameTextField_ setHidden:YES]; |
549 [profileNameTextField_ resignFirstResponder]; | 641 [profileNameTextField_ setEnabled:NO]; |
groby-ooo-7-16
2014/06/10 19:53:23
You shouldn't need to disable if it's hidden.
| |
550 } | 642 } |
551 | 643 |
552 - (void)showEditableView:(id)sender { | 644 - (void)showEditableView:(id)sender { |
553 [profileNameTextField_ setHidden:NO]; | 645 [profileNameTextField_ setHidden:NO]; |
554 [profileNameTextField_ becomeFirstResponder]; | 646 [profileNameTextField_ setEnabled:YES]; |
647 [[self window] makeFirstResponder:profileNameTextField_]; | |
555 } | 648 } |
556 | 649 |
557 @end | 650 @end |
558 | |
559 // Custom button cell that adds a left padding before the button image, and | |
560 // a custom spacing between the button image and title. | |
561 @interface CustomPaddingImageButtonCell : NSButtonCell { | |
562 @private | |
563 // Padding between the left margin of the button and the cell image. | |
564 int leftMarginSpacing_; | |
565 // Spacing between the cell image and title. | |
566 int imageTitleSpacing_; | |
567 } | |
568 | |
569 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing | |
570 imageTitleSpacing:(int)imageTitleSpacing; | |
571 @end | |
572 | |
573 @implementation CustomPaddingImageButtonCell | |
574 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing | |
575 imageTitleSpacing:(int)imageTitleSpacing { | |
576 if ((self = [super init])) { | |
577 leftMarginSpacing_ = leftMarginSpacing; | |
578 imageTitleSpacing_ = imageTitleSpacing; | |
579 } | |
580 return self; | |
581 } | |
582 | |
583 - (NSRect)drawTitle:(NSAttributedString*)title | |
584 withFrame:(NSRect)frame | |
585 inView:(NSView*)controlView { | |
586 // The title frame origin isn't aware of the left margin spacing added | |
587 // in -drawImage, so it must be added when drawing the title as well. | |
588 frame.origin.x += leftMarginSpacing_ + imageTitleSpacing_; | |
589 frame.size.width -= (imageTitleSpacing_ + leftMarginSpacing_); | |
590 return [super drawTitle:title withFrame:frame inView:controlView]; | |
591 } | |
592 | |
593 - (void)drawImage:(NSImage*)image | |
594 withFrame:(NSRect)frame | |
595 inView:(NSView*)controlView { | |
596 frame.origin.x = leftMarginSpacing_; | |
597 [super drawImage:image withFrame:frame inView:controlView]; | |
598 } | |
599 | |
600 - (NSSize)cellSize { | |
601 NSSize buttonSize = [super cellSize]; | |
602 buttonSize.width += leftMarginSpacing_ + imageTitleSpacing_; | |
603 return buttonSize; | |
604 } | |
605 | |
606 @end | |
607 | 651 |
608 // A custom button that allows for setting a background color when hovered over. | 652 // A custom button that allows for setting a background color when hovered over. |
609 @interface BackgroundColorHoverButton : HoverImageButton { | 653 @interface BackgroundColorHoverButton : HoverImageButton { |
610 @private | 654 @private |
611 base::scoped_nsobject<NSColor> backgroundColor_; | 655 base::scoped_nsobject<NSColor> backgroundColor_; |
612 base::scoped_nsobject<NSColor> hoverColor_; | 656 base::scoped_nsobject<NSColor> hoverColor_; |
613 } | 657 } |
614 @end | 658 @end |
615 | 659 |
616 @implementation BackgroundColorHoverButton | 660 @implementation BackgroundColorHoverButton |
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
978 currentProfileView = [self createCurrentProfileView:item]; | 1022 currentProfileView = [self createCurrentProfileView:item]; |
979 enableLock = item.signed_in; | 1023 enableLock = item.signed_in; |
980 } else { | 1024 } else { |
981 [otherProfiles addObject:[self createOtherProfileView:i]]; | 1025 [otherProfiles addObject:[self createOtherProfileView:i]]; |
982 } | 1026 } |
983 } | 1027 } |
984 if (!currentProfileView) // Guest windows don't have an active profile. | 1028 if (!currentProfileView) // Guest windows don't have an active profile. |
985 currentProfileView = [self createGuestProfileView]; | 1029 currentProfileView = [self createGuestProfileView]; |
986 | 1030 |
987 // |yOffset| is the next position at which to draw in |container| | 1031 // |yOffset| is the next position at which to draw in |container| |
988 // coordinates. | 1032 // coordinates. Add a pixel offset so that the bottom option buttons don't |
989 CGFloat yOffset = 0; | 1033 // overlap the bubble's rounded corners. |
1034 CGFloat yOffset = 1; | |
990 | 1035 |
991 // Option buttons. Only available with the new profile management flag. | 1036 // Option buttons. Only available with the new profile management flag. |
992 if (switches::IsNewProfileManagement()) { | 1037 if (switches::IsNewProfileManagement()) { |
993 NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); | 1038 NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); |
994 NSView* optionsView = [self createOptionsViewWithRect:rect | 1039 NSView* optionsView = [self createOptionsViewWithRect:rect |
995 enableLock:enableLock]; | 1040 enableLock:enableLock]; |
996 [container addSubview:optionsView]; | 1041 [container addSubview:optionsView]; |
997 rect.origin.y = NSMaxY([optionsView frame]); | 1042 rect.origin.y = NSMaxY([optionsView frame]); |
998 | 1043 |
999 NSBox* separator = [self separatorWithFrame:rect]; | 1044 NSBox* separator = [self horizontalSeparatorWithFrame:rect]; |
1000 [container addSubview:separator]; | 1045 [container addSubview:separator]; |
1001 yOffset = NSMaxY([separator frame]); | 1046 yOffset = NSMaxY([separator frame]); |
1002 } | 1047 } |
1003 | 1048 |
1004 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && | 1049 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && |
1005 switches::IsFastUserSwitching()) { | 1050 switches::IsFastUserSwitching()) { |
1006 // Other profiles switcher. The profiles have already been sorted | 1051 // Other profiles switcher. The profiles have already been sorted |
1007 // by their y-coordinate, so they can be added in the existing order. | 1052 // by their y-coordinate, so they can be added in the existing order. |
1008 for (NSView *otherProfileView in otherProfiles.get()) { | 1053 for (NSView *otherProfileView in otherProfiles.get()) { |
1009 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1054 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
1010 [container addSubview:otherProfileView]; | 1055 [container addSubview:otherProfileView]; |
1011 yOffset = NSMaxY([otherProfileView frame]); | 1056 yOffset = NSMaxY([otherProfileView frame]); |
1012 | 1057 |
1013 NSBox* separator = | 1058 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
1014 [self separatorWithFrame:NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; | 1059 0, yOffset, kFixedMenuWidth, 0)]; |
1015 [container addSubview:separator]; | 1060 [container addSubview:separator]; |
1016 yOffset = NSMaxY([separator frame]); | 1061 yOffset = NSMaxY([separator frame]); |
1017 } | 1062 } |
1018 } else if (viewMode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { | 1063 } else if (viewMode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { |
1019 NSView* currentProfileAccountsView = [self createCurrentProfileAccountsView: | 1064 NSView* currentProfileAccountsView = [self createCurrentProfileAccountsView: |
1020 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; | 1065 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
1021 [container addSubview:currentProfileAccountsView]; | 1066 [container addSubview:currentProfileAccountsView]; |
1022 yOffset = NSMaxY([currentProfileAccountsView frame]); | 1067 yOffset = NSMaxY([currentProfileAccountsView frame]); |
1023 | 1068 |
1024 NSBox* accountsSeparator = [self separatorWithFrame: | 1069 NSBox* accountsSeparator = [self horizontalSeparatorWithFrame: |
1025 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; | 1070 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
1026 [container addSubview:accountsSeparator]; | 1071 [container addSubview:accountsSeparator]; |
1027 yOffset = NSMaxY([accountsSeparator frame]); | 1072 yOffset = NSMaxY([accountsSeparator frame]); |
1028 } | 1073 } |
1029 | 1074 |
1030 // For supervised users, add the disclaimer text. | 1075 // For supervised users, add the disclaimer text. |
1031 if (browser_->profile()->IsManaged()) { | 1076 if (browser_->profile()->IsManaged()) { |
1032 yOffset += kSmallVerticalSpacing; | 1077 yOffset += kSmallVerticalSpacing; |
1033 NSView* disclaimerContainer = [self createSupervisedUserDisclaimerView]; | 1078 NSView* disclaimerContainer = [self createSupervisedUserDisclaimerView]; |
1034 [disclaimerContainer setFrameOrigin:NSMakePoint(0, yOffset)]; | 1079 [disclaimerContainer setFrameOrigin:NSMakePoint(0, yOffset)]; |
1035 [container addSubview:disclaimerContainer]; | 1080 [container addSubview:disclaimerContainer]; |
1036 yOffset = NSMaxY([disclaimerContainer frame]); | 1081 yOffset = NSMaxY([disclaimerContainer frame]); |
1037 yOffset += kSmallVerticalSpacing; | 1082 yOffset += kSmallVerticalSpacing; |
1038 | 1083 |
1039 NSBox* separator = | 1084 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect( |
1040 [self separatorWithFrame:NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; | 1085 0, yOffset, kFixedMenuWidth, 0)]; |
1041 [container addSubview:separator]; | 1086 [container addSubview:separator]; |
1042 yOffset = NSMaxY([separator frame]); | 1087 yOffset = NSMaxY([separator frame]); |
1043 } | 1088 } |
1044 | 1089 |
1045 // Active profile card. | 1090 // Active profile card. |
1046 if (currentProfileView) { | 1091 if (currentProfileView) { |
1047 yOffset += kVerticalSpacing; | 1092 yOffset += kVerticalSpacing; |
1048 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1093 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
1049 [container addSubview:currentProfileView]; | 1094 [container addSubview:currentProfileView]; |
1050 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; | 1095 yOffset = NSMaxY([currentProfileView frame]) + kVerticalSpacing; |
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1415 [profileButton setBordered:NO]; | 1460 [profileButton setBordered:NO]; |
1416 [profileButton setTag:itemIndex]; | 1461 [profileButton setTag:itemIndex]; |
1417 [profileButton setTarget:self]; | 1462 [profileButton setTarget:self]; |
1418 [profileButton setAction:@selector(switchToProfile:)]; | 1463 [profileButton setAction:@selector(switchToProfile:)]; |
1419 | 1464 |
1420 return profileButton.autorelease(); | 1465 return profileButton.autorelease(); |
1421 } | 1466 } |
1422 | 1467 |
1423 - (NSView*)createOptionsViewWithRect:(NSRect)rect | 1468 - (NSView*)createOptionsViewWithRect:(NSRect)rect |
1424 enableLock:(BOOL)enableLock { | 1469 enableLock:(BOOL)enableLock { |
1425 int widthOfLockButton = enableLock? 2 * kHorizontalSpacing + 12 : 0; | 1470 int widthOfLockButton = enableLock ? 2 * kHorizontalSpacing + 14 : 0; |
1426 NSRect viewRect = NSMakeRect(0, 0, | 1471 NSRect viewRect = NSMakeRect(0, 0, |
1427 rect.size.width - widthOfLockButton, | 1472 rect.size.width - widthOfLockButton, |
1428 kBlueButtonHeight + kVerticalSpacing); | 1473 kBlueButtonHeight + kVerticalSpacing); |
1429 NSString* text = isGuestSession_ ? | 1474 NSString* text = isGuestSession_ ? |
1430 l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) : | 1475 l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) : |
1431 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU_BUTTON, | 1476 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU_BUTTON, |
1432 profiles::GetAvatarNameForProfile(browser_->profile())); | 1477 profiles::GetAvatarNameForProfile(browser_->profile())); |
1433 NSButton* notYouButton = | 1478 NSButton* notYouButton = |
1434 [self hoverButtonWithRect:viewRect | 1479 [self hoverButtonWithRect:viewRect |
1435 text:text | 1480 text:text |
1436 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR | 1481 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR |
1437 alternateImageResourceId:IDR_ICON_PROFILES_MENU_AVATAR | 1482 alternateImageResourceId:IDR_ICON_PROFILES_MENU_AVATAR |
1438 action:isGuestSession_? @selector(exitGuest:) : | 1483 action:isGuestSession_? @selector(exitGuest:) : |
1439 @selector(showUserManager:)]; | 1484 @selector(showUserManager:)]; |
1440 | 1485 |
1441 rect.size.height = NSMaxY([notYouButton frame]); | 1486 rect.size.height = NSMaxY([notYouButton frame]); |
1442 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); | 1487 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); |
1443 [container addSubview:notYouButton]; | 1488 [container addSubview:notYouButton]; |
1444 | 1489 |
1445 if (enableLock) { | 1490 if (enableLock) { |
1446 viewRect.origin.x = NSMaxX([notYouButton frame]); | 1491 viewRect.origin.x = NSMaxX([notYouButton frame]); |
1492 NSBox* separator = [self verticalSeparatorWithFrame:viewRect]; | |
1493 [container addSubview:separator]; | |
1494 | |
1495 viewRect.origin.x = NSMaxX([separator frame]); | |
1447 viewRect.size.width = widthOfLockButton; | 1496 viewRect.size.width = widthOfLockButton; |
1448 NSButton* lockButton = | 1497 NSButton* lockButton = |
1449 [self hoverButtonWithRect:viewRect | 1498 [self hoverButtonWithRect:viewRect |
1450 text:@"" | 1499 text:@"" |
1451 imageResourceId:IDR_ICON_PROFILES_MENU_LOCK | 1500 imageResourceId:IDR_ICON_PROFILES_MENU_LOCK |
1452 alternateImageResourceId:IDR_ICON_PROFILES_MENU_LOCK | 1501 alternateImageResourceId:IDR_ICON_PROFILES_MENU_LOCK |
1453 action:@selector(lockProfile:)]; | 1502 action:@selector(lockProfile:)]; |
1454 [container addSubview:lockButton]; | 1503 [container addSubview:lockButton]; |
1455 } | 1504 } |
1456 | 1505 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1544 source, false /* auto_close */, true /* is_constrained */), | 1593 source, false /* auto_close */, true /* is_constrained */), |
1545 content::Referrer(), | 1594 content::Referrer(), |
1546 content::PAGE_TRANSITION_AUTO_TOPLEVEL, | 1595 content::PAGE_TRANSITION_AUTO_TOPLEVEL, |
1547 std::string()); | 1596 std::string()); |
1548 NSView* webview = webContents_->GetNativeView(); | 1597 NSView* webview = webContents_->GetNativeView(); |
1549 [webview setFrameSize:NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight)]; | 1598 [webview setFrameSize:NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight)]; |
1550 [container addSubview:webview]; | 1599 [container addSubview:webview]; |
1551 yOffset = NSMaxY([webview frame]); | 1600 yOffset = NSMaxY([webview frame]); |
1552 | 1601 |
1553 // Adds the title card. | 1602 // Adds the title card. |
1554 NSBox* separator = [self separatorWithFrame: | 1603 NSBox* separator = [self horizontalSeparatorWithFrame: |
1555 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; | 1604 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; |
1556 [container addSubview:separator]; | 1605 [container addSubview:separator]; |
1557 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1606 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
1558 | 1607 |
1559 NSView* titleView = BuildTitleCard( | 1608 NSView* titleView = BuildTitleCard( |
1560 NSMakeRect(0, yOffset, kFixedGaiaViewWidth,0), | 1609 NSMakeRect(0, yOffset, kFixedGaiaViewWidth,0), |
1561 addSecondaryAccount ? IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE : | 1610 addSecondaryAccount ? IDS_PROFILES_GAIA_ADD_ACCOUNT_TITLE : |
1562 IDS_PROFILES_GAIA_SIGNIN_TITLE, | 1611 IDS_PROFILES_GAIA_SIGNIN_TITLE, |
1563 self /* backButtonTarget*/, | 1612 self /* backButtonTarget*/, |
1564 @selector(navigateBackFromSigninPage:) /* backButtonAction */); | 1613 @selector(navigateBackFromSigninPage:) /* backButtonAction */); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1616 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, | 1665 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, |
1617 GetDialogBackgroundColor(), nil /* text_color */); | 1666 GetDialogBackgroundColor(), nil /* text_color */); |
1618 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; | 1667 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
1619 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; | 1668 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
1620 contentView = contentLabel; | 1669 contentView = contentLabel; |
1621 } | 1670 } |
1622 [container addSubview:contentView]; | 1671 [container addSubview:contentView]; |
1623 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; | 1672 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; |
1624 | 1673 |
1625 // Adds the title card. | 1674 // Adds the title card. |
1626 NSBox* separator = [self separatorWithFrame: | 1675 NSBox* separator = [self horizontalSeparatorWithFrame: |
1627 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)]; | 1676 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)]; |
1628 [container addSubview:separator]; | 1677 [container addSubview:separator]; |
1629 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1678 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
1630 | 1679 |
1631 NSView* titleView = BuildTitleCard( | 1680 NSView* titleView = BuildTitleCard( |
1632 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), | 1681 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), |
1633 IDS_PROFILES_ACCOUNT_REMOVAL_TITLE, | 1682 IDS_PROFILES_ACCOUNT_REMOVAL_TITLE, |
1634 self /* backButtonTarget*/, | 1683 self /* backButtonTarget*/, |
1635 @selector(showAccountManagement:) /* backButtonAction */); | 1684 @selector(showAccountManagement:) /* backButtonAction */); |
1636 [container addSubview:titleView]; | 1685 [container addSubview:titleView]; |
(...skipping 30 matching lines...) Expand all Loading... | |
1667 NSString* contentStr = | 1716 NSString* contentStr = |
1668 l10n_util::GetNSString(IDS_PROFILES_END_PREVIEW_TEXT); | 1717 l10n_util::GetNSString(IDS_PROFILES_END_PREVIEW_TEXT); |
1669 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, | 1718 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, |
1670 GetDialogBackgroundColor(), nil /* text_color */); | 1719 GetDialogBackgroundColor(), nil /* text_color */); |
1671 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; | 1720 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
1672 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; | 1721 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
1673 [container addSubview:contentLabel]; | 1722 [container addSubview:contentLabel]; |
1674 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; | 1723 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; |
1675 | 1724 |
1676 // Adds the title card. | 1725 // Adds the title card. |
1677 NSBox* separator = [self separatorWithFrame: | 1726 NSBox* separator = [self horizontalSeparatorWithFrame: |
1678 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0)]; | 1727 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0)]; |
1679 [container addSubview:separator]; | 1728 [container addSubview:separator]; |
1680 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1729 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
1681 | 1730 |
1682 NSView* titleView = BuildTitleCard( | 1731 NSView* titleView = BuildTitleCard( |
1683 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0), | 1732 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0), |
1684 IDS_PROFILES_END_PREVIEW, | 1733 IDS_PROFILES_END_PREVIEW, |
1685 self /* backButtonTarget*/, | 1734 self /* backButtonTarget*/, |
1686 @selector(showSendFeedbackTutorial:) /* backButtonAction */); | 1735 @selector(showSendFeedbackTutorial:) /* backButtonAction */); |
1687 [container addSubview:titleView]; | 1736 [container addSubview:titleView]; |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1782 [button addSubview:deleteButton]; | 1831 [button addSubview:deleteButton]; |
1783 return button.autorelease(); | 1832 return button.autorelease(); |
1784 } | 1833 } |
1785 | 1834 |
1786 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { | 1835 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { |
1787 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); | 1836 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); |
1788 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; | 1837 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; |
1789 } | 1838 } |
1790 | 1839 |
1791 @end | 1840 @end |
OLD | NEW |