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 "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" | 5 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" |
6 | 6 |
7 #import <Carbon/Carbon.h> // kVK_Return. | 7 #import <Carbon/Carbon.h> // kVK_Return. |
8 #import <Cocoa/Cocoa.h> | 8 #import <Cocoa/Cocoa.h> |
9 #include <stddef.h> | 9 #include <stddef.h> |
10 | 10 |
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1383 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: | 1383 case profiles::BUBBLE_VIEW_MODE_GAIA_REAUTH: |
1384 subView = [self buildGaiaEmbeddedView]; | 1384 subView = [self buildGaiaEmbeddedView]; |
1385 break; | 1385 break; |
1386 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: | 1386 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_REMOVAL: |
1387 subView = [self buildAccountRemovalView]; | 1387 subView = [self buildAccountRemovalView]; |
1388 break; | 1388 break; |
1389 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: | 1389 case profiles::BUBBLE_VIEW_MODE_SWITCH_USER: |
1390 subView = [self buildSwitchUserView]; | 1390 subView = [self buildSwitchUserView]; |
1391 break; | 1391 break; |
1392 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: | 1392 case profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER: |
1393 case profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER: | |
1394 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: | 1393 case profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT: |
1395 subView = [self buildProfileChooserView]; | 1394 subView = [self buildProfileChooserView]; |
1396 break; | 1395 break; |
1397 } | 1396 } |
1398 | 1397 |
1399 // Clears tutorial mode for all non-profile-chooser views. | 1398 // Clears tutorial mode for all non-profile-chooser views. |
1400 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) | 1399 if (viewMode_ != profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) |
1401 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; | 1400 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; |
1402 | 1401 |
1403 // Add a dummy, empty element so that we don't initially display any | 1402 // Add a dummy, empty element so that we don't initially display any |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 createCurrentProfileAccountsView:NSMakeRect(0, yOffset, | 1483 createCurrentProfileAccountsView:NSMakeRect(0, yOffset, |
1485 kFixedMenuWidth, 0)]; | 1484 kFixedMenuWidth, 0)]; |
1486 [container addSubview:currentProfileAccountsView]; | 1485 [container addSubview:currentProfileAccountsView]; |
1487 yOffset = NSMaxY([currentProfileAccountsView frame]); | 1486 yOffset = NSMaxY([currentProfileAccountsView frame]); |
1488 | 1487 |
1489 yOffset = [self addSeparatorToContainer:container atYOffset:yOffset]; | 1488 yOffset = [self addSeparatorToContainer:container atYOffset:yOffset]; |
1490 } else { | 1489 } else { |
1491 // This is the case when the user selects the sign out option in the user | 1490 // This is the case when the user selects the sign out option in the user |
1492 // menu upon encountering unrecoverable errors. Afterwards, the profile | 1491 // menu upon encountering unrecoverable errors. Afterwards, the profile |
1493 // chooser view is shown instead of the account management view. | 1492 // chooser view is shown instead of the account management view. |
1494 viewMode_ = profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | 1493 viewMode_ = profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER; |
1495 } | 1494 } |
1496 } | 1495 } |
1497 | 1496 |
1498 // Active profile card. | 1497 // Active profile card. |
1499 if (currentProfileView) { | 1498 if (currentProfileView) { |
1500 const CGFloat verticalSpacing = kRelatedControllVerticalSpacing; | 1499 const CGFloat verticalSpacing = kRelatedControllVerticalSpacing; |
1501 yOffset += verticalSpacing; | 1500 yOffset += verticalSpacing; |
1502 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; | 1501 [currentProfileView setFrameOrigin:NSMakePoint(0, yOffset)]; |
1503 [container addSubview:currentProfileView]; | 1502 [container addSubview:currentProfileView]; |
1504 yOffset = NSMaxY([currentProfileView frame]) + verticalSpacing; | 1503 yOffset = NSMaxY([currentProfileView frame]) + verticalSpacing; |
(...skipping 22 matching lines...) Expand all Loading... |
1527 base::scoped_nsobject<NSView> container( | 1526 base::scoped_nsobject<NSView> container( |
1528 [[NSView alloc] initWithFrame:NSZeroRect]); | 1527 [[NSView alloc] initWithFrame:NSZeroRect]); |
1529 | 1528 |
1530 NSView* tutorialView = nil; | 1529 NSView* tutorialView = nil; |
1531 NSView* syncErrorView = nil; | 1530 NSView* syncErrorView = nil; |
1532 NSView* currentProfileView = nil; | 1531 NSView* currentProfileView = nil; |
1533 base::scoped_nsobject<NSMutableArray> otherProfiles( | 1532 base::scoped_nsobject<NSMutableArray> otherProfiles( |
1534 [[NSMutableArray alloc] init]); | 1533 [[NSMutableArray alloc] init]); |
1535 // Local and guest profiles cannot lock their profile. | 1534 // Local and guest profiles cannot lock their profile. |
1536 bool showLock = false; | 1535 bool showLock = false; |
1537 bool isFastProfileChooser = | |
1538 viewMode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; | |
1539 if (isFastProfileChooser) { | |
1540 // The user is using right-click switching, no need to tell them about it. | |
1541 PrefService* localState = g_browser_process->local_state(); | |
1542 localState->SetBoolean( | |
1543 prefs::kProfileAvatarRightClickTutorialDismissed, true); | |
1544 } | |
1545 | 1536 |
1546 // Loop over the profiles in reverse, so that they are sorted by their | 1537 // Loop over the profiles in reverse, so that they are sorted by their |
1547 // y-coordinate, and separate them into active and "other" profiles. | 1538 // y-coordinate, and separate them into active and "other" profiles. |
1548 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { | 1539 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { |
1549 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); | 1540 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); |
1550 if (item.active) { | 1541 if (item.active) { |
1551 syncErrorView = [self buildSyncErrorViewIfNeeded]; | 1542 syncErrorView = [self buildSyncErrorViewIfNeeded]; |
1552 currentProfileView = [self createCurrentProfileView:item]; | 1543 currentProfileView = [self createCurrentProfileView:item]; |
1553 showLock = item.signed_in && | 1544 showLock = item.signed_in && |
1554 profiles::IsLockAvailable(browser_->profile()); | 1545 profiles::IsLockAvailable(browser_->profile()); |
1555 } else { | 1546 } else { |
1556 [otherProfiles addObject:[self createOtherProfileView:i]]; | 1547 [otherProfiles addObject:[self createOtherProfileView:i]]; |
1557 } | 1548 } |
1558 } | 1549 } |
1559 firstProfileView_ = [otherProfiles lastObject]; | 1550 firstProfileView_ = [otherProfiles lastObject]; |
1560 if (!currentProfileView) // Guest windows don't have an active profile. | 1551 if (!currentProfileView) // Guest windows don't have an active profile. |
1561 currentProfileView = [self createGuestProfileView]; | 1552 currentProfileView = [self createGuestProfileView]; |
1562 | 1553 |
1563 // |yOffset| is the next position at which to draw in |container| | 1554 // |yOffset| is the next position at which to draw in |container| |
1564 // coordinates. Add a pixel offset so that the bottom option buttons don't | 1555 // coordinates. Add a pixel offset so that the bottom option buttons don't |
1565 // overlap the bubble's rounded corners. | 1556 // overlap the bubble's rounded corners. |
1566 CGFloat yOffset = 1; | 1557 CGFloat yOffset = 1; |
1567 | 1558 |
1568 if (!isFastProfileChooser) | 1559 [self buildProfileChooserViewWithProfileView:currentProfileView |
1569 [self buildProfileChooserViewWithProfileView:currentProfileView | 1560 tutorialView:tutorialView |
1570 tutorialView:tutorialView | 1561 syncErrorView:syncErrorView |
1571 syncErrorView:syncErrorView | 1562 otherProfiles:otherProfiles.get() |
1572 otherProfiles:otherProfiles.get() | 1563 atYOffset:yOffset |
1573 atYOffset:yOffset | 1564 inContainer:container |
1574 inContainer:container | 1565 showLock:showLock]; |
1575 showLock:showLock]; | |
1576 | |
1577 return container.autorelease(); | 1566 return container.autorelease(); |
1578 } | 1567 } |
1579 | 1568 |
1580 - (NSView*)buildSigninConfirmationView { | 1569 - (NSView*)buildSigninConfirmationView { |
1581 ProfileMetrics::LogProfileNewAvatarMenuSignin( | 1570 ProfileMetrics::LogProfileNewAvatarMenuSignin( |
1582 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_VIEW); | 1571 ProfileMetrics::PROFILE_AVATAR_MENU_SIGNIN_VIEW); |
1583 | 1572 |
1584 NSString* titleMessage = l10n_util::GetNSString( | 1573 NSString* titleMessage = l10n_util::GetNSString( |
1585 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE); | 1574 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_TITLE); |
1586 NSString* contentMessage = l10n_util::GetNSString( | 1575 NSString* contentMessage = l10n_util::GetNSString( |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2687 | 2676 |
2688 - (void)showWindow:(id)sender { | 2677 - (void)showWindow:(id)sender { |
2689 [super showWindow:sender]; | 2678 [super showWindow:sender]; |
2690 NSEvent *event = [[NSApplication sharedApplication] currentEvent]; | 2679 NSEvent *event = [[NSApplication sharedApplication] currentEvent]; |
2691 if (firstProfileView_ && [event type] == NSKeyDown) { | 2680 if (firstProfileView_ && [event type] == NSKeyDown) { |
2692 [[self window] makeFirstResponder:firstProfileView_]; | 2681 [[self window] makeFirstResponder:firstProfileView_]; |
2693 } | 2682 } |
2694 } | 2683 } |
2695 | 2684 |
2696 @end | 2685 @end |
OLD | NEW |