Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: chrome/browser/ui/cocoa/profiles/profile_chooser_controller.mm

Issue 323143004: [Mac] Misc fixes for the new avatar bubble (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: unbork rebase and fix unittest Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
332 // The observer can be removed both when closing the browser, and by just 332 // The observer can be removed both when closing the browser, and by just
333 // closing the avatar bubble. However, in the case of closing the browser, 333 // closing the avatar bubble. However, in the case of closing the browser,
334 // the avatar bubble will also be closed afterwards, resulting in a second 334 // the avatar bubble will also be closed afterwards, resulting in a second
335 // attempt to remove the observer. This ensures the observer is only 335 // attempt to remove the observer. This ensures the observer is only
336 // removed once. 336 // removed once.
337 bool token_observer_registered_; 337 bool token_observer_registered_;
338 338
339 DISALLOW_COPY_AND_ASSIGN(ActiveProfileObserverBridge); 339 DISALLOW_COPY_AND_ASSIGN(ActiveProfileObserverBridge);
340 }; 340 };
341 341
342 // Custom button cell that adds a left padding before the button image, and
343 // a custom spacing between the button image and title.
344 @interface CustomPaddingImageButtonCell : NSButtonCell {
345 @private
346 // Padding added to the left margin of the button.
347 int leftMarginSpacing_;
348 // Spacing between the cell image and title.
349 int imageTitleSpacing_;
350 }
351
352 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing
353 imageTitleSpacing:(int)imageTitleSpacing;
354 @end
355
356 @implementation CustomPaddingImageButtonCell
357 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing
358 imageTitleSpacing:(int)imageTitleSpacing {
359 if ((self = [super init])) {
360 leftMarginSpacing_ = leftMarginSpacing;
361 imageTitleSpacing_ = imageTitleSpacing;
362 }
363 return self;
364 }
365
366 - (NSRect)drawTitle:(NSAttributedString*)title
367 withFrame:(NSRect)frame
368 inView:(NSView*)controlView {
369 NSRect marginRect;
370 NSDivideRect(frame, &marginRect, &frame, leftMarginSpacing_, NSMinXEdge);
371
372 // The title frame origin isn't aware of the left margin spacing added
373 // in -drawImage, so it must be added when drawing the title as well.
374 if ([self imagePosition] == NSImageLeft)
375 NSDivideRect(frame, &marginRect, &frame, imageTitleSpacing_, NSMinXEdge);
376
377 return [super drawTitle:title withFrame:frame inView:controlView];
378 }
379
380 - (void)drawImage:(NSImage*)image
381 withFrame:(NSRect)frame
382 inView:(NSView*)controlView {
383 if ([self imagePosition] == NSImageLeft)
384 frame.origin.x = leftMarginSpacing_;
385 [super drawImage:image withFrame:frame inView:controlView];
386 }
387
388 - (NSSize)cellSize {
389 NSSize buttonSize = [super cellSize];
390 buttonSize.width += leftMarginSpacing_;
391 if ([self imagePosition] == NSImageLeft)
392 buttonSize.width += imageTitleSpacing_;
393 return buttonSize;
394 }
395
396 @end
397
342 // A custom button that has a transparent backround. 398 // A custom button that has a transparent backround.
343 @interface TransparentBackgroundButton : NSButton 399 @interface TransparentBackgroundButton : NSButton
344 @end 400 @end
345 401
346 @implementation TransparentBackgroundButton 402 @implementation TransparentBackgroundButton
347 - (id)initWithFrame:(NSRect)frameRect { 403 - (id)initWithFrame:(NSRect)frameRect {
348 if ((self = [super initWithFrame:frameRect])) { 404 if ((self = [super initWithFrame:frameRect])) {
349 [self setBordered:NO]; 405 [self setBordered:NO];
350 [self setFont:[NSFont labelFontOfSize:kTextFontSize]]; 406 [self setFont:[NSFont labelFontOfSize:kTextFontSize]];
351 [self setButtonType:NSMomentaryChangeButton]; 407 [self setButtonType:NSMomentaryChangeButton];
352 } 408 }
353 return self; 409 return self;
354 } 410 }
355 411
356 - (void)drawRect:(NSRect)dirtyRect { 412 - (void)drawRect:(NSRect)dirtyRect {
357 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.4f]; 413 NSColor* backgroundColor = [NSColor colorWithCalibratedWhite:1 alpha:0.6f];
358 [backgroundColor setFill]; 414 [backgroundColor setFill];
359 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop); 415 NSRectFillUsingOperation(dirtyRect, NSCompositeSourceAtop);
360 [super drawRect:dirtyRect]; 416 [super drawRect:dirtyRect];
361 } 417 }
362 @end 418 @end
363 419
364 // A custom image control that shows a "Change" button when moused over. 420 // A custom image control that shows a "Change" button when moused over.
365 @interface EditableProfilePhoto : NSImageView { 421 @interface EditableProfilePhoto : NSImageView {
366 @private 422 @private
367 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController. 423 AvatarMenu* avatarMenu_; // Weak; Owned by ProfileChooserController.
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 [button setImage:ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed( 513 [button setImage:ui::ResourceBundle::GetSharedInstance().GetNativeImageNamed(
458 IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()]; 514 IDR_ICON_PROFILES_EDIT_CAMERA).AsNSImage()];
459 [button setImagePosition:NSImageOnly]; 515 [button setImagePosition:NSImageOnly];
460 [button setTarget:self]; 516 [button setTarget:self];
461 [button setAction:@selector(editPhoto:)]; 517 [button setAction:@selector(editPhoto:)];
462 return button; 518 return button;
463 } 519 }
464 @end 520 @end
465 521
466 // A custom text control that turns into a textfield for editing when clicked. 522 // A custom text control that turns into a textfield for editing when clicked.
467 @interface EditableProfileNameButton : HoverImageButton<NSTextFieldDelegate> { 523 @interface EditableProfileNameButton : HoverImageButton {
468 @private 524 @private
469 base::scoped_nsobject<NSTextField> profileNameTextField_; 525 base::scoped_nsobject<NSTextField> profileNameTextField_;
470 Profile* profile_; // Weak. 526 Profile* profile_; // Weak.
471 ProfileChooserController* controller_; 527 ProfileChooserController* controller_;
472 } 528 }
473 529
474 - (id)initWithFrame:(NSRect)frameRect 530 - (id)initWithFrame:(NSRect)frameRect
475 profile:(Profile*)profile 531 profile:(Profile*)profile
476 profileName:(NSString*)profileName 532 profileName:(NSString*)profileName
477 editingAllowed:(BOOL)editingAllowed 533 editingAllowed:(BOOL)editingAllowed
478 withController:(ProfileChooserController*)controller; 534 withController:(ProfileChooserController*)controller;
479 535
480 // Called when the button is clicked. 536 // Called when the button is clicked.
481 - (void)showEditableView:(id)sender; 537 - (void)showEditableView:(id)sender;
482 538
483 // Called when the user presses "Enter" in the textfield. 539 // Called when enter is pressed in the text field.
484 - (void)controlTextDidEndEditing:(NSNotification *)obj; 540 - (void)saveProfileName:(id)sender;
541
485 @end 542 @end
486 543
487 @implementation EditableProfileNameButton 544 @implementation EditableProfileNameButton
488 - (id)initWithFrame:(NSRect)frameRect 545 - (id)initWithFrame:(NSRect)frameRect
489 profile:(Profile*)profile 546 profile:(Profile*)profile
490 profileName:(NSString*)profileName 547 profileName:(NSString*)profileName
491 editingAllowed:(BOOL)editingAllowed 548 editingAllowed:(BOOL)editingAllowed
492 withController:(ProfileChooserController*)controller { 549 withController:(ProfileChooserController*)controller {
493 if ((self = [super initWithFrame:frameRect])) { 550 if ((self = [super initWithFrame:frameRect])) {
494 profile_ = profile; 551 profile_ = profile;
495 controller_ = controller; 552 controller_ = controller;
496 553
497 [self setBordered:NO];
498 [self setFont:[NSFont labelFontOfSize:kTitleFontSize]];
499 [self setAlignment:NSCenterTextAlignment];
500 [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail];
501 [self setTitle:profileName];
502
503 if (editingAllowed) { 554 if (editingAllowed) {
504 // Show an "edit" pencil icon when hovering over. In the default state, 555 // Show an "edit" pencil icon when hovering over. In the default state,
505 // we need to create an empty placeholder of the correct size, so that 556 // we need to create an empty placeholder of the correct size, so that
506 // the text doesn't jump around when the hovered icon appears. 557 // the text doesn't jump around when the hovered icon appears.
507 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 558 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance();
508 NSImage* hoverImage = rb->GetNativeImageNamed( 559 NSImage* hoverImage = rb->GetNativeImageNamed(
509 IDR_ICON_PROFILES_EDIT_HOVER).AsNSImage(); 560 IDR_ICON_PROFILES_EDIT_HOVER).AsNSImage();
561
562 // In order to center the button title, we need to add a left padding of
563 // the same width as the pencil icon.
564 base::scoped_nsobject<CustomPaddingImageButtonCell> cell(
565 [[CustomPaddingImageButtonCell alloc]
566 initWithLeftMarginSpacing:[hoverImage size].width
567 imageTitleSpacing:0]);
568 [self setCell:cell.get()];
569
510 NSImage* placeholder = [[NSImage alloc] initWithSize:[hoverImage size]]; 570 NSImage* placeholder = [[NSImage alloc] initWithSize:[hoverImage size]];
511 [self setDefaultImage:placeholder]; 571 [self setDefaultImage:placeholder];
512 [self setHoverImage:hoverImage]; 572 [self setHoverImage:hoverImage];
513 [self setAlternateImage: 573 [self setAlternateImage:
514 rb->GetNativeImageNamed(IDR_ICON_PROFILES_EDIT_PRESSED).AsNSImage()]; 574 rb->GetNativeImageNamed(IDR_ICON_PROFILES_EDIT_PRESSED).AsNSImage()];
515 [self setImagePosition:NSImageRight]; 575 [self setImagePosition:NSImageRight];
516 [self setTarget:self]; 576 [self setTarget:self];
517 [self setAction:@selector(showEditableView:)]; 577 [self setAction:@selector(showEditableView:)];
518 578
519 // We need to subtract the width of the bezel from the frame rect, so that 579 // We need to subtract the width of the bezel from the frame rect, so that
520 // the textfield can take the exact same space as the button. 580 // the textfield can take the exact same space as the button.
521 frameRect.size.height -= 2 * kBezelThickness; 581 frameRect.size.height -= 2 * kBezelThickness;
522 frameRect.origin = NSMakePoint(0, kBezelThickness); 582 frameRect.origin = NSMakePoint(0, kBezelThickness);
523 profileNameTextField_.reset( 583 profileNameTextField_.reset(
524 [[NSTextField alloc] initWithFrame:frameRect]); 584 [[NSTextField alloc] initWithFrame:frameRect]);
525 [profileNameTextField_ setStringValue:profileName]; 585 [profileNameTextField_ setStringValue:profileName];
526 [profileNameTextField_ setFont:[NSFont labelFontOfSize:kTitleFontSize]]; 586 [profileNameTextField_ setFont:[NSFont labelFontOfSize:kTitleFontSize]];
527 [profileNameTextField_ setEditable:YES]; 587 [profileNameTextField_ setEditable:YES];
528 [profileNameTextField_ setDrawsBackground:YES]; 588 [profileNameTextField_ setDrawsBackground:YES];
529 [profileNameTextField_ setBezeled:YES]; 589 [profileNameTextField_ setBezeled:YES];
530 [profileNameTextField_ setAlignment:NSCenterTextAlignment]; 590 [profileNameTextField_ setAlignment:NSCenterTextAlignment];
531 [[profileNameTextField_ cell] setWraps:NO]; 591 [[profileNameTextField_ cell] setWraps:NO];
532 [[profileNameTextField_ cell] setLineBreakMode: 592 [[profileNameTextField_ cell] setLineBreakMode:
533 NSLineBreakByTruncatingTail]; 593 NSLineBreakByTruncatingTail];
534 [profileNameTextField_ setDelegate:self];
535 [self addSubview:profileNameTextField_]; 594 [self addSubview:profileNameTextField_];
595 [profileNameTextField_ setTarget:self];
596 [profileNameTextField_ setAction:@selector(saveProfileName:)];
536 597
537 // Hide the textfield until the user clicks on the button. 598 // Hide the textfield until the user clicks on the button.
538 [profileNameTextField_ setHidden:YES]; 599 [profileNameTextField_ setHidden:YES];
539 } 600 }
601
602 [self setBordered:NO];
603 [self setFont:[NSFont labelFontOfSize:kTitleFontSize]];
604 [self setAlignment:NSCenterTextAlignment];
605 [[self cell] setLineBreakMode:NSLineBreakByTruncatingTail];
606 [self setTitle:profileName];
540 } 607 }
541 return self; 608 return self;
542 } 609 }
543 610
544 // NSTextField objects send an NSNotification to a delegate if 611 - (void)saveProfileName:(id)sender {
545 // it implements this method:
546 - (void)controlTextDidEndEditing:(NSNotification *)obj {
547 NSString* text = [profileNameTextField_ stringValue]; 612 NSString* text = [profileNameTextField_ stringValue];
548 // Empty profile names are not allowed, and are treated as a cancel. 613 // Empty profile names are not allowed, and are treated as a cancel.
549 if ([text length] > 0) { 614 if ([text length] > 0) {
550 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text)); 615 profiles::UpdateProfileName(profile_, base::SysNSStringToUTF16(text));
551 [controller_ 616 [controller_
552 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME]; 617 postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_EDIT_NAME];
553 [self setTitle:text]; 618 [self setTitle:text];
554 } 619 }
555 [profileNameTextField_ setHidden:YES]; 620 [profileNameTextField_ setHidden:YES];
556 [profileNameTextField_ resignFirstResponder];
557 } 621 }
558 622
559 - (void)showEditableView:(id)sender { 623 - (void)showEditableView:(id)sender {
560 [profileNameTextField_ setHidden:NO]; 624 [profileNameTextField_ setHidden:NO];
561 [profileNameTextField_ becomeFirstResponder]; 625 [[self window] makeFirstResponder:profileNameTextField_];
562 } 626 }
563 627
564 @end 628 @end
565
566 // Custom button cell that adds a left padding before the button image, and
567 // a custom spacing between the button image and title.
568 @interface CustomPaddingImageButtonCell : NSButtonCell {
569 @private
570 // Padding between the left margin of the button and the cell image.
571 int leftMarginSpacing_;
572 // Spacing between the cell image and title.
573 int imageTitleSpacing_;
574 }
575
576 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing
577 imageTitleSpacing:(int)imageTitleSpacing;
578 @end
579
580 @implementation CustomPaddingImageButtonCell
581 - (id)initWithLeftMarginSpacing:(int)leftMarginSpacing
582 imageTitleSpacing:(int)imageTitleSpacing {
583 if ((self = [super init])) {
584 leftMarginSpacing_ = leftMarginSpacing;
585 imageTitleSpacing_ = imageTitleSpacing;
586 }
587 return self;
588 }
589
590 - (NSRect)drawTitle:(NSAttributedString*)title
591 withFrame:(NSRect)frame
592 inView:(NSView*)controlView {
593 // The title frame origin isn't aware of the left margin spacing added
594 // in -drawImage, so it must be added when drawing the title as well.
595 frame.origin.x += leftMarginSpacing_ + imageTitleSpacing_;
596 frame.size.width -= (imageTitleSpacing_ + leftMarginSpacing_);
597 return [super drawTitle:title withFrame:frame inView:controlView];
598 }
599
600 - (void)drawImage:(NSImage*)image
601 withFrame:(NSRect)frame
602 inView:(NSView*)controlView {
603 frame.origin.x = leftMarginSpacing_;
604 [super drawImage:image withFrame:frame inView:controlView];
605 }
606
607 - (NSSize)cellSize {
608 NSSize buttonSize = [super cellSize];
609 buttonSize.width += leftMarginSpacing_ + imageTitleSpacing_;
610 return buttonSize;
611 }
612
613 @end
614 629
615 // A custom button that allows for setting a background color when hovered over. 630 // A custom button that allows for setting a background color when hovered over.
616 @interface BackgroundColorHoverButton : HoverImageButton { 631 @interface BackgroundColorHoverButton : HoverImageButton {
617 @private 632 @private
618 base::scoped_nsobject<NSColor> backgroundColor_; 633 base::scoped_nsobject<NSColor> backgroundColor_;
619 base::scoped_nsobject<NSColor> hoverColor_; 634 base::scoped_nsobject<NSColor> hoverColor_;
620 } 635 }
621 @end 636 @end
622 637
623 @implementation BackgroundColorHoverButton 638 @implementation BackgroundColorHoverButton
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 currentProfileView = [self createCurrentProfileView:item]; 1014 currentProfileView = [self createCurrentProfileView:item];
1000 enableLock = item.signed_in; 1015 enableLock = item.signed_in;
1001 } else { 1016 } else {
1002 [otherProfiles addObject:[self createOtherProfileView:i]]; 1017 [otherProfiles addObject:[self createOtherProfileView:i]];
1003 } 1018 }
1004 } 1019 }
1005 if (!currentProfileView) // Guest windows don't have an active profile. 1020 if (!currentProfileView) // Guest windows don't have an active profile.
1006 currentProfileView = [self createGuestProfileView]; 1021 currentProfileView = [self createGuestProfileView];
1007 1022
1008 // |yOffset| is the next position at which to draw in |container| 1023 // |yOffset| is the next position at which to draw in |container|
1009 // coordinates. 1024 // coordinates. Add a pixel offset so that the bottom option buttons don't
1010 CGFloat yOffset = 0; 1025 // overlap the bubble's rounded corners.
1026 CGFloat yOffset = 1;
1011 1027
1012 // Option buttons. Only available with the new profile management flag. 1028 // Option buttons. Only available with the new profile management flag.
1013 if (switches::IsNewProfileManagement()) { 1029 if (switches::IsNewProfileManagement()) {
1014 NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0); 1030 NSRect rect = NSMakeRect(0, yOffset, kFixedMenuWidth, 0);
1015 NSView* optionsView = [self createOptionsViewWithRect:rect 1031 NSView* optionsView = [self createOptionsViewWithRect:rect
1016 enableLock:enableLock]; 1032 enableLock:enableLock];
1017 [container addSubview:optionsView]; 1033 [container addSubview:optionsView];
1018 rect.origin.y = NSMaxY([optionsView frame]); 1034 rect.origin.y = NSMaxY([optionsView frame]);
1019 1035
1020 NSBox* separator = [self separatorWithFrame:rect]; 1036 NSBox* separator = [self horizontalSeparatorWithFrame:rect];
1021 [container addSubview:separator]; 1037 [container addSubview:separator];
1022 yOffset = NSMaxY([separator frame]); 1038 yOffset = NSMaxY([separator frame]);
1023 } 1039 }
1024 1040
1025 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER && 1041 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER &&
1026 switches::IsFastUserSwitching()) { 1042 switches::IsFastUserSwitching()) {
1027 // Other profiles switcher. The profiles have already been sorted 1043 // Other profiles switcher. The profiles have already been sorted
1028 // by their y-coordinate, so they can be added in the existing order. 1044 // by their y-coordinate, so they can be added in the existing order.
1029 for (NSView *otherProfileView in otherProfiles.get()) { 1045 for (NSView *otherProfileView in otherProfiles.get()) {
1030 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; 1046 [otherProfileView setFrameOrigin:NSMakePoint(0, yOffset)];
1031 [container addSubview:otherProfileView]; 1047 [container addSubview:otherProfileView];
1032 yOffset = NSMaxY([otherProfileView frame]); 1048 yOffset = NSMaxY([otherProfileView frame]);
1033 1049
1034 NSBox* separator = 1050 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect(
1035 [self separatorWithFrame:NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; 1051 0, yOffset, kFixedMenuWidth, 0)];
1036 [container addSubview:separator]; 1052 [container addSubview:separator];
1037 yOffset = NSMaxY([separator frame]); 1053 yOffset = NSMaxY([separator frame]);
1038 } 1054 }
1039 } 1055 }
1040 1056
1041 // For supervised users, add the disclaimer text. 1057 // For supervised users, add the disclaimer text.
1042 if (browser_->profile()->IsSupervised()) { 1058 if (browser_->profile()->IsSupervised()) {
1043 yOffset += kSmallVerticalSpacing; 1059 yOffset += kSmallVerticalSpacing;
1044 NSView* disclaimerContainer = [self createSupervisedUserDisclaimerView]; 1060 NSView* disclaimerContainer = [self createSupervisedUserDisclaimerView];
1045 [disclaimerContainer setFrameOrigin:NSMakePoint(0, yOffset)]; 1061 [disclaimerContainer setFrameOrigin:NSMakePoint(0, yOffset)];
1046 [container addSubview:disclaimerContainer]; 1062 [container addSubview:disclaimerContainer];
1047 yOffset = NSMaxY([disclaimerContainer frame]); 1063 yOffset = NSMaxY([disclaimerContainer frame]);
1048 yOffset += kSmallVerticalSpacing; 1064 yOffset += kSmallVerticalSpacing;
1049 1065
1050 NSBox* separator = 1066 NSBox* separator = [self horizontalSeparatorWithFrame:NSMakeRect(
1051 [self separatorWithFrame:NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; 1067 0, yOffset, kFixedMenuWidth, 0)];
1052 [container addSubview:separator]; 1068 [container addSubview:separator];
1053 yOffset = NSMaxY([separator frame]); 1069 yOffset = NSMaxY([separator frame]);
1054 } 1070 }
1055 1071
1056 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) { 1072 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT) {
1057 NSView* currentProfileAccountsView = [self createCurrentProfileAccountsView: 1073 NSView* currentProfileAccountsView = [self createCurrentProfileAccountsView:
1058 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; 1074 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)];
1059 [container addSubview:currentProfileAccountsView]; 1075 [container addSubview:currentProfileAccountsView];
1060 yOffset = NSMaxY([currentProfileAccountsView frame]); 1076 yOffset = NSMaxY([currentProfileAccountsView frame]);
1061 1077
1062 NSBox* accountsSeparator = [self separatorWithFrame: 1078 NSBox* accountsSeparator = [self horizontalSeparatorWithFrame:
1063 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; 1079 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)];
1064 [container addSubview:accountsSeparator]; 1080 [container addSubview:accountsSeparator];
1065 yOffset = NSMaxY([accountsSeparator frame]); 1081 yOffset = NSMaxY([accountsSeparator frame]);
1066 } 1082 }
1067 1083
1068 // Active profile card. 1084 // Active profile card.
1069 if (currentProfileView) { 1085 if (currentProfileView) {
1070 yOffset += kVerticalSpacing; 1086 yOffset += kVerticalSpacing;
1071 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; 1087 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)];
1072 [container addSubview:currentProfileView]; 1088 [container addSubview:currentProfileView];
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1439 [profileButton setBordered:NO]; 1455 [profileButton setBordered:NO];
1440 [profileButton setTag:itemIndex]; 1456 [profileButton setTag:itemIndex];
1441 [profileButton setTarget:self]; 1457 [profileButton setTarget:self];
1442 [profileButton setAction:@selector(switchToProfile:)]; 1458 [profileButton setAction:@selector(switchToProfile:)];
1443 1459
1444 return profileButton.autorelease(); 1460 return profileButton.autorelease();
1445 } 1461 }
1446 1462
1447 - (NSView*)createOptionsViewWithRect:(NSRect)rect 1463 - (NSView*)createOptionsViewWithRect:(NSRect)rect
1448 enableLock:(BOOL)enableLock { 1464 enableLock:(BOOL)enableLock {
1449 int widthOfLockButton = enableLock? 2 * kHorizontalSpacing + 12 : 0; 1465 int widthOfLockButton = enableLock ? 2 * kHorizontalSpacing + 14 : 0;
1450 NSRect viewRect = NSMakeRect(0, 0, 1466 NSRect viewRect = NSMakeRect(0, 0,
1451 rect.size.width - widthOfLockButton, 1467 rect.size.width - widthOfLockButton,
1452 kBlueButtonHeight + kVerticalSpacing); 1468 kBlueButtonHeight + kVerticalSpacing);
1453 NSString* text = isGuestSession_ ? 1469 NSString* text = isGuestSession_ ?
1454 l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) : 1470 l10n_util::GetNSString(IDS_PROFILES_EXIT_GUEST) :
1455 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU_BUTTON, 1471 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU_BUTTON,
1456 profiles::GetAvatarNameForProfile(browser_->profile())); 1472 profiles::GetAvatarNameForProfile(browser_->profile()));
1457 NSButton* notYouButton = 1473 NSButton* notYouButton =
1458 [self hoverButtonWithRect:viewRect 1474 [self hoverButtonWithRect:viewRect
1459 text:text 1475 text:text
1460 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR 1476 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
1461 alternateImageResourceId:IDR_ICON_PROFILES_MENU_AVATAR 1477 alternateImageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
1462 action:isGuestSession_? @selector(exitGuest:) : 1478 action:isGuestSession_? @selector(exitGuest:) :
1463 @selector(showUserManager:)]; 1479 @selector(showUserManager:)];
1464 1480
1465 rect.size.height = NSMaxY([notYouButton frame]); 1481 rect.size.height = NSMaxY([notYouButton frame]);
1466 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); 1482 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]);
1467 [container addSubview:notYouButton]; 1483 [container addSubview:notYouButton];
1468 1484
1469 if (enableLock) { 1485 if (enableLock) {
1470 viewRect.origin.x = NSMaxX([notYouButton frame]); 1486 viewRect.origin.x = NSMaxX([notYouButton frame]);
1487 NSBox* separator = [self verticalSeparatorWithFrame:viewRect];
1488 [container addSubview:separator];
1489
1490 viewRect.origin.x = NSMaxX([separator frame]);
1471 viewRect.size.width = widthOfLockButton; 1491 viewRect.size.width = widthOfLockButton;
1472 NSButton* lockButton = 1492 NSButton* lockButton =
1473 [self hoverButtonWithRect:viewRect 1493 [self hoverButtonWithRect:viewRect
1474 text:@"" 1494 text:@""
1475 imageResourceId:IDR_ICON_PROFILES_MENU_LOCK 1495 imageResourceId:IDR_ICON_PROFILES_MENU_LOCK
1476 alternateImageResourceId:IDR_ICON_PROFILES_MENU_LOCK 1496 alternateImageResourceId:IDR_ICON_PROFILES_MENU_LOCK
1477 action:@selector(lockProfile:)]; 1497 action:@selector(lockProfile:)];
1478 [container addSubview:lockButton]; 1498 [container addSubview:lockButton];
1479 } 1499 }
1480 1500
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1600 webContents_->GetController().LoadURL(url, 1620 webContents_->GetController().LoadURL(url,
1601 content::Referrer(), 1621 content::Referrer(),
1602 content::PAGE_TRANSITION_AUTO_TOPLEVEL, 1622 content::PAGE_TRANSITION_AUTO_TOPLEVEL,
1603 std::string()); 1623 std::string());
1604 NSView* webview = webContents_->GetNativeView(); 1624 NSView* webview = webContents_->GetNativeView();
1605 [webview setFrameSize:NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight)]; 1625 [webview setFrameSize:NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight)];
1606 [container addSubview:webview]; 1626 [container addSubview:webview];
1607 yOffset = NSMaxY([webview frame]); 1627 yOffset = NSMaxY([webview frame]);
1608 1628
1609 // Adds the title card. 1629 // Adds the title card.
1610 NSBox* separator = [self separatorWithFrame: 1630 NSBox* separator = [self horizontalSeparatorWithFrame:
1611 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; 1631 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)];
1612 [container addSubview:separator]; 1632 [container addSubview:separator];
1613 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; 1633 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing;
1614 1634
1615 NSView* titleView = BuildTitleCard( 1635 NSView* titleView = BuildTitleCard(
1616 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0), 1636 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0),
1617 messageId, 1637 messageId,
1618 self /* backButtonTarget*/, 1638 self /* backButtonTarget*/,
1619 @selector(navigateBackFromSigninPage:) /* backButtonAction */); 1639 @selector(navigateBackFromSigninPage:) /* backButtonAction */);
1620 [container addSubview:titleView]; 1640 [container addSubview:titleView];
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, 1691 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin,
1672 GetDialogBackgroundColor(), nil /* text_color */); 1692 GetDialogBackgroundColor(), nil /* text_color */);
1673 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; 1693 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)];
1674 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; 1694 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel];
1675 contentView = contentLabel; 1695 contentView = contentLabel;
1676 } 1696 }
1677 [container addSubview:contentView]; 1697 [container addSubview:contentView];
1678 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; 1698 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing;
1679 1699
1680 // Adds the title card. 1700 // Adds the title card.
1681 NSBox* separator = [self separatorWithFrame: 1701 NSBox* separator = [self horizontalSeparatorWithFrame:
1682 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)]; 1702 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)];
1683 [container addSubview:separator]; 1703 [container addSubview:separator];
1684 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; 1704 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing;
1685 1705
1686 NSView* titleView = BuildTitleCard( 1706 NSView* titleView = BuildTitleCard(
1687 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), 1707 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0),
1688 IDS_PROFILES_ACCOUNT_REMOVAL_TITLE, 1708 IDS_PROFILES_ACCOUNT_REMOVAL_TITLE,
1689 self /* backButtonTarget*/, 1709 self /* backButtonTarget*/,
1690 @selector(showAccountManagement:) /* backButtonAction */); 1710 @selector(showAccountManagement:) /* backButtonAction */);
1691 [container addSubview:titleView]; 1711 [container addSubview:titleView];
(...skipping 30 matching lines...) Expand all
1722 NSString* contentStr = 1742 NSString* contentStr =
1723 l10n_util::GetNSString(IDS_PROFILES_END_PREVIEW_TEXT); 1743 l10n_util::GetNSString(IDS_PROFILES_END_PREVIEW_TEXT);
1724 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin, 1744 NSTextField* contentLabel = BuildLabel(contentStr, contentFrameOrigin,
1725 GetDialogBackgroundColor(), nil /* text_color */); 1745 GetDialogBackgroundColor(), nil /* text_color */);
1726 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; 1746 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)];
1727 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; 1747 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel];
1728 [container addSubview:contentLabel]; 1748 [container addSubview:contentLabel];
1729 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; 1749 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing;
1730 1750
1731 // Adds the title card. 1751 // Adds the title card.
1732 NSBox* separator = [self separatorWithFrame: 1752 NSBox* separator = [self horizontalSeparatorWithFrame:
1733 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0)]; 1753 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0)];
1734 [container addSubview:separator]; 1754 [container addSubview:separator];
1735 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; 1755 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing;
1736 1756
1737 NSView* titleView = BuildTitleCard( 1757 NSView* titleView = BuildTitleCard(
1738 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0), 1758 NSMakeRect(0, yOffset, kFixedEndPreviewViewWidth, 0),
1739 IDS_PROFILES_END_PREVIEW, 1759 IDS_PROFILES_END_PREVIEW,
1740 self /* backButtonTarget*/, 1760 self /* backButtonTarget*/,
1741 @selector(showSendFeedbackTutorial:) /* backButtonAction */); 1761 @selector(showSendFeedbackTutorial:) /* backButtonAction */);
1742 [container addSubview:titleView]; 1762 [container addSubview:titleView];
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 1876
1857 return button.autorelease(); 1877 return button.autorelease();
1858 } 1878 }
1859 1879
1860 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action { 1880 - (void)postActionPerformed:(ProfileMetrics::ProfileDesktopMenu)action {
1861 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_); 1881 ProfileMetrics::LogProfileDesktopMenu(action, serviceType_);
1862 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE; 1882 serviceType_ = signin::GAIA_SERVICE_TYPE_NONE;
1863 } 1883 }
1864 1884
1865 @end 1885 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698