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

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

Issue 464673002: Revert 288817 "[Mac, Win] Only show the user manager tutorial if..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 6 years, 4 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 800 matching lines...) Expand 10 before | Expand all | Expand 10 after
811 811
812 - (IBAction)switchToProfile:(id)sender { 812 - (IBAction)switchToProfile:(id)sender {
813 // Check the event flags to see if a new window should be created. 813 // Check the event flags to see if a new window should be created.
814 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent( 814 bool alwaysCreate = ui::WindowOpenDispositionFromNSEvent(
815 [NSApp currentEvent]) == NEW_WINDOW; 815 [NSApp currentEvent]) == NEW_WINDOW;
816 avatarMenu_->SwitchToProfile([sender tag], alwaysCreate, 816 avatarMenu_->SwitchToProfile([sender tag], alwaysCreate,
817 ProfileMetrics::SWITCH_PROFILE_ICON); 817 ProfileMetrics::SWITCH_PROFILE_ICON);
818 } 818 }
819 819
820 - (IBAction)showUserManager:(id)sender { 820 - (IBAction)showUserManager:(id)sender {
821 chrome::ShowUserManager(browser_->profile()->GetPath()); 821 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
822 } 822 }
823 823
824 - (IBAction)exitGuest:(id)sender { 824 - (IBAction)exitGuest:(id)sender {
825 DCHECK(browser_->profile()->IsGuestSession()); 825 DCHECK(browser_->profile()->IsGuestSession());
826 chrome::ShowUserManager(base::FilePath()); 826 [self showUserManager:sender];
827 profiles::CloseGuestProfileWindows(); 827 profiles::CloseGuestProfileWindows();
828 } 828 }
829 829
830 - (IBAction)goIncognito:(id)sender { 830 - (IBAction)goIncognito:(id)sender {
831 DCHECK([self shouldShowGoIncognito]); 831 DCHECK([self shouldShowGoIncognito]);
832 chrome::NewIncognitoWindow(browser_); 832 chrome::NewIncognitoWindow(browser_);
833 } 833 }
834 834
835 - (IBAction)showAccountManagement:(id)sender { 835 - (IBAction)showAccountManagement:(id)sender {
836 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT]; 836 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_ACCOUNT_MANAGEMENT];
837 } 837 }
838 838
839 - (IBAction)hideAccountManagement:(id)sender { 839 - (IBAction)hideAccountManagement:(id)sender {
840 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; 840 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
841 } 841 }
842 842
843 - (IBAction)lockProfile:(id)sender { 843 - (IBAction)lockProfile:(id)sender {
844 profiles::LockProfile(browser_->profile()); 844 profiles::LockProfile(browser_->profile());
845 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK]; 845 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_LOCK];
846 } 846 }
847 847
848 - (IBAction)showInlineSigninPage:(id)sender { 848 - (IBAction)showInlineSigninPage:(id)sender {
849 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN]; 849 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_SIGNIN];
850 } 850 }
851 851
852
852 - (IBAction)addAccount:(id)sender { 853 - (IBAction)addAccount:(id)sender {
853 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT]; 854 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_GAIA_ADD_ACCOUNT];
854 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT]; 855 [self postActionPerformed:ProfileMetrics::PROFILE_DESKTOP_MENU_ADD_ACCT];
855 } 856 }
856 857
857 - (IBAction)navigateBackFromSigninPage:(id)sender { 858 - (IBAction)navigateBackFromSigninPage:(id)sender {
858 std::string primaryAccount = SigninManagerFactory::GetForProfile( 859 std::string primaryAccount = SigninManagerFactory::GetForProfile(
859 browser_->profile())->GetAuthenticatedUsername(); 860 browser_->profile())->GetAuthenticatedUsername();
860 bool hasAccountManagement = !primaryAccount.empty() && 861 bool hasAccountManagement = !primaryAccount.empty() &&
861 switches::IsEnableAccountConsistency(); 862 switches::IsEnableAccountConsistency();
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 SyncConfirmationUIClosed(true); 912 SyncConfirmationUIClosed(true);
912 } 913 }
913 914
914 - (IBAction)syncSettingsConfirmed:(id)sender { 915 - (IBAction)syncSettingsConfirmed:(id)sender {
915 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; 916 tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
916 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 917 LoginUIServiceFactory::GetForProfile(browser_->profile())->
917 SyncConfirmationUIClosed(false); 918 SyncConfirmationUIClosed(false);
918 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; 919 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
919 } 920 }
920 921
922 - (IBAction)addPerson:(id)sender {
923 profiles::ShowUserManagerMaybeWithTutorial(browser_->profile());
924 }
925
921 - (IBAction)disconnectProfile:(id)sender { 926 - (IBAction)disconnectProfile:(id)sender {
922 chrome::ShowSettings(browser_); 927 chrome::ShowSettings(browser_);
923 } 928 }
924 929
925 - (IBAction)navigateBackFromSwitchUserView:(id)sender { 930 - (IBAction)navigateBackFromSwitchUserView:(id)sender {
926 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; 931 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
927 } 932 }
928 933
929 - (void)windowWillClose:(NSNotification*)notification { 934 - (void)windowWillClose:(NSNotification*)notification {
930 if (tutorialMode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { 935 if (tutorialMode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) {
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1159 buttonAction:@selector(syncSettingsConfirmed:)]; 1164 buttonAction:@selector(syncSettingsConfirmed:)];
1160 } 1165 }
1161 1166
1162 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded { 1167 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded {
1163 if (first_run::IsChromeFirstRun()) 1168 if (first_run::IsChromeFirstRun())
1164 return nil; 1169 return nil;
1165 1170
1166 Profile* profile = browser_->profile(); 1171 Profile* profile = browser_->profile();
1167 const AvatarMenu::Item& avatarItem = 1172 const AvatarMenu::Item& avatarItem =
1168 avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex()); 1173 avatarMenu_->GetItemAt(avatarMenu_->GetActiveProfileIndex());
1174 if (!avatarItem.signed_in) {
1175 profile->GetPrefs()->SetInteger(
1176 prefs::kProfileAvatarTutorialShown, kUpgradeWelcomeTutorialShowMax + 1);
1177 return nil;
1178 }
1169 1179
1170 const int showCount = profile->GetPrefs()->GetInteger( 1180 const int showCount = profile->GetPrefs()->GetInteger(
1171 prefs::kProfileAvatarTutorialShown); 1181 prefs::kProfileAvatarTutorialShown);
1172 // Do not show the tutorial if user has dismissed it. 1182 // Do not show the tutorial if user has dismissed it.
1173 if (showCount > kUpgradeWelcomeTutorialShowMax) 1183 if (showCount > kUpgradeWelcomeTutorialShowMax)
1174 return nil; 1184 return nil;
1175 1185
1176 if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { 1186 if (tutorialMode_ != profiles::TUTORIAL_MODE_WELCOME_UPGRADE) {
1177 if (showCount == kUpgradeWelcomeTutorialShowMax) 1187 if (showCount == kUpgradeWelcomeTutorialShowMax)
1178 return nil; 1188 return nil;
1179 profile->GetPrefs()->SetInteger( 1189 profile->GetPrefs()->SetInteger(
1180 prefs::kProfileAvatarTutorialShown, showCount + 1); 1190 prefs::kProfileAvatarTutorialShown, showCount + 1);
1181 } 1191 }
1182 1192
1183 NSString* titleMessage = l10n_util::GetNSStringF( 1193 NSString* titleMessage = l10n_util::GetNSStringF(
1184 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatarItem.name); 1194 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_TITLE, avatarItem.name);
1185 NSString* contentMessage = l10n_util::GetNSString( 1195 NSString* contentMessage = l10n_util::GetNSString(
1186 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT); 1196 IDS_PROFILES_WELCOME_UPGRADE_TUTORIAL_CONTENT_TEXT);
1187 // For local profiles, the "Not you" link doesn't make sense. 1197 NSString* linkMessage = l10n_util::GetNSStringF(
1188 NSString* linkMessage = avatarItem.signed_in ? 1198 IDS_PROFILES_NOT_YOU, avatarItem.name);
1189 l10n_util::GetNSStringF(IDS_PROFILES_NOT_YOU, avatarItem.name) : nil;
1190 NSString* buttonMessage = l10n_util::GetNSString( 1199 NSString* buttonMessage = l10n_util::GetNSString(
1191 IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON); 1200 IDS_PROFILES_TUTORIAL_WHATS_NEW_BUTTON);
1192 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE 1201 return [self tutorialViewWithMode:profiles::TUTORIAL_MODE_WELCOME_UPGRADE
1193 titleMessage:titleMessage 1202 titleMessage:titleMessage
1194 contentMessage:contentMessage 1203 contentMessage:contentMessage
1195 linkMessage:linkMessage 1204 linkMessage:linkMessage
1196 buttonMessage:buttonMessage 1205 buttonMessage:buttonMessage
1197 linkAction:@selector(showSwitchUserView:) 1206 linkAction:@selector(showSwitchUserView:)
1198 buttonAction:@selector(seeWhatsNew:)]; 1207 buttonAction:@selector(seeWhatsNew:)];
1199 } 1208 }
(...skipping 23 matching lines...) Expand all
1223 [tutorialOkButton setTarget:self]; 1232 [tutorialOkButton setTarget:self];
1224 [tutorialOkButton setAction:buttonAction]; 1233 [tutorialOkButton setAction:buttonAction];
1225 [tutorialOkButton sizeToFit]; 1234 [tutorialOkButton sizeToFit];
1226 NSSize buttonSize = [tutorialOkButton frame].size; 1235 NSSize buttonSize = [tutorialOkButton frame].size;
1227 const CGFloat kTopBottomTextPadding = 6; 1236 const CGFloat kTopBottomTextPadding = 6;
1228 const CGFloat kLeftRightTextPadding = 15; 1237 const CGFloat kLeftRightTextPadding = 15;
1229 buttonSize.width += 2 * kLeftRightTextPadding; 1238 buttonSize.width += 2 * kLeftRightTextPadding;
1230 buttonSize.height += 2 * kTopBottomTextPadding; 1239 buttonSize.height += 2 * kTopBottomTextPadding;
1231 [tutorialOkButton setFrameSize:buttonSize]; 1240 [tutorialOkButton setFrameSize:buttonSize];
1232 [tutorialOkButton setAlignment:NSCenterTextAlignment]; 1241 [tutorialOkButton setAlignment:NSCenterTextAlignment];
1233
1234 [tutorialOkButton setFrameOrigin:NSMakePoint( 1242 [tutorialOkButton setFrameOrigin:NSMakePoint(
1235 kFixedMenuWidth - NSWidth([tutorialOkButton frame]) - kHorizontalSpacing, 1243 kFixedMenuWidth - NSWidth([tutorialOkButton frame]) - kHorizontalSpacing,
1236 yOffset)]; 1244 yOffset)];
1237 [container addSubview:tutorialOkButton]; 1245 [container addSubview:tutorialOkButton];
1238 1246
1239 if (linkMessage) { 1247 NSButton* learnMoreLink =
1240 NSButton* learnMoreLink = 1248 [self linkButtonWithTitle:linkMessage
1241 [self linkButtonWithTitle:linkMessage 1249 frameOrigin:NSZeroPoint
1242 frameOrigin:NSZeroPoint 1250 action:linkAction];
1243 action:linkAction]; 1251 [[learnMoreLink cell] setTextColor:[NSColor whiteColor]];
1244 [[learnMoreLink cell] setTextColor:[NSColor whiteColor]]; 1252 CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) -
1245 CGFloat linkYOffset = yOffset + (NSHeight([tutorialOkButton frame]) - 1253 NSHeight([learnMoreLink frame])) / 2;
1246 NSHeight([learnMoreLink frame])) / 2; 1254 [learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)];
1247 [learnMoreLink setFrameOrigin:NSMakePoint(kHorizontalSpacing, linkYOffset)]; 1255 [container addSubview:learnMoreLink];
1248 [container addSubview:learnMoreLink]; 1256
1249 yOffset = std::max(NSMaxY([learnMoreLink frame]), 1257 yOffset = std::max(NSMaxY([learnMoreLink frame]),
1250 NSMaxY([tutorialOkButton frame])) + kVerticalSpacing; 1258 NSMaxY([tutorialOkButton frame])) + kVerticalSpacing;
1251 } else { 1259
1252 yOffset = NSMaxY([tutorialOkButton frame]) + kVerticalSpacing;
1253 }
1254 // Adds body content. 1260 // Adds body content.
1255 NSTextField* contentLabel = BuildLabel( 1261 NSTextField* contentLabel = BuildLabel(
1256 contentMessage, 1262 contentMessage,
1257 NSMakePoint(kHorizontalSpacing, yOffset), 1263 NSMakePoint(kHorizontalSpacing, yOffset),
1258 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialContentTextColor)); 1264 gfx::SkColorToSRGBNSColor(profiles::kAvatarTutorialContentTextColor));
1259 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; 1265 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)];
1260 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; 1266 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel];
1261 [container addSubview:contentLabel]; 1267 [container addSubview:contentLabel];
1262 yOffset = NSMaxY([contentLabel frame]) + kSmallVerticalSpacing; 1268 yOffset = NSMaxY([contentLabel frame]) + kSmallVerticalSpacing;
1263 1269
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 l10n_util::GetNSString(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE), 1763 l10n_util::GetNSString(IDS_PROFILES_ACCOUNT_REMOVAL_TITLE),
1758 self /* backButtonTarget*/, 1764 self /* backButtonTarget*/,
1759 @selector(showAccountManagement:) /* backButtonAction */); 1765 @selector(showAccountManagement:) /* backButtonAction */);
1760 [container addSubview:titleView]; 1766 [container addSubview:titleView];
1761 yOffset = NSMaxY([titleView frame]); 1767 yOffset = NSMaxY([titleView frame]);
1762 1768
1763 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)]; 1769 [container setFrameSize:NSMakeSize(kFixedAccountRemovalViewWidth, yOffset)];
1764 return container.autorelease(); 1770 return container.autorelease();
1765 } 1771 }
1766 1772
1773
1767 - (NSView*)buildSwitchUserView { 1774 - (NSView*)buildSwitchUserView {
1768 base::scoped_nsobject<NSView> container( 1775 base::scoped_nsobject<NSView> container(
1769 [[NSView alloc] initWithFrame:NSZeroRect]); 1776 [[NSView alloc] initWithFrame:NSZeroRect]);
1770 CGFloat availableWidth = 1777 CGFloat availableWidth =
1771 kFixedSwitchUserViewWidth - 2 * kHorizontalSpacing; 1778 kFixedSwitchUserViewWidth - 2 * kHorizontalSpacing;
1772 CGFloat yOffset = 0; 1779 CGFloat yOffset = 0;
1773 NSRect viewRect = NSMakeRect(0, yOffset, 1780 NSRect viewRect = NSMakeRect(0, yOffset,
1774 kFixedSwitchUserViewWidth, 1781 kFixedSwitchUserViewWidth,
1775 kBlueButtonHeight + kSmallVerticalSpacing); 1782 kBlueButtonHeight + kSmallVerticalSpacing);
1776 1783
(...skipping 15 matching lines...) Expand all
1792 [container addSubview:separator]; 1799 [container addSubview:separator];
1793 yOffset = NSMaxY([separator frame]); 1800 yOffset = NSMaxY([separator frame]);
1794 1801
1795 // Adds "Add person" button. 1802 // Adds "Add person" button.
1796 viewRect.origin.y = yOffset; 1803 viewRect.origin.y = yOffset;
1797 NSButton* addPersonButton = 1804 NSButton* addPersonButton =
1798 [self hoverButtonWithRect:viewRect 1805 [self hoverButtonWithRect:viewRect
1799 text:l10n_util::GetNSString( 1806 text:l10n_util::GetNSString(
1800 IDS_PROFILES_ADD_PERSON_BUTTON) 1807 IDS_PROFILES_ADD_PERSON_BUTTON)
1801 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR 1808 imageResourceId:IDR_ICON_PROFILES_MENU_AVATAR
1802 action:@selector(showUserManager:)]; 1809 action:@selector(addPerson:)];
1803 [container addSubview:addPersonButton]; 1810 [container addSubview:addPersonButton];
1804 yOffset = NSMaxY([addPersonButton frame]); 1811 yOffset = NSMaxY([addPersonButton frame]);
1805 1812
1806 separator = [self horizontalSeparatorWithFrame: 1813 separator = [self horizontalSeparatorWithFrame:
1807 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)]; 1814 NSMakeRect(0, yOffset, kFixedMenuWidth, 0)];
1808 [container addSubview:separator]; 1815 [container addSubview:separator];
1809 yOffset = NSMaxY([separator frame]); 1816 yOffset = NSMaxY([separator frame]);
1810 1817
1811 // Adds the content text. 1818 // Adds the content text.
1812 NSTextField* contentLabel = BuildLabel( 1819 NSTextField* contentLabel = BuildLabel(
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1954 } 1961 }
1955 1962
1956 - (bool)shouldShowGoIncognito { 1963 - (bool)shouldShowGoIncognito {
1957 bool incognitoAvailable = 1964 bool incognitoAvailable =
1958 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1965 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1959 IncognitoModePrefs::DISABLED; 1966 IncognitoModePrefs::DISABLED;
1960 return incognitoAvailable && !browser_->profile()->IsGuestSession(); 1967 return incognitoAvailable && !browser_->profile()->IsGuestSession();
1961 } 1968 }
1962 1969
1963 @end 1970 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698