| 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 "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 Loading... |
| 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 Loading... |
| 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 // If the button string is specified, then the button action needs to be |
| 1903 [resolveErrorButton setTitle:l10n_util::GetNSString(buttonStringId)]; | 1896 // already initialized for the button to be constructed. |
| 1904 [resolveErrorButton setTarget:self]; | 1897 DCHECK(buttonAction); |
| 1905 [resolveErrorButton setAction:buttonAction]; | 1898 base::scoped_nsobject<NSButton> resolveErrorButton( |
| 1906 [resolveErrorButton setAlignment:NSCenterTextAlignment]; | 1899 [[BlueLabelButton alloc] initWithFrame:NSZeroRect]); |
| 1907 [resolveErrorButton sizeToFit]; | 1900 [resolveErrorButton setTitle:l10n_util::GetNSString(buttonStringId)]; |
| 1908 [resolveErrorButton setFrameOrigin:NSMakePoint(xOffset, yOffset)]; | 1901 [resolveErrorButton setTarget:self]; |
| 1909 [container addSubview:resolveErrorButton]; | 1902 [resolveErrorButton setAction:buttonAction]; |
| 1910 yOffset = NSMaxY([resolveErrorButton frame]) + kVerticalSpacing; | 1903 [resolveErrorButton setAlignment:NSCenterTextAlignment]; |
| 1904 [resolveErrorButton sizeToFit]; |
| 1905 [resolveErrorButton setFrameOrigin:NSMakePoint(xOffset, yOffset + 4.0)]; |
| 1906 [container addSubview:resolveErrorButton]; |
| 1907 yOffset = NSMaxY([resolveErrorButton frame]) + kVerticalSpacing; |
| 1908 } |
| 1911 | 1909 |
| 1912 // Adds the error message content. | 1910 // Adds the error message content. |
| 1913 NSTextField* contentLabel = | 1911 NSTextField* contentLabel = |
| 1914 BuildLabel(l10n_util::GetNSString(contentStringId), | 1912 BuildLabel(l10n_util::GetNSString(contentStringId), |
| 1915 NSMakePoint(xOffset, yOffset), nil); | 1913 NSMakePoint(xOffset, yOffset), nil); |
| 1916 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; | 1914 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
| 1917 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; | 1915 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
| 1918 [container addSubview:contentLabel]; | 1916 [container addSubview:contentLabel]; |
| 1919 yOffset = NSMaxY([contentLabel frame]) + 4; | 1917 yOffset = NSMaxY([contentLabel frame]) + 4; |
| 1920 | 1918 |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2890 } | 2888 } |
| 2891 | 2889 |
| 2892 - (bool)shouldShowGoIncognito { | 2890 - (bool)shouldShowGoIncognito { |
| 2893 bool incognitoAvailable = | 2891 bool incognitoAvailable = |
| 2894 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2892 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2895 IncognitoModePrefs::DISABLED; | 2893 IncognitoModePrefs::DISABLED; |
| 2896 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2894 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 2897 } | 2895 } |
| 2898 | 2896 |
| 2899 @end | 2897 @end |
| OLD | NEW |