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

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

Issue 1120013003: Add right-click user switching tutorial bubble. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make the pref per-chrome instead of per-profile. Created 5 years, 7 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
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 #import <Carbon/Carbon.h> // kVK_Return. 6 #import <Carbon/Carbon.h> // kVK_Return.
7 7
8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 8 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
9 9
10 #include "base/mac/bundle_locations.h" 10 #include "base/mac/bundle_locations.h"
(...skipping 881 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 stackButton:(BOOL)stackButton 892 stackButton:(BOOL)stackButton
893 hasCloseButton:(BOOL)hasCloseButton 893 hasCloseButton:(BOOL)hasCloseButton
894 linkAction:(SEL)linkAction 894 linkAction:(SEL)linkAction
895 buttonAction:(SEL)buttonAction; 895 buttonAction:(SEL)buttonAction;
896 896
897 // Builds a tutorial card to introduce an upgrade user to the new avatar menu if 897 // Builds a tutorial card to introduce an upgrade user to the new avatar menu if
898 // needed. |tutorial_shown| indicates if the tutorial has already been shown in 898 // needed. |tutorial_shown| indicates if the tutorial has already been shown in
899 // the previous active view. |avatar_item| refers to the current profile. 899 // the previous active view. |avatar_item| refers to the current profile.
900 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded; 900 - (NSView*)buildWelcomeUpgradeTutorialViewIfNeeded;
901 901
902 // Builds a tutorial card to inform the user about right-click user switching if
903 // needed.
904 - (NSView*)buildRightClickTutorialViewIfNeeded;
905
902 // Builds a tutorial card to have the user confirm the last Chrome signin, 906 // Builds a tutorial card to have the user confirm the last Chrome signin,
903 // Chrome sync will be delayed until the user either dismisses the tutorial, or 907 // Chrome sync will be delayed until the user either dismisses the tutorial, or
904 // configures sync through the "Settings" link. 908 // configures sync through the "Settings" link.
905 - (NSView*)buildSigninConfirmationView; 909 - (NSView*)buildSigninConfirmationView;
906 910
907 // Builds a tutorial card to show the last signin error. 911 // Builds a tutorial card to show the last signin error.
908 - (NSView*)buildSigninErrorView; 912 - (NSView*)buildSigninErrorView;
909 913
910 // Creates the main profile card for the profile |item| at the top of 914 // Creates the main profile card for the profile |item| at the top of
911 // the bubble. 915 // the bubble.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 } 1126 }
1123 1127
1124 - (IBAction)dismissTutorial:(id)sender { 1128 - (IBAction)dismissTutorial:(id)sender {
1125 // Never shows the upgrade tutorial again if manually closed. 1129 // Never shows the upgrade tutorial again if manually closed.
1126 if (tutorialMode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE) { 1130 if (tutorialMode_ == profiles::TUTORIAL_MODE_WELCOME_UPGRADE) {
1127 browser_->profile()->GetPrefs()->SetInteger( 1131 browser_->profile()->GetPrefs()->SetInteger(
1128 prefs::kProfileAvatarTutorialShown, 1132 prefs::kProfileAvatarTutorialShown,
1129 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1); 1133 signin_ui_util::kUpgradeWelcomeTutorialShowMax + 1);
1130 } 1134 }
1131 1135
1136 if(tutorialMode_ == profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING) {
1137 profiles::SetFastUserSwitchingTutorialDismissedState(true);
1138 }
1139
1132 tutorialMode_ = profiles::TUTORIAL_MODE_NONE; 1140 tutorialMode_ = profiles::TUTORIAL_MODE_NONE;
1133 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER]; 1141 [self initMenuContentsWithView:profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER];
1134 } 1142 }
1135 1143
1136 - (void)windowWillClose:(NSNotification*)notification { 1144 - (void)windowWillClose:(NSNotification*)notification {
1137 if (tutorialMode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) { 1145 if (tutorialMode_ == profiles::TUTORIAL_MODE_CONFIRM_SIGNIN) {
1138 LoginUIServiceFactory::GetForProfile(browser_->profile())-> 1146 LoginUIServiceFactory::GetForProfile(browser_->profile())->
1139 SyncConfirmationUIClosed(false); 1147 SyncConfirmationUIClosed(false);
1140 } 1148 }
1141 1149
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 [[NSView alloc] initWithFrame:NSZeroRect]); 1271 [[NSView alloc] initWithFrame:NSZeroRect]);
1264 1272
1265 NSView* tutorialView = nil; 1273 NSView* tutorialView = nil;
1266 NSView* currentProfileView = nil; 1274 NSView* currentProfileView = nil;
1267 base::scoped_nsobject<NSMutableArray> otherProfiles( 1275 base::scoped_nsobject<NSMutableArray> otherProfiles(
1268 [[NSMutableArray alloc] init]); 1276 [[NSMutableArray alloc] init]);
1269 // Local and guest profiles cannot lock their profile. 1277 // Local and guest profiles cannot lock their profile.
1270 bool displayLock = false; 1278 bool displayLock = false;
1271 bool isFastProfileChooser = 1279 bool isFastProfileChooser =
1272 viewMode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER; 1280 viewMode_ == profiles::BUBBLE_VIEW_MODE_FAST_PROFILE_CHOOSER;
1281 if (isFastProfileChooser) {
Mike Lerman 2015/05/05 01:31:45 nit: inline the condition.
anthonyvd 2015/05/05 16:19:17 It's used again a little further down.
1282 // The user is using right-click switching, no need to tell them about it.
1283 profiles::SetFastUserSwitchingTutorialDismissedState(true);
1284 }
1273 1285
1274 // Loop over the profiles in reverse, so that they are sorted by their 1286 // Loop over the profiles in reverse, so that they are sorted by their
1275 // y-coordinate, and separate them into active and "other" profiles. 1287 // y-coordinate, and separate them into active and "other" profiles.
1276 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) { 1288 for (int i = avatarMenu_->GetNumberOfItems() - 1; i >= 0; --i) {
1277 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i); 1289 const AvatarMenu::Item& item = avatarMenu_->GetItemAt(i);
1278 if (item.active) { 1290 if (item.active) {
1279 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) { 1291 if (viewMode_ == profiles::BUBBLE_VIEW_MODE_PROFILE_CHOOSER) {
1280 switch (tutorialMode_) { 1292 switch (tutorialMode_) {
1281 case profiles::TUTORIAL_MODE_NONE: 1293 case profiles::TUTORIAL_MODE_NONE:
1282 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE: 1294 case profiles::TUTORIAL_MODE_WELCOME_UPGRADE:
1295 case profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING:
1283 tutorialView = 1296 tutorialView =
1284 [self buildWelcomeUpgradeTutorialViewIfNeeded]; 1297 [self buildWelcomeUpgradeTutorialViewIfNeeded];
1298 if (!tutorialView)
1299 tutorialView = [self buildRightClickTutorialViewIfNeeded];
1285 break; 1300 break;
1286 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN: 1301 case profiles::TUTORIAL_MODE_CONFIRM_SIGNIN:
1287 tutorialView = [self buildSigninConfirmationView]; 1302 tutorialView = [self buildSigninConfirmationView];
1288 break; 1303 break;
1289 case profiles::TUTORIAL_MODE_SHOW_ERROR: 1304 case profiles::TUTORIAL_MODE_SHOW_ERROR:
1290 tutorialView = [self buildSigninErrorView]; 1305 tutorialView = [self buildSigninErrorView];
1291 } 1306 }
1292 } 1307 }
1293 currentProfileView = [self createCurrentProfileView:item]; 1308 currentProfileView = [self createCurrentProfileView:item];
1294 displayLock = item.signed_in && 1309 displayLock = item.signed_in &&
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1462 titleMessage:titleMessage 1477 titleMessage:titleMessage
1463 contentMessage:contentMessage 1478 contentMessage:contentMessage
1464 linkMessage:linkMessage 1479 linkMessage:linkMessage
1465 buttonMessage:buttonMessage 1480 buttonMessage:buttonMessage
1466 stackButton:YES 1481 stackButton:YES
1467 hasCloseButton:YES 1482 hasCloseButton:YES
1468 linkAction:@selector(showSwitchUserView:) 1483 linkAction:@selector(showSwitchUserView:)
1469 buttonAction:@selector(seeWhatsNew:)]; 1484 buttonAction:@selector(seeWhatsNew:)];
1470 } 1485 }
1471 1486
1487 - (NSView*)buildRightClickTutorialViewIfNeeded {
1488 const bool dismissed = profiles::GetFastUserSwitchingTutorialDismissedState();
1489
1490 // Don't show the tutorial if it's already been dismissed for this profile or
1491 // if right-clicking wouldn't show any targets.
1492 if (dismissed || !profiles::HasProfileSwitchTargets(browser_->profile()))
1493 return nil;
1494
1495 NSString* titleMessage = l10n_util::GetNSString(
1496 IDS_PROFILES_RIGHT_CLICK_TUTORIAL_TITLE);
1497 NSString* contentMessage = l10n_util::GetNSString(
1498 IDS_PROFILES_RIGHT_CLICK_TUTORIAL_CONTENT_TEXT);
1499 NSString* buttonMessage = l10n_util::GetNSString(
1500 IDS_PROFILES_TUTORIAL_OK_BUTTON);
1501
1502 return
1503 [self tutorialViewWithMode:profiles::TUTORIAL_MODE_RIGHT_CLICK_SWITCHING
1504 titleMessage:titleMessage
1505 contentMessage:contentMessage
1506 linkMessage:nil
1507 buttonMessage:buttonMessage
1508 stackButton:NO
1509 hasCloseButton:NO
1510 linkAction:nil
1511 buttonAction:@selector(dismissTutorial:)];
1512 }
1513
1472 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode 1514 - (NSView*)tutorialViewWithMode:(profiles::TutorialMode)mode
1473 titleMessage:(NSString*)titleMessage 1515 titleMessage:(NSString*)titleMessage
1474 contentMessage:(NSString*)contentMessage 1516 contentMessage:(NSString*)contentMessage
1475 linkMessage:(NSString*)linkMessage 1517 linkMessage:(NSString*)linkMessage
1476 buttonMessage:(NSString*)buttonMessage 1518 buttonMessage:(NSString*)buttonMessage
1477 stackButton:(BOOL)stackButton 1519 stackButton:(BOOL)stackButton
1478 hasCloseButton:(BOOL)hasCloseButton 1520 hasCloseButton:(BOOL)hasCloseButton
1479 linkAction:(SEL)linkAction 1521 linkAction:(SEL)linkAction
1480 buttonAction:(SEL)buttonAction { 1522 buttonAction:(SEL)buttonAction {
1481 tutorialMode_ = mode; 1523 tutorialMode_ = mode;
(...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 } 2357 }
2316 2358
2317 - (bool)shouldShowGoIncognito { 2359 - (bool)shouldShowGoIncognito {
2318 bool incognitoAvailable = 2360 bool incognitoAvailable =
2319 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2361 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2320 IncognitoModePrefs::DISABLED; 2362 IncognitoModePrefs::DISABLED;
2321 return incognitoAvailable && !browser_->profile()->IsGuestSession(); 2363 return incognitoAvailable && !browser_->profile()->IsGuestSession();
2322 } 2364 }
2323 2365
2324 @end 2366 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698