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

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

Issue 2267013002: [MD User Menu] New way to handle supervised user auth error (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Consolidated sync error functions on mac too Created 4 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
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 "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/profile_chooser_controller.h"
6 6
7 #import <Carbon/Carbon.h> // kVK_Return. 7 #import <Carbon/Carbon.h> // kVK_Return.
8 #import <Cocoa/Cocoa.h> 8 #import <Cocoa/Cocoa.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
956 contentMessage:(NSString*)contentMessage 956 contentMessage:(NSString*)contentMessage
957 linkMessage:(NSString*)linkMessage 957 linkMessage:(NSString*)linkMessage
958 buttonMessage:(NSString*)buttonMessage 958 buttonMessage:(NSString*)buttonMessage
959 stackButton:(BOOL)stackButton 959 stackButton:(BOOL)stackButton
960 hasCloseButton:(BOOL)hasCloseButton 960 hasCloseButton:(BOOL)hasCloseButton
961 linkAction:(SEL)linkAction 961 linkAction:(SEL)linkAction
962 buttonAction:(SEL)buttonAction; 962 buttonAction:(SEL)buttonAction;
963 963
964 // Builds a header for signin and sync error surfacing on the user menu. 964 // Builds a header for signin and sync error surfacing on the user menu.
965 - (NSView*)buildSyncErrorViewIfNeeded; 965 - (NSView*)buildSyncErrorViewIfNeeded;
966 - (NSView*)buildSyncErrorViewWithContent:(int)contentStringId
967 buttonStringId:(int)buttonStringId
968 buttonAction:(SEL)buttonAction;
969 966
970 // Builds a tutorial card to introduce an upgrade user to the new avatar menu if 967 // Builds a tutorial card to introduce an upgrade user to the new avatar menu if
971 // needed. |tutorial_shown| indicates if the tutorial has already been shown in 968 // needed. |tutorial_shown| indicates if the tutorial has already been shown in
972 // the previous active view. |avatar_item| refers to the current profile. 969 // the previous active view. |avatar_item| refers to the current profile.
973 - (NSView*)buildWelcomeUpgradeTutorialView:(const AvatarMenu::Item&)item; 970 - (NSView*)buildWelcomeUpgradeTutorialView:(const AvatarMenu::Item&)item;
974 971
975 // Builds a tutorial card to inform the user about right-click user switching if 972 // Builds a tutorial card to inform the user about right-click user switching if
976 // needed. 973 // needed.
977 - (NSView*)buildRightClickTutorialView; 974 - (NSView*)buildRightClickTutorialView;
978 975
(...skipping 882 matching lines...) Expand 10 before | Expand all | Expand 10 after
1861 sync_ui_util::AvatarSyncErrorType error = 1858 sync_ui_util::AvatarSyncErrorType error =
1862 sync_ui_util::GetMessagesForAvatarSyncError( 1859 sync_ui_util::GetMessagesForAvatarSyncError(
1863 browser_->profile(), &contentStringId, &buttonStringId); 1860 browser_->profile(), &contentStringId, &buttonStringId);
1864 switch (error) { 1861 switch (error) {
1865 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR: 1862 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR:
1866 buttonAction = @selector(showSignoutView:); 1863 buttonAction = @selector(showSignoutView:);
1867 break; 1864 break;
1868 case sync_ui_util::UNRECOVERABLE_ERROR: 1865 case sync_ui_util::UNRECOVERABLE_ERROR:
1869 buttonAction = @selector(showSignoutSigninView:); 1866 buttonAction = @selector(showSignoutSigninView:);
1870 break; 1867 break;
1868 case sync_ui_util::SUPERVISED_USER_AUTH_ERROR:
1869 buttonAction = nil;
1870 break;
1871 case sync_ui_util::AUTH_ERROR: 1871 case sync_ui_util::AUTH_ERROR:
1872 buttonAction = @selector(showAccountReauthenticationView:); 1872 buttonAction = @selector(showAccountReauthenticationView:);
1873 break; 1873 break;
1874 case sync_ui_util::UPGRADE_CLIENT_ERROR: 1874 case sync_ui_util::UPGRADE_CLIENT_ERROR:
1875 buttonAction = @selector(showUpdateChromeView:); 1875 buttonAction = @selector(showUpdateChromeView:);
1876 break; 1876 break;
1877 case sync_ui_util::PASSPHRASE_ERROR: 1877 case sync_ui_util::PASSPHRASE_ERROR:
1878 buttonAction = @selector(showSyncPassphraseSetupView:); 1878 buttonAction = @selector(showSyncPassphraseSetupView:);
1879 break; 1879 break;
1880 case sync_ui_util::NO_SYNC_ERROR: 1880 case sync_ui_util::NO_SYNC_ERROR:
1881 return nil; 1881 return nil;
1882 default: 1882 default:
1883 NOTREACHED(); 1883 NOTREACHED();
1884 } 1884 }
1885 return [self buildSyncErrorViewWithContent:contentStringId
1886 buttonStringId:buttonStringId
1887 buttonAction:buttonAction];
1888 }
1889 1885
1890 - (NSView*)buildSyncErrorViewWithContent:(int)contentStringId
1891 buttonStringId:(int)buttonStringId
1892 buttonAction:(SEL)buttonAction {
1893 base::scoped_nsobject<NSView> container( 1886 base::scoped_nsobject<NSView> container(
1894 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, GetFixedMenuWidth(), 0)]); 1887 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, GetFixedMenuWidth(), 0)]);
1895 CGFloat iconSize = 20.0; 1888 CGFloat iconSize = 20.0;
1896 CGFloat xOffset = kHorizontalSpacing + iconSize + 12.0; 1889 CGFloat xOffset = kHorizontalSpacing + iconSize + 12.0;
1897 CGFloat availableWidth = GetFixedMenuWidth() - xOffset - kHorizontalSpacing; 1890 CGFloat availableWidth = GetFixedMenuWidth() - xOffset - kHorizontalSpacing;
1898 CGFloat yOffset = 20.0; 1891 CGFloat yOffset = 16.0;
1899 1892
1900 // Adds an action button for resolving the error at the bottom. 1893 // Adds an action button for resolving the error at the bottom.
1901 base::scoped_nsobject<NSButton> resolveErrorButton( 1894 if (buttonStringId) {
1902 [[BlueLabelButton alloc] initWithFrame:NSZeroRect]); 1895 DCHECK(buttonAction);
groby-ooo-7-16 2016/08/23 15:16:49 You added a buttonAction = nil case above. Is th D
Jane 2016/08/23 16:39:38 Yes - when a button string is returned, that means
1903 [resolveErrorButton setTitle:l10n_util::GetNSString(buttonStringId)]; 1896 base::scoped_nsobject<NSButton> resolveErrorButton(
1904 [resolveErrorButton setTarget:self]; 1897 [[BlueLabelButton alloc] initWithFrame:NSZeroRect]);
1905 [resolveErrorButton setAction:buttonAction]; 1898 [resolveErrorButton setTitle:l10n_util::GetNSString(buttonStringId)];
1906 [resolveErrorButton setAlignment:NSCenterTextAlignment]; 1899 [resolveErrorButton setTarget:self];
1907 [resolveErrorButton sizeToFit]; 1900 [resolveErrorButton setAction:buttonAction];
1908 [resolveErrorButton setFrameOrigin:NSMakePoint(xOffset, yOffset)]; 1901 [resolveErrorButton setAlignment:NSCenterTextAlignment];
1909 [container addSubview:resolveErrorButton]; 1902 [resolveErrorButton sizeToFit];
1910 yOffset = NSMaxY([resolveErrorButton frame]) + kVerticalSpacing; 1903 [resolveErrorButton setFrameOrigin:NSMakePoint(xOffset, yOffset + 4.0)];
1904 [container addSubview:resolveErrorButton];
1905 yOffset = NSMaxY([resolveErrorButton frame]) + kVerticalSpacing;
1906 }
1911 1907
1912 // Adds the error message content. 1908 // Adds the error message content.
1913 NSTextField* contentLabel = 1909 NSTextField* contentLabel =
1914 BuildLabel(l10n_util::GetNSString(contentStringId), 1910 BuildLabel(l10n_util::GetNSString(contentStringId),
1915 NSMakePoint(xOffset, yOffset), nil); 1911 NSMakePoint(xOffset, yOffset), nil);
1916 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; 1912 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)];
1917 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; 1913 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel];
1918 [container addSubview:contentLabel]; 1914 [container addSubview:contentLabel];
1919 yOffset = NSMaxY([contentLabel frame]) + 4; 1915 yOffset = NSMaxY([contentLabel frame]) + 4;
1920 1916
(...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after
2890 } 2886 }
2891 2887
2892 - (bool)shouldShowGoIncognito { 2888 - (bool)shouldShowGoIncognito {
2893 bool incognitoAvailable = 2889 bool incognitoAvailable =
2894 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 2890 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
2895 IncognitoModePrefs::DISABLED; 2891 IncognitoModePrefs::DISABLED;
2896 return incognitoAvailable && !browser_->profile()->IsGuestSession(); 2892 return incognitoAvailable && !browser_->profile()->IsGuestSession();
2897 } 2893 }
2898 2894
2899 @end 2895 @end
OLDNEW
« no previous file with comments | « chrome/browser/sync/sync_ui_util.cc ('k') | chrome/browser/ui/views/profiles/profile_chooser_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698