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

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

Issue 516163003: Fix UI glitches in the new avatar bubble (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/ui/views/profiles/profile_chooser_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 const int kBlueButtonHeight = 30; 87 const int kBlueButtonHeight = 30;
88 88
89 // Fixed size for embedded sign in pages as defined in Gaia. 89 // Fixed size for embedded sign in pages as defined in Gaia.
90 const CGFloat kFixedGaiaViewWidth = 360; 90 const CGFloat kFixedGaiaViewWidth = 360;
91 const CGFloat kFixedGaiaViewHeight = 440; 91 const CGFloat kFixedGaiaViewHeight = 440;
92 92
93 // Fixed size for the account removal view. 93 // Fixed size for the account removal view.
94 const CGFloat kFixedAccountRemovalViewWidth = 280; 94 const CGFloat kFixedAccountRemovalViewWidth = 280;
95 95
96 // Fixed size for the switch user view. 96 // Fixed size for the switch user view.
97 const int kFixedSwitchUserViewWidth = 280; 97 const int kFixedSwitchUserViewWidth = 320;
98 98
99 // The tag number for the primary account. 99 // The tag number for the primary account.
100 const int kPrimaryProfileTag = -1; 100 const int kPrimaryProfileTag = -1;
101 101
102 gfx::Image CreateProfileImage(const gfx::Image& icon, int imageSize) { 102 gfx::Image CreateProfileImage(const gfx::Image& icon, int imageSize) {
103 return profiles::GetSizedAvatarIcon( 103 return profiles::GetSizedAvatarIcon(
104 icon, true /* image is a square */, imageSize, imageSize); 104 icon, true /* image is a square */, imageSize, imageSize);
105 } 105 }
106 106
107 // Updates the window size and position. 107 // Updates the window size and position.
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 [title_label setFont:[NSFont labelFontOfSize:kTitleFontSize]]; 223 [title_label setFont:[NSFont labelFontOfSize:kTitleFontSize]];
224 [title_label sizeToFit]; 224 [title_label sizeToFit];
225 CGFloat x_offset = (frame_rect.size.width - NSWidth([title_label frame])) / 2; 225 CGFloat x_offset = (frame_rect.size.width - NSWidth([title_label frame])) / 2;
226 CGFloat y_offset = 226 CGFloat y_offset =
227 (NSHeight([button frame]) - NSHeight([title_label frame])) / 2; 227 (NSHeight([button frame]) - NSHeight([title_label frame])) / 2;
228 [title_label setFrameOrigin:NSMakePoint(x_offset, y_offset)]; 228 [title_label setFrameOrigin:NSMakePoint(x_offset, y_offset)];
229 229
230 [container addSubview:button]; 230 [container addSubview:button];
231 [container addSubview:title_label]; 231 [container addSubview:title_label];
232 CGFloat height = std::max(NSMaxY([title_label frame]), 232 CGFloat height = std::max(NSMaxY([title_label frame]),
233 NSMaxY([button frame])) + kSmallVerticalSpacing; 233 NSMaxY([button frame])) + kVerticalSpacing;
234 [container setFrameSize:NSMakeSize(NSWidth([container frame]), height)]; 234 [container setFrameSize:NSMakeSize(NSWidth([container frame]), height)];
235 235
236 return container.autorelease(); 236 return container.autorelease();
237 } 237 }
238 238
239 bool HasAuthError(Profile* profile) { 239 bool HasAuthError(Profile* profile) {
240 const SigninErrorController* error_controller = 240 const SigninErrorController* error_controller =
241 profiles::GetSigninErrorController(profile); 241 profiles::GetSigninErrorController(profile);
242 return error_controller && error_controller->HasError(); 242 return error_controller && error_controller->HasError();
243 } 243 }
(...skipping 1627 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 std::string()); 1871 std::string());
1872 NSView* webview = webContents_->GetNativeView(); 1872 NSView* webview = webContents_->GetNativeView();
1873 [webview setFrameSize:NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight)]; 1873 [webview setFrameSize:NSMakeSize(kFixedGaiaViewWidth, kFixedGaiaViewHeight)];
1874 [container addSubview:webview]; 1874 [container addSubview:webview];
1875 yOffset = NSMaxY([webview frame]); 1875 yOffset = NSMaxY([webview frame]);
1876 1876
1877 // Adds the title card. 1877 // Adds the title card.
1878 NSBox* separator = [self horizontalSeparatorWithFrame: 1878 NSBox* separator = [self horizontalSeparatorWithFrame:
1879 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; 1879 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)];
1880 [container addSubview:separator]; 1880 [container addSubview:separator];
1881 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; 1881 yOffset = NSMaxY([separator frame]) + kVerticalSpacing;
1882 1882
1883 NSView* titleView = BuildTitleCard( 1883 NSView* titleView = BuildTitleCard(
1884 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0), 1884 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0),
1885 l10n_util::GetStringUTF16(messageId), 1885 l10n_util::GetStringUTF16(messageId),
1886 self /* backButtonTarget*/, 1886 self /* backButtonTarget*/,
1887 @selector(navigateBackFromSigninPage:) /* backButtonAction */); 1887 @selector(navigateBackFromSigninPage:) /* backButtonAction */);
1888 [container addSubview:titleView]; 1888 [container addSubview:titleView];
1889 yOffset = NSMaxY([titleView frame]); 1889 yOffset = NSMaxY([titleView frame]);
1890 1890
1891 [container setFrameSize:NSMakeSize(kFixedGaiaViewWidth, yOffset)]; 1891 [container setFrameSize:NSMakeSize(kFixedGaiaViewWidth, yOffset)];
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
1943 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; 1943 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel];
1944 contentView = contentLabel; 1944 contentView = contentLabel;
1945 } 1945 }
1946 [container addSubview:contentView]; 1946 [container addSubview:contentView];
1947 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; 1947 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing;
1948 1948
1949 // Adds the title card. 1949 // Adds the title card.
1950 NSBox* separator = [self horizontalSeparatorWithFrame: 1950 NSBox* separator = [self horizontalSeparatorWithFrame:
1951 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)]; 1951 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)];
1952 [container addSubview:separator]; 1952 [container addSubview:separator];
1953 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; 1953 yOffset = NSMaxY([separator frame]) + kVerticalSpacing;
1954 1954
1955 NSView* titleView = BuildTitleCard( 1955 NSView* titleView = BuildTitleCard(
1956 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), 1956 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0),
1957 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), 1957 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE),
1958 self /* backButtonTarget*/, 1958 self /* backButtonTarget*/,
1959 @selector(showAccountManagement:) /* backButtonAction */); 1959 @selector(showAccountManagement:) /* backButtonAction */);
1960 [container addSubview:titleView]; 1960 [container addSubview:titleView];
1961 yOffset = NSMaxY([titleView frame]); 1961 yOffset = NSMaxY([titleView frame]);
1962 1962
1963 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; 1963 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)];
(...skipping 19 matching lines...) Expand all
1983 NSButton* disconnectButton = 1983 NSButton* disconnectButton =
1984 [self hoverButtonWithRect:viewRect 1984 [self hoverButtonWithRect:viewRect
1985 text:l10n_util::GetNSString( 1985 text:l10n_util::GetNSString(
1986 IDS_PROFILES_DISCONNECT_BUTTON) 1986 IDS_PROFILES_DISCONNECT_BUTTON)
1987 imageResourceId:IDR_ICON_PROFILES_MENU_DISCONNECT 1987 imageResourceId:IDR_ICON_PROFILES_MENU_DISCONNECT
1988 action:@selector(disconnectProfile:)]; 1988 action:@selector(disconnectProfile:)];
1989 [container addSubview:disconnectButton]; 1989 [container addSubview:disconnectButton];
1990 yOffset = NSMaxY([disconnectButton frame]); 1990 yOffset = NSMaxY([disconnectButton frame]);
1991 1991
1992 NSBox* separator = [self horizontalSeparatorWithFrame: 1992 NSBox* separator = [self horizontalSeparatorWithFrame:
1993 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; 1993 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth, 0)];
1994 [container addSubview:separator]; 1994 [container addSubview:separator];
1995 yOffset = NSMaxY([separator frame]); 1995 yOffset = NSMaxY([separator frame]);
1996 1996
1997 // Adds "Add person" button. 1997 // Adds "Add person" button.
1998 viewRect.origin.y = yOffset; 1998 viewRect.origin.y = yOffset;
1999 NSButton* addPersonButton = 1999 NSButton* addPersonButton =
2000 [self hoverButtonWithRect:viewRect 2000 [self hoverButtonWithRect:viewRect
2001 text:l10n_util::GetNSString( 2001 text:l10n_util::GetNSString(
2002 IDS_PROFILES_ADD_PERSON_BUTTON) 2002 IDS_PROFILES_ADD_PERSON_BUTTON)
2003 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR 2003 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
2004 action:@selector(showUserManager:)]; 2004 action:@selector(showUserManager:)];
2005 [container addSubview:addPersonButton]; 2005 [container addSubview:addPersonButton];
2006 yOffset = NSMaxY([addPersonButton frame]); 2006 yOffset = NSMaxY([addPersonButton frame]);
2007 2007
2008 separator = [self horizontalSeparatorWithFrame: 2008 separator = [self horizontalSeparatorWithFrame:
2009 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; 2009 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth, 0)];
2010 [container addSubview:separator]; 2010 [container addSubview:separator];
2011 yOffset = NSMaxY([separator frame]); 2011 yOffset = NSMaxY([separator frame]);
2012 2012
2013 // Adds the content text. 2013 // Adds the content text.
2014 base::string16 elidedName(gfx::ElideText( 2014 base::string16 elidedName(gfx::ElideText(
2015 avatarItem.name, gfx::FontList(), availableWidth, gfx::ELIDE_TAIL)); 2015 avatarItem.name, gfx::FontList(), availableWidth, gfx::ELIDE_TAIL));
2016 NSTextField* contentLabel = BuildLabel( 2016 NSTextField* contentLabel = BuildLabel(
2017 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU_CONTENT_TEXT, elidedName), 2017 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU_CONTENT_TEXT, elidedName),
2018 NSMakePoint(kHorizontalSpacing, yOffset + kVerticalSpacing), 2018 NSMakePoint(kHorizontalSpacing, yOffset + kVerticalSpacing),
2019 nil); 2019 nil);
2020 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; 2020 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)];
2021 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; 2021 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel];
2022 [container addSubview:contentLabel]; 2022 [container addSubview:contentLabel];
2023 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; 2023 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing;
2024 2024
2025 // Adds the title card. 2025 // Adds the title card.
2026 separator = [self horizontalSeparatorWithFrame: 2026 separator = [self horizontalSeparatorWithFrame:
2027 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth, 0)]; 2027 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth, 0)];
2028 [container addSubview:separator]; 2028 [container addSubview:separator];
2029 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; 2029 yOffset = NSMaxY([separator frame]) + kVerticalSpacing;
2030 2030
2031 NSView* titleView = BuildTitleCard( 2031 NSView* titleView = BuildTitleCard(
2032 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth,0), 2032 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth,0),
2033 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatarItem.name), 2033 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatarItem.name),
2034 self /* backButtonTarget*/, 2034 self /* backButtonTarget*/,
2035 @selector(navigateBackFromSwitchUserView:) /* backButtonAction */); 2035 @selector(navigateBackFromSwitchUserView:) /* backButtonAction */);
2036 [container addSubview:titleView]; 2036 [container addSubview:titleView];
2037 yOffset = NSMaxY([titleView frame]); 2037 yOffset = NSMaxY([titleView frame]);
2038 2038
2039 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; 2039 [container setFrameSize:NSMakeSize(kFixedSwitchUserViewWidth, yOffset)];
2040 return container.autorelease(); 2040 return container.autorelease();
2041 } 2041 }
2042 2042
2043 // Called when clicked on the settings link. 2043 // Called when clicked on the settings link.
2044 - (BOOL)textView:(NSTextView*)textView 2044 - (BOOL)textView:(NSTextView*)textView
2045 clickedOnLink:(id)link 2045 clickedOnLink:(id)link
2046 atIndex:(NSUInteger)charIndex { 2046 atIndex:(NSUInteger)charIndex {
2047 chrome::ShowSettings(browser_); 2047 chrome::ShowSettings(browser_);
2048 return YES; 2048 return YES;
2049 } 2049 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2161 } 2161 }
2162 2162
2163 - (bool)shouldShowGoIncognito { 2163 - (bool)shouldShowGoIncognito {
2164 bool incognitoAvailable = 2164 bool incognitoAvailable =
2165 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2165 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2166 IncognitoModePrefs::DISABLED; 2166 IncognitoModePrefs::DISABLED;
2167 return incognitoAvailable && !browser_->profile()->IsGuestSession(); 2167 return incognitoAvailable && !browser_->profile()->IsGuestSession();
2168 } 2168 }
2169 2169
2170 @end 2170 @end
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/views/profiles/profile_chooser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698