| 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 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 sync_ui_util::AvatarSyncErrorType error = | 1861 sync_ui_util::AvatarSyncErrorType error = |
| 1862 sync_ui_util::GetMessagesForAvatarSyncError( | 1862 sync_ui_util::GetMessagesForAvatarSyncError( |
| 1863 browser_->profile(), &contentStringId, &buttonStringId); | 1863 browser_->profile(), &contentStringId, &buttonStringId); |
| 1864 switch (error) { | 1864 switch (error) { |
| 1865 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR: | 1865 case sync_ui_util::MANAGED_USER_UNRECOVERABLE_ERROR: |
| 1866 buttonAction = @selector(showSignoutView:); | 1866 buttonAction = @selector(showSignoutView:); |
| 1867 break; | 1867 break; |
| 1868 case sync_ui_util::UNRECOVERABLE_ERROR: | 1868 case sync_ui_util::UNRECOVERABLE_ERROR: |
| 1869 buttonAction = @selector(showSignoutSigninView:); | 1869 buttonAction = @selector(showSignoutSigninView:); |
| 1870 break; | 1870 break; |
| 1871 case sync_ui_util::SUPERVISED_USER_AUTH_ERROR: |
| 1872 buttonAction = nil; |
| 1873 break; |
| 1871 case sync_ui_util::AUTH_ERROR: | 1874 case sync_ui_util::AUTH_ERROR: |
| 1872 buttonAction = @selector(showAccountReauthenticationView:); | 1875 buttonAction = @selector(showAccountReauthenticationView:); |
| 1873 break; | 1876 break; |
| 1874 case sync_ui_util::UPGRADE_CLIENT_ERROR: | 1877 case sync_ui_util::UPGRADE_CLIENT_ERROR: |
| 1875 buttonAction = @selector(showUpdateChromeView:); | 1878 buttonAction = @selector(showUpdateChromeView:); |
| 1876 break; | 1879 break; |
| 1877 case sync_ui_util::PASSPHRASE_ERROR: | 1880 case sync_ui_util::PASSPHRASE_ERROR: |
| 1878 buttonAction = @selector(showSyncPassphraseSetupView:); | 1881 buttonAction = @selector(showSyncPassphraseSetupView:); |
| 1879 break; | 1882 break; |
| 1880 case sync_ui_util::NO_SYNC_ERROR: | 1883 case sync_ui_util::NO_SYNC_ERROR: |
| 1881 return nil; | 1884 return nil; |
| 1882 default: | 1885 default: |
| 1883 NOTREACHED(); | 1886 NOTREACHED(); |
| 1884 } | 1887 } |
| 1885 return [self buildSyncErrorViewWithContent:contentStringId | 1888 return [self buildSyncErrorViewWithContent:contentStringId |
| 1886 buttonStringId:buttonStringId | 1889 buttonStringId:buttonStringId |
| 1887 buttonAction:buttonAction]; | 1890 buttonAction:buttonAction]; |
| 1888 } | 1891 } |
| 1889 | 1892 |
| 1890 - (NSView*)buildSyncErrorViewWithContent:(int)contentStringId | 1893 - (NSView*)buildSyncErrorViewWithContent:(int)contentStringId |
| 1891 buttonStringId:(int)buttonStringId | 1894 buttonStringId:(int)buttonStringId |
| 1892 buttonAction:(SEL)buttonAction { | 1895 buttonAction:(SEL)buttonAction { |
| 1893 base::scoped_nsobject<NSView> container( | 1896 base::scoped_nsobject<NSView> container( |
| 1894 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, GetFixedMenuWidth(), 0)]); | 1897 [[NSView alloc] initWithFrame:NSMakeRect(0, 0, GetFixedMenuWidth(), 0)]); |
| 1895 CGFloat iconSize = 20.0; | 1898 CGFloat iconSize = 20.0; |
| 1896 CGFloat xOffset = kHorizontalSpacing + iconSize + 12.0; | 1899 CGFloat xOffset = kHorizontalSpacing + iconSize + 12.0; |
| 1897 CGFloat availableWidth = GetFixedMenuWidth() - xOffset - kHorizontalSpacing; | 1900 CGFloat availableWidth = GetFixedMenuWidth() - xOffset - kHorizontalSpacing; |
| 1898 CGFloat yOffset = 20.0; | 1901 CGFloat yOffset = 16.0; |
| 1899 | 1902 |
| 1900 // Adds an action button for resolving the error at the bottom. | 1903 // Adds an action button for resolving the error at the bottom. |
| 1901 base::scoped_nsobject<NSButton> resolveErrorButton( | 1904 if (buttonStringId) { |
| 1902 [[BlueLabelButton alloc] initWithFrame:NSZeroRect]); | 1905 DCHECK(buttonAction); |
| 1903 [resolveErrorButton setTitle:l10n_util::GetNSString(buttonStringId)]; | 1906 base::scoped_nsobject<NSButton> resolveErrorButton( |
| 1904 [resolveErrorButton setTarget:self]; | 1907 [[BlueLabelButton alloc] initWithFrame:NSZeroRect]); |
| 1905 [resolveErrorButton setAction:buttonAction]; | 1908 [resolveErrorButton setTitle:l10n_util::GetNSString(buttonStringId)]; |
| 1906 [resolveErrorButton setAlignment:NSCenterTextAlignment]; | 1909 [resolveErrorButton setTarget:self]; |
| 1907 [resolveErrorButton sizeToFit]; | 1910 [resolveErrorButton setAction:buttonAction]; |
| 1908 [resolveErrorButton setFrameOrigin:NSMakePoint(xOffset, yOffset)]; | 1911 [resolveErrorButton setAlignment:NSCenterTextAlignment]; |
| 1909 [container addSubview:resolveErrorButton]; | 1912 [resolveErrorButton sizeToFit]; |
| 1910 yOffset = NSMaxY([resolveErrorButton frame]) + kVerticalSpacing; | 1913 [resolveErrorButton setFrameOrigin:NSMakePoint(xOffset, yOffset + 4.0)]; |
| 1914 [container addSubview:resolveErrorButton]; |
| 1915 yOffset = NSMaxY([resolveErrorButton frame]) + kVerticalSpacing; |
| 1916 } |
| 1911 | 1917 |
| 1912 // Adds the error message content. | 1918 // Adds the error message content. |
| 1913 NSTextField* contentLabel = | 1919 NSTextField* contentLabel = |
| 1914 BuildLabel(l10n_util::GetNSString(contentStringId), | 1920 BuildLabel(l10n_util::GetNSString(contentStringId), |
| 1915 NSMakePoint(xOffset, yOffset), nil); | 1921 NSMakePoint(xOffset, yOffset), nil); |
| 1916 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; | 1922 [contentLabel setFrameSize:NSMakeSize(availableWidth, 0)]; |
| 1917 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; | 1923 [GTMUILocalizerAndLayoutTweaker sizeToFitFixedWidthTextField:contentLabel]; |
| 1918 [container addSubview:contentLabel]; | 1924 [container addSubview:contentLabel]; |
| 1919 yOffset = NSMaxY([contentLabel frame]) + 4; | 1925 yOffset = NSMaxY([contentLabel frame]) + 4; |
| 1920 | 1926 |
| (...skipping 969 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2890 } | 2896 } |
| 2891 | 2897 |
| 2892 - (bool)shouldShowGoIncognito { | 2898 - (bool)shouldShowGoIncognito { |
| 2893 bool incognitoAvailable = | 2899 bool incognitoAvailable = |
| 2894 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != | 2900 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != |
| 2895 IncognitoModePrefs::DISABLED; | 2901 IncognitoModePrefs::DISABLED; |
| 2896 return incognitoAvailable && !browser_->profile()->IsGuestSession(); | 2902 return incognitoAvailable && !browser_->profile()->IsGuestSession(); |
| 2897 } | 2903 } |
| 2898 | 2904 |
| 2899 @end | 2905 @end |
| OLD | NEW |