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 1556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1567 | 1567 |
1568 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item | 1568 - (NSView*)createCurrentProfileLinksForItem:(const AvatarMenu::Item&)item |
1569 rect:(NSRect)rect { | 1569 rect:(NSRect)rect { |
1570 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); | 1570 base::scoped_nsobject<NSView> container([[NSView alloc] initWithFrame:rect]); |
1571 | 1571 |
1572 // Don't double-apply the left margin to the sub-views. | 1572 // Don't double-apply the left margin to the sub-views. |
1573 rect.origin.x = 0; | 1573 rect.origin.x = 0; |
1574 | 1574 |
1575 // The available links depend on the type of profile that is active. | 1575 // The available links depend on the type of profile that is active. |
1576 if (item.signed_in) { | 1576 if (item.signed_in) { |
1577 rect.size.height = kBlueButtonHeight / 2; | |
1578 // Signed in profiles with no authentication errors do not have a clickable | 1577 // Signed in profiles with no authentication errors do not have a clickable |
1579 // email link. | 1578 // email link. |
1580 NSButton* link = nil; | 1579 NSButton* link = nil; |
1581 if (switches::IsEnableAccountConsistency()) { | 1580 if (switches::IsEnableAccountConsistency()) { |
1582 NSString* linkTitle = l10n_util::GetNSString( | 1581 NSString* linkTitle = l10n_util::GetNSString( |
1583 viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ? | 1582 viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER ? |
1584 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : | 1583 IDS_PROFILES_PROFILE_MANAGE_ACCOUNTS_BUTTON : |
1585 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); | 1584 IDS_PROFILES_PROFILE_HIDE_MANAGE_ACCOUNTS_BUTTON); |
1586 SEL linkSelector = | 1585 SEL linkSelector = |
1587 (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) ? | 1586 (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) ? |
(...skipping 15 matching lines...) Expand all Loading... |
1603 [link setTag:kPrimaryProfileTag]; | 1602 [link setTag:kPrimaryProfileTag]; |
1604 [[link cell] | 1603 [[link cell] |
1605 accessibilitySetOverrideValue:l10n_util::GetNSStringF( | 1604 accessibilitySetOverrideValue:l10n_util::GetNSStringF( |
1606 IDS_PROFILES_ACCOUNT_BUTTON_AUTH_ERROR_ACCESSIBLE_NAME, | 1605 IDS_PROFILES_ACCOUNT_BUTTON_AUTH_ERROR_ACCESSIBLE_NAME, |
1607 item.sync_state) | 1606 item.sync_state) |
1608 forAttribute:NSAccessibilityTitleAttribute]; | 1607 forAttribute:NSAccessibilityTitleAttribute]; |
1609 } else { | 1608 } else { |
1610 [link setEnabled:NO]; | 1609 [link setEnabled:NO]; |
1611 } | 1610 } |
1612 } | 1611 } |
1613 // -linkButtonWithTitle sizeToFit's the link, so re-stretch it so that it | 1612 // -linkButtonWithTitle sizeToFit's the link. We can use the height, but |
1614 // can be centered correctly in the view. | 1613 // need to re-stretch the width so that the link can be centered correctly |
| 1614 // in the view. |
| 1615 rect.size.height = [link frame].size.height; |
1615 [link setAlignment:NSCenterTextAlignment]; | 1616 [link setAlignment:NSCenterTextAlignment]; |
1616 [link setFrame:rect]; | 1617 [link setFrame:rect]; |
1617 [container addSubview:link]; | 1618 [container addSubview:link]; |
1618 [container setFrameSize:rect.size]; | 1619 [container setFrameSize:rect.size]; |
1619 } else { | 1620 } else { |
1620 rect.size.height = kBlueButtonHeight; | 1621 rect.size.height = kBlueButtonHeight; |
1621 NSButton* signinButton = [[BlueLabelButton alloc] initWithFrame:rect]; | 1622 NSButton* signinButton = [[BlueLabelButton alloc] initWithFrame:rect]; |
1622 | 1623 |
1623 // Manually elide the button text so that the contents fit inside the bubble | 1624 // Manually elide the button text so that the contents fit inside the bubble |
1624 // This is needed because the BlueLabelButton cell resets the style on | 1625 // This is needed because the BlueLabelButton cell resets the style on |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2178 } | 2179 } |
2179 | 2180 |
2180 - (bool)shouldShowGoIncognito { | 2181 - (bool)shouldShowGoIncognito { |
2181 bool incognitoAvailable = | 2182 bool incognitoAvailable = |
2182 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2183 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
2183 IncognitoModePrefs::DISABLED; | 2184 IncognitoModePrefs::DISABLED; |
2184 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2185 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
2185 } | 2186 } |
2186 | 2187 |
2187 @end | 2188 @end |
OLD | NEW |