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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
80 const CGFloat kHorizontalSpacing = 16.0; | 80 const CGFloat kHorizontalSpacing = 16.0; |
81 const CGFloat kTitleFontSize = 15.0; | 81 const CGFloat kTitleFontSize = 15.0; |
82 const CGFloat kTextFontSize = 12.0; | 82 const CGFloat kTextFontSize = 12.0; |
83 const CGFloat kProfileButtonHeight = 30; | 83 const CGFloat kProfileButtonHeight = 30; |
84 const int kBezelThickness = 3; // Width of the bezel on an NSButton. | 84 const int kBezelThickness = 3; // Width of the bezel on an NSButton. |
85 const int kImageTitleSpacing = 10; | 85 const int kImageTitleSpacing = 10; |
86 const int kBlueButtonHeight = 30; | 86 const int kBlueButtonHeight = 30; |
87 | 87 |
88 // Fixed size for embedded sign in pages as defined in Gaia. | 88 // Fixed size for embedded sign in pages as defined in Gaia. |
89 const CGFloat kFixedGaiaViewWidth = 360; | 89 const CGFloat kFixedGaiaViewWidth = 360; |
90 const CGFloat kFixedGaiaViewHeight = 400; | 90 const CGFloat kFixedGaiaViewHeight = 440; |
91 | 91 |
92 // Fixed size for the account removal view. | 92 // Fixed size for the account removal view. |
93 const CGFloat kFixedAccountRemovalViewWidth = 280; | 93 const CGFloat kFixedAccountRemovalViewWidth = 280; |
94 | 94 |
95 // Fixed size for the switch user view. | 95 // Fixed size for the switch user view. |
96 const int kFixedSwitchUserViewWidth = 280; | 96 const int kFixedSwitchUserViewWidth = 280; |
97 | 97 |
98 // The tag number for the primary account. | 98 // The tag number for the primary account. |
99 const int kPrimaryProfileTag = -1; | 99 const int kPrimaryProfileTag = -1; |
100 | 100 |
(...skipping 10 matching lines...) Expand all Loading... | |
111 frame.size = size; | 111 frame.size = size; |
112 [window setFrame:frame display:YES]; | 112 [window setFrame:frame display:YES]; |
113 } | 113 } |
114 | 114 |
115 NSString* ElideEmail(const std::string& email, CGFloat width) { | 115 NSString* ElideEmail(const std::string& email, CGFloat width) { |
116 const base::string16 elidedEmail = gfx::ElideText( | 116 const base::string16 elidedEmail = gfx::ElideText( |
117 base::UTF8ToUTF16(email), gfx::FontList(), width, gfx::ELIDE_EMAIL); | 117 base::UTF8ToUTF16(email), gfx::FontList(), width, gfx::ELIDE_EMAIL); |
118 return base::SysUTF16ToNSString(elidedEmail); | 118 return base::SysUTF16ToNSString(elidedEmail); |
119 } | 119 } |
120 | 120 |
121 NSString* ElideMessage(const base::string16& message, CGFloat width) { | |
122 return base::SysUTF16ToNSString( | |
123 gfx::ElideText(message, gfx::FontList(), width, gfx::ELIDE_TAIL)); | |
124 } | |
125 | |
121 // Builds a label with the given |title| anchored at |frame_origin|. Sets the | 126 // Builds a label with the given |title| anchored at |frame_origin|. Sets the |
122 // text color to |text_color| if not null. | 127 // text color to |text_color| if not null. |
123 NSTextField* BuildLabel(NSString* title, | 128 NSTextField* BuildLabel(NSString* title, |
124 NSPoint frame_origin, | 129 NSPoint frame_origin, |
125 NSColor* text_color) { | 130 NSColor* text_color) { |
126 base::scoped_nsobject<NSTextField> label( | 131 base::scoped_nsobject<NSTextField> label( |
127 [[NSTextField alloc] initWithFrame:NSZeroRect]); | 132 [[NSTextField alloc] initWithFrame:NSZeroRect]); |
128 [label setStringValue:title]; | 133 [label setStringValue:title]; |
129 [label setEditable:NO]; | 134 [label setEditable:NO]; |
130 [label setAlignment:NSLeftTextAlignment]; | 135 [label setAlignment:NSLeftTextAlignment]; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
183 // Returns the native dialog background color. | 188 // Returns the native dialog background color. |
184 NSColor* GetDialogBackgroundColor() { | 189 NSColor* GetDialogBackgroundColor() { |
185 return gfx::SkColorToCalibratedNSColor( | 190 return gfx::SkColorToCalibratedNSColor( |
186 ui::NativeTheme::instance()->GetSystemColor( | 191 ui::NativeTheme::instance()->GetSystemColor( |
187 ui::NativeTheme::kColorId_DialogBackground)); | 192 ui::NativeTheme::kColorId_DialogBackground)); |
188 } | 193 } |
189 | 194 |
190 // Builds a title card with one back button right aligned and one label center | 195 // Builds a title card with one back button right aligned and one label center |
191 // aligned. | 196 // aligned. |
192 NSView* BuildTitleCard(NSRect frame_rect, | 197 NSView* BuildTitleCard(NSRect frame_rect, |
193 NSString* message, | 198 const base::string16& message, |
194 id back_button_target, | 199 id back_button_target, |
195 SEL back_button_action) { | 200 SEL back_button_action) { |
196 base::scoped_nsobject<NSView> container( | 201 base::scoped_nsobject<NSView> container( |
197 [[NSView alloc] initWithFrame:frame_rect]); | 202 [[NSView alloc] initWithFrame:frame_rect]); |
198 | 203 |
199 base::scoped_nsobject<HoverImageButton> button( | 204 base::scoped_nsobject<HoverImageButton> button( |
200 [[HoverImageButton alloc] initWithFrame:frame_rect]); | 205 [[HoverImageButton alloc] initWithFrame:frame_rect]); |
201 [button setBordered:NO]; | 206 [button setBordered:NO]; |
202 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); | 207 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); |
203 [button setDefaultImage:rb->GetNativeImageNamed(IDR_BACK).ToNSImage()]; | 208 [button setDefaultImage:rb->GetNativeImageNamed(IDR_BACK).ToNSImage()]; |
204 [button setHoverImage:rb->GetNativeImageNamed(IDR_BACK_H).ToNSImage()]; | 209 [button setHoverImage:rb->GetNativeImageNamed(IDR_BACK_H).ToNSImage()]; |
205 [button setPressedImage:rb->GetNativeImageNamed(IDR_BACK_P).ToNSImage()]; | 210 [button setPressedImage:rb->GetNativeImageNamed(IDR_BACK_P).ToNSImage()]; |
206 [button setTarget:back_button_target]; | 211 [button setTarget:back_button_target]; |
207 [button setAction:back_button_action]; | 212 [button setAction:back_button_action]; |
208 [button setFrameSize:NSMakeSize(kProfileButtonHeight, kProfileButtonHeight)]; | 213 [button setFrameSize:NSMakeSize(kProfileButtonHeight, kProfileButtonHeight)]; |
209 [button setFrameOrigin:NSMakePoint(kHorizontalSpacing, 0)]; | 214 [button setFrameOrigin:NSMakePoint(kHorizontalSpacing, 0)]; |
210 | 215 |
211 NSTextField* title_label = BuildLabel(message, NSZeroPoint, nil); | 216 CGFloat max_label_width = frame_rect.size.width - |
217 (kHorizontalSpacing * 2 + kProfileButtonHeight) * 2; | |
218 NSTextField* title_label = BuildLabel( | |
219 ElideMessage(message, max_label_width), | |
220 NSZeroPoint, nil); | |
212 [title_label setAlignment:NSCenterTextAlignment]; | 221 [title_label setAlignment:NSCenterTextAlignment]; |
213 [title_label setFont:[NSFont labelFontOfSize:kTitleFontSize]]; | 222 [title_label setFont:[NSFont labelFontOfSize:kTitleFontSize]]; |
214 [title_label sizeToFit]; | 223 [title_label sizeToFit]; |
215 CGFloat x_offset = (frame_rect.size.width - NSWidth([title_label frame])) / 2; | 224 CGFloat x_offset = (frame_rect.size.width - NSWidth([title_label frame])) / 2; |
216 CGFloat y_offset = | 225 CGFloat y_offset = |
217 (NSHeight([button frame]) - NSHeight([title_label frame])) / 2; | 226 (NSHeight([button frame]) - NSHeight([title_label frame])) / 2; |
218 [title_label setFrameOrigin:NSMakePoint(x_offset, y_offset)]; | 227 [title_label setFrameOrigin:NSMakePoint(x_offset, y_offset)]; |
219 | 228 |
220 [container addSubview:button]; | 229 [container addSubview:button]; |
221 [container addSubview:title_label]; | 230 [container addSubview:title_label]; |
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
704 NSRectFill(dirtyRect); | 713 NSRectFill(dirtyRect); |
705 [super drawRect:dirtyRect]; | 714 [super drawRect:dirtyRect]; |
706 } | 715 } |
707 @end | 716 @end |
708 | 717 |
709 @interface ProfileChooserController () | 718 @interface ProfileChooserController () |
710 // Builds the profile chooser view. | 719 // Builds the profile chooser view. |
711 - (NSView*)buildProfileChooserView; | 720 - (NSView*)buildProfileChooserView; |
712 | 721 |
713 // Builds a tutorial card with a title label using |titleMessage|, a content | 722 // Builds a tutorial card with a title label using |titleMessage|, a content |
714 // label using |contentMessage|, and a bottom row with a right-aligned link | 723 // label using |contentMessage|, a link using |linkMessage|, and a button using |
715 // using |linkMessage|, and a left aligned button using |buttonMessage|. | 724 // |buttonMessage|. If |stackButton| is true, places the button above the link. |
Alexei Svitkine (slow)
2014/08/15 18:51:13
Nit: "is true" -> "is YES"
guohui
2014/08/15 18:53:42
Done.
| |
716 // On click, the link would execute |linkAction|, and the button would execute | 725 // Otherwise places both on the same row with the link left aligned and button |
717 // |buttonAction|. It sets |tutorialMode_| to the given |mode|. | 726 // right aligned. On click, the link would execute |linkAction|, and the button |
727 // would execute |buttonAction|. It sets |tutorialMode_| to the given |mode|. | |
718 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode | 728 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode |
719 titleMessage:(NSString*)titleMessage | 729 titleMessage:(NSString*)titleMessage |
720 contentMessage:(NSString*)contentMessage | 730 contentMessage:(NSString*)contentMessage |
721 linkMessage:(NSString*)linkMessage | 731 linkMessage:(NSString*)linkMessage |
722 buttonMessage:(NSString*)buttonMessage | 732 buttonMessage:(NSString*)buttonMessage |
733 stackButton:(BOOL)stackButton | |
723 linkAction:(SEL)linkAction | 734 linkAction:(SEL)linkAction |
724 buttonAction:(SEL)buttonAction; | 735 buttonAction:(SEL)buttonAction; |
725 | 736 |
726 // Builds a tutorial card to introduce an upgrade user to the new avatar menu if | 737 // Builds a tutorial card to introduce an upgrade user to the new avatar menu if |
727 // needed. |tutorial_shown| indicates if the tutorial has already been shown in | 738 // needed. |tutorial_shown| indicates if the tutorial has already been shown in |
728 // the previous active view. |avatar_item| refers to the current profile. | 739 // the previous active view. |avatar_item| refers to the current profile. |
729 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded; | 740 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded; |
730 | 741 |
731 // Builds a tutorial card to have the user confirm the last Chrome signin, | 742 // Builds a tutorial card to have the user confirm the last Chrome signin, |
732 // Chrome sync will be delayed until the user either dismisses the tutorial, or | 743 // Chrome sync will be delayed until the user either dismisses the tutorial, or |
(...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1151 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT); | 1162 IDS_PROFILES_CONFIRM_SIGNIN_TUTORIAL_CONTENT_TEXT); |
1152 NSString* linkMessage = l10n_util::GetNSString( | 1163 NSString* linkMessage = l10n_util::GetNSString( |
1153 IDS_PROFILES_SYNC_SETTINGS_LINK); | 1164 IDS_PROFILES_SYNC_SETTINGS_LINK); |
1154 NSString* buttonMessage = l10n_util::GetNSString( | 1165 NSString* buttonMessage = l10n_util::GetNSString( |
1155 IDS_PROFILES_TUTORIAL_OK_BUTTON); | 1166 IDS_PROFILES_TUTORIAL_OK_BUTTON); |
1156 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_CONFIRM_SIGNIN | 1167 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_CONFIRM_SIGNIN |
1157 titleMessage:titleMessage | 1168 titleMessage:titleMessage |
1158 contentMessage:contentMessage | 1169 contentMessage:contentMessage |
1159 linkMessage:linkMessage | 1170 linkMessage:linkMessage |
1160 buttonMessage:buttonMessage | 1171 buttonMessage:buttonMessage |
1172 stackButton:NO | |
1161 linkAction:@selector(configureSyncSettings:) | 1173 linkAction:@selector(configureSyncSettings:) |
1162 buttonAction:@selector(syncSettingsConfirmed:)]; | 1174 buttonAction:@selector(syncSettingsConfirmed:)]; |
1163 } | 1175 } |
1164 | 1176 |
1165 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded { | 1177 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded { |
1166 Profile* profile = browser_->profile(); | 1178 Profile* profile = browser_->profile(); |
1167 const AvatarMenu::Item& avatarItem = | 1179 const AvatarMenu::Item& avatarItem = |
1168 avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); | 1180 avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); |
1169 if (!avatarItem.signed_in) { | 1181 if (!avatarItem.signed_in) { |
1170 profile->GetPrefs()->SetInteger( | 1182 profile->GetPrefs()->SetInteger( |
(...skipping 12 matching lines...) Expand all Loading... | |
1183 if (showCount == signin_ui_util::kUpgradeWelcomeTutorialShowMax) | 1195 if (showCount == signin_ui_util::kUpgradeWelcomeTutorialShowMax) |
1184 return nil; | 1196 return nil; |
1185 profile->GetPrefs()->SetInteger( | 1197 profile->GetPrefs()->SetInteger( |
1186 prefs::kProfileAvatarTutorialShown, showCount + 1); | 1198 prefs::kProfileAvatarTutorialShown, showCount + 1); |
1187 } | 1199 } |
1188 | 1200 |
1189 NSString* titleMessage = l10n_util::GetNSString( | 1201 NSString* titleMessage = l10n_util::GetNSString( |
1190 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE); | 1202 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE); |
1191 NSString* contentMessage = l10n_util::GetNSString( | 1203 NSString* contentMessage = l10n_util::GetNSString( |
1192 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT); | 1204 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT); |
1193 NSString* linkMessage = l10n_util::GetNSStringF( | 1205 NSString* linkMessage = ElideMessage( |
1194 IDS_PROFILES_NOT_YOU, avatarItem.name); | 1206 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatarItem.name), |
1207 kFixedMenuWidth - 2 * kHorizontalSpacing); | |
1195 NSString* buttonMessage = l10n_util::GetNSString( | 1208 NSString* buttonMessage = l10n_util::GetNSString( |
1196 IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON); | 1209 IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON); |
1197 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE | 1210 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE |
1198 titleMessage:titleMessage | 1211 titleMessage:titleMessage |
1199 contentMessage:contentMessage | 1212 contentMessage:contentMessage |
1200 linkMessage:linkMessage | 1213 linkMessage:linkMessage |
1201 buttonMessage:buttonMessage | 1214 buttonMessage:buttonMessage |
1215 stackButton:YES | |
1202 linkAction:@selector(showSwitchUserView:) | 1216 linkAction:@selector(showSwitchUserView:) |
1203 buttonAction:@selector(seeWhatsNew:)]; | 1217 buttonAction:@selector(seeWhatsNew:)]; |
1204 } | 1218 } |
1205 | 1219 |
1206 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode | 1220 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode |
1207 titleMessage:(NSString*)titleMessage | 1221 titleMessage:(NSString*)titleMessage |
1208 contentMessage:(NSString*)contentMessage | 1222 contentMessage:(NSString*)contentMessage |
1209 linkMessage:(NSString*)linkMessage | 1223 linkMessage:(NSString*)linkMessage |
1210 buttonMessage:(NSString*)buttonMessage | 1224 buttonMessage:(NSString*)buttonMessage |
1225 stackButton:(BOOL)stackButton | |
1211 linkAction:(SEL)linkAction | 1226 linkAction:(SEL)linkAction |
1212 buttonAction:(SEL)buttonAction { | 1227 buttonAction:(SEL)buttonAction { |
1213 tutorialMode_ = mode; | 1228 tutorialMode_ = mode; |
1214 | 1229 |
1215 NSColor* tutorialBackgroundColor = | 1230 NSColor* tutorialBackgroundColor = |
1216 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialBackgroundColor); | 1231 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialBackgroundColor); |
1217 base::scoped_nsobject<NSView> container([[BackgroundColorView alloc] | 1232 base::scoped_nsobject<NSView> container([[BackgroundColorView alloc] |
1218 initWithFrame:NSMakeRect(0, 0, kFixedMenuWidth, 0) | 1233 initWithFrame:NSMakeRect(0, 0, kFixedMenuWidth, 0) |
1219 withColor:tutorialBackgroundColor]); | 1234 withColor:tutorialBackgroundColor]); |
1220 CGFloat availableWidth = kFixedMenuWidth - 2 * kHorizontalSpacing; | 1235 CGFloat availableWidth = kFixedMenuWidth - 2 * kHorizontalSpacing; |
1221 CGFloat yOffset = kSmallVerticalSpacing; | 1236 CGFloat yOffset = kVerticalSpacing; |
1222 | 1237 |
1223 // Adds links and buttons at the bottom. | 1238 // Adds links and buttons at the bottom. |
1224 base::scoped_nsobject<NSButton> tutorialOkButton([[HoverButton alloc] | 1239 base::scoped_nsobject<NSButton> tutorialOkButton([[HoverButton alloc] |
1225 initWithFrame:NSZeroRect]); | 1240 initWithFrame:NSZeroRect]); |
1226 [tutorialOkButton setTitle:buttonMessage]; | 1241 [tutorialOkButton setTitle:buttonMessage]; |
1227 [tutorialOkButton setBezelStyle:NSRoundedBezelStyle]; | 1242 [tutorialOkButton setBezelStyle:NSRoundedBezelStyle]; |
1228 [tutorialOkButton setTarget:self]; | 1243 [tutorialOkButton setTarget:self]; |
1229 [tutorialOkButton setAction:buttonAction]; | 1244 [tutorialOkButton setAction:buttonAction]; |
1245 [tutorialOkButton setAlignment:NSCenterTextAlignment]; | |
1230 [tutorialOkButton sizeToFit]; | 1246 [tutorialOkButton sizeToFit]; |
1231 NSSize buttonSize = [tutorialOkButton frame].size; | |
1232 const CGFloat kTopBottomTextPadding = 6; | |
1233 const CGFloat kLeftRightTextPadding = 15; | |
1234 buttonSize.width += 2 * kLeftRightTextPadding; | |
1235 buttonSize.height += 2 * kTopBottomTextPadding; | |
1236 [tutorialOkButton setFrameSize:buttonSize]; | |
1237 [tutorialOkButton setAlignment:NSCenterTextAlignment]; | |
1238 [tutorialOkButton setFrameOrigin:NSMakePoint( | |
1239 kFixedMenuWidth - NSWidth([tutorialOkButton frame]) - kHorizontalSpacing, | |
1240 yOffset)]; | |
1241 [container addSubview:tutorialOkButton]; | |
1242 | 1247 |
1243 NSButton* learnMoreLink = | 1248 NSButton* learnMoreLink = |
1244 [self linkButtonWithTitle:linkMessage | 1249 [self linkButtonWithTitle:linkMessage |
1245 frameOrigin:NSZeroPoint | 1250 frameOrigin:NSZeroPoint |
1246 action:linkAction]; | 1251 action:linkAction]; |
1247 [[learnMoreLink cell] setTextColor:[NSColor whiteColor]]; | 1252 [[learnMoreLink cell] setTextColor:[NSColor whiteColor]]; |
1248 CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) - | 1253 |
1249 NSHeight([learnMoreLink frame])) / 2; | 1254 if (stackButton) { |
1250 [learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)]; | 1255 [learnMoreLink setFrameOrigin:NSMakePoint( |
1256 (kFixedMenuWidth - NSWidth([learnMoreLink frame])) / 2, yOffset)]; | |
1257 [tutorialOkButton setFrameSize:NSMakeSize( | |
1258 availableWidth, NSHeight([tutorialOkButton frame]))]; | |
1259 [tutorialOkButton setFrameOrigin:NSMakePoint( | |
1260 kHorizontalSpacing, yOffset + NSHeight([learnMoreLink frame]))]; | |
1261 } else { | |
1262 NSSize buttonSize = [tutorialOkButton frame].size; | |
1263 const CGFloat kTopBottomTextPadding = 6; | |
1264 const CGFloat kLeftRightTextPadding = 15; | |
1265 buttonSize.width += 2 * kLeftRightTextPadding; | |
1266 buttonSize.height += 2 * kTopBottomTextPadding; | |
1267 [tutorialOkButton setFrameSize:buttonSize]; | |
1268 CGFloat buttonXOffset = kFixedMenuWidth - | |
1269 NSWidth([tutorialOkButton frame]) - kHorizontalSpacing; | |
1270 [tutorialOkButton setFrameOrigin:NSMakePoint(buttonXOffset, yOffset)]; | |
1271 | |
1272 CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) - | |
1273 NSHeight([learnMoreLink frame])) / 2; | |
1274 [learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)]; | |
1275 } | |
1276 [container addSubview:tutorialOkButton]; | |
1251 [container addSubview:learnMoreLink]; | 1277 [container addSubview:learnMoreLink]; |
1252 | 1278 |
1253 yOffset = std::max(NSMaxY([learnMoreLink frame]), | 1279 yOffset = std::max(NSMaxY([learnMoreLink frame]), |
1254 NSMaxY([tutorialOkButton frame])) + kVerticalSpacing; | 1280 NSMaxY([tutorialOkButton frame])) + kVerticalSpacing; |
1255 | 1281 |
1256 // Adds body content. | 1282 // Adds body content. |
1257 NSTextField* contentLabel = BuildLabel( | 1283 NSTextField* contentLabel = BuildLabel( |
1258 contentMessage, | 1284 contentMessage, |
1259 NSMakePoint(kHorizontalSpacing, yOffset), | 1285 NSMakePoint(kHorizontalSpacing, yOffset), |
1260 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialContentTextColor)); | 1286 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialContentTextColor)); |
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1672 yOffset = NSMaxY([webview frame]); | 1698 yOffset = NSMaxY([webview frame]); |
1673 | 1699 |
1674 // Adds the title card. | 1700 // Adds the title card. |
1675 NSBox* separator = [self horizontalSeparatorWithFrame: | 1701 NSBox* separator = [self horizontalSeparatorWithFrame: |
1676 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; | 1702 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0)]; |
1677 [container addSubview:separator]; | 1703 [container addSubview:separator]; |
1678 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1704 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
1679 | 1705 |
1680 NSView* titleView = BuildTitleCard( | 1706 NSView* titleView = BuildTitleCard( |
1681 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0), | 1707 NSMakeRect(0, yOffset, kFixedGaiaViewWidth, 0), |
1682 l10n_util::GetNSString(messageId), | 1708 l10n_util::GetStringUTF16(messageId), |
1683 self /* backButtonTarget*/, | 1709 self /* backButtonTarget*/, |
1684 @selector(navigateBackFromSigninPage:) /* backButtonAction */); | 1710 @selector(navigateBackFromSigninPage:) /* backButtonAction */); |
1685 [container addSubview:titleView]; | 1711 [container addSubview:titleView]; |
1686 yOffset = NSMaxY([titleView frame]); | 1712 yOffset = NSMaxY([titleView frame]); |
1687 | 1713 |
1688 [container setFrameSize:NSMakeSize(kFixedGaiaViewWidth, yOffset)]; | 1714 [container setFrameSize:NSMakeSize(kFixedGaiaViewWidth, yOffset)]; |
1689 return container.autorelease(); | 1715 return container.autorelease(); |
1690 } | 1716 } |
1691 | 1717 |
1692 - (NSView*)buildAccountRemovalView { | 1718 - (NSView*)buildAccountRemovalView { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1742 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; | 1768 yOffset = NSMaxY([contentView frame]) + kVerticalSpacing; |
1743 | 1769 |
1744 // Adds the title card. | 1770 // Adds the title card. |
1745 NSBox* separator = [self horizontalSeparatorWithFrame: | 1771 NSBox* separator = [self horizontalSeparatorWithFrame: |
1746 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)]; | 1772 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth, 0)]; |
1747 [container addSubview:separator]; | 1773 [container addSubview:separator]; |
1748 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1774 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
1749 | 1775 |
1750 NSView* titleView = BuildTitleCard( | 1776 NSView* titleView = BuildTitleCard( |
1751 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), | 1777 NSMakeRect(0, yOffset, kFixedAccountRemovalViewWidth,0), |
1752 l10n_util::GetNSString(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), | 1778 l10n_util::GetStringUTF16(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), |
1753 self /* backButtonTarget*/, | 1779 self /* backButtonTarget*/, |
1754 @selector(showAccountManagement:) /* backButtonAction */); | 1780 @selector(showAccountManagement:) /* backButtonAction */); |
1755 [container addSubview:titleView]; | 1781 [container addSubview:titleView]; |
1756 yOffset = NSMaxY([titleView frame]); | 1782 yOffset = NSMaxY([titleView frame]); |
1757 | 1783 |
1758 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; | 1784 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; |
1759 return container.autorelease(); | 1785 return container.autorelease(); |
1760 } | 1786 } |
1761 | 1787 |
1762 | 1788 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1798 action:@selector(addPerson:)]; | 1824 action:@selector(addPerson:)]; |
1799 [container addSubview:addPersonButton]; | 1825 [container addSubview:addPersonButton]; |
1800 yOffset = NSMaxY([addPersonButton frame]); | 1826 yOffset = NSMaxY([addPersonButton frame]); |
1801 | 1827 |
1802 separator = [self horizontalSeparatorWithFrame: | 1828 separator = [self horizontalSeparatorWithFrame: |
1803 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; | 1829 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; |
1804 [container addSubview:separator]; | 1830 [container addSubview:separator]; |
1805 yOffset = NSMaxY([separator frame]); | 1831 yOffset = NSMaxY([separator frame]); |
1806 | 1832 |
1807 // Adds the content text. | 1833 // Adds the content text. |
1834 base::string16 elidedName(gfx::ElideText( | |
1835 avatarItem.name, gfx::FontList(), availableWidth, gfx::ELIDE_TAIL)); | |
1808 NSTextField* contentLabel = BuildLabel( | 1836 NSTextField* contentLabel = BuildLabel( |
1809 l10n_util::GetNSStringF( | 1837 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU_CONTENT_TEXT, elidedName), |
1810 IDS_PROFILES_NOT_YOU_CONTENT_TEXT, avatarItem.name), | |
1811 NSMakePoint(kHorizontalSpacing, yOffset + kVerticalSpacing), | 1838 NSMakePoint(kHorizontalSpacing, yOffset + kVerticalSpacing), |
1812 nil); | 1839 nil); |
1813 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; | 1840 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
1814 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; | 1841 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
1815 [container addSubview:contentLabel]; | 1842 [container addSubview:contentLabel]; |
1816 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; | 1843 yOffset = NSMaxY([contentLabel frame]) + kVerticalSpacing; |
1817 | 1844 |
1818 // Adds the title card. | 1845 // Adds the title card. |
1819 separator = [self horizontalSeparatorWithFrame: | 1846 separator = [self horizontalSeparatorWithFrame: |
1820 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth, 0)]; | 1847 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth, 0)]; |
1821 [container addSubview:separator]; | 1848 [container addSubview:separator]; |
1822 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; | 1849 yOffset = NSMaxY([separator frame]) + kSmallVerticalSpacing; |
1823 | 1850 |
1824 NSView* titleView = BuildTitleCard( | 1851 NSView* titleView = BuildTitleCard( |
1825 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth,0), | 1852 NSMakeRect(0, yOffset, kFixedSwitchUserViewWidth,0), |
1826 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU, avatarItem.name), | 1853 l10n_util::GetStringFUTF16(IDS_PROFILES_NOT_YOU, avatarItem.name), |
1827 self /* backButtonTarget*/, | 1854 self /* backButtonTarget*/, |
1828 @selector(navigateBackFromSwitchUserView:) /* backButtonAction */); | 1855 @selector(navigateBackFromSwitchUserView:) /* backButtonAction */); |
1829 [container addSubview:titleView]; | 1856 [container addSubview:titleView]; |
1830 yOffset = NSMaxY([titleView frame]); | 1857 yOffset = NSMaxY([titleView frame]); |
1831 | 1858 |
1832 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; | 1859 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; |
1833 return container.autorelease(); | 1860 return container.autorelease(); |
1834 } | 1861 } |
1835 | 1862 |
1836 // Called when clicked on the settings link. | 1863 // Called when clicked on the settings link. |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1950 } | 1977 } |
1951 | 1978 |
1952 - (bool)shouldShowGoIncognito { | 1979 - (bool)shouldShowGoIncognito { |
1953 bool incognitoAvailable = | 1980 bool incognitoAvailable = |
1954 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 1981 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
1955 IncognitoModePrefs::DISABLED; | 1982 IncognitoModePrefs::DISABLED; |
1956 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 1983 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
1957 } | 1984 } |
1958 | 1985 |
1959 @end | 1986 @end |
OLD | NEW |