Chromium Code Reviews| Index: chrome/browser/ui/cocoa/one_click_signin_view_controller.mm |
| diff --git a/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm b/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm |
| index 05a43e94d20ad86bfb515f2a455a9e5c7b5ad165..2c9a9a2f66f879dc995a94999059ffd01003a435 100644 |
| --- a/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm |
| +++ b/chrome/browser/ui/cocoa/one_click_signin_view_controller.mm |
| @@ -35,42 +35,60 @@ void ShiftOriginY(NSView* view, CGFloat amount) { |
| @implementation OneClickSigninViewController |
| + |
| - (id)initWithNibName:(NSString*)nibName |
| webContents:(content::WebContents*)webContents |
| syncCallback:(const BrowserWindow::StartSyncCallback&)syncCallback |
| - closeCallback:(const base::Closure&)closeCallback { |
| + closeCallback:(const base::Closure&)closeCallback |
| + isSyncDialog:(BOOL)isSyncDialog |
| + errorMessage:(NSString*)errorMessage { |
| if ((self = [super initWithNibName:nibName |
| bundle:base::mac::FrameworkBundle()])) { |
| webContents_ = webContents; |
| startSyncCallback_ = syncCallback; |
| closeCallback_ = closeCallback; |
| - DCHECK(!startSyncCallback_.is_null()); |
| + isSyncDialog_ = isSyncDialog; |
| + errorMessage_ = errorMessage; |
| + |
| + if (isSyncDialog_) |
| + DCHECK(!startSyncCallback_.is_null()); |
| } |
| return self; |
| } |
| - (void)viewWillClose { |
| - if (!startSyncCallback_.is_null()) { |
| + if (isSyncDialog_ && !startSyncCallback_.is_null()) { |
| base::ResetAndReturn(&startSyncCallback_).Run( |
| OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
| } |
| } |
| - (IBAction)ok:(id)sender { |
| - base::ResetAndReturn(&startSyncCallback_).Run( |
| + if (isSyncDialog_) { |
| + base::ResetAndReturn(&startSyncCallback_).Run( |
| OneClickSigninSyncStarter::SYNC_WITH_DEFAULT_SETTINGS); |
| + } |
| [self close]; |
| } |
| - (IBAction)onClickUndo:(id)sender { |
| - base::ResetAndReturn(&startSyncCallback_).Run( |
| - OneClickSigninSyncStarter::UNDO_SYNC); |
| + if (isSyncDialog_) { |
| + base::ResetAndReturn(&startSyncCallback_).Run( |
| + OneClickSigninSyncStarter::UNDO_SYNC); |
| + } |
| [self close]; |
| } |
| - (IBAction)onClickAdvancedLink:(id)sender { |
| - base::ResetAndReturn(&startSyncCallback_).Run( |
| - OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| + if (isSyncDialog_) { |
| + base::ResetAndReturn(&startSyncCallback_).Run( |
| + OneClickSigninSyncStarter::CONFIGURE_SYNC_FIRST); |
| + } else { |
| + content::OpenURLParams params(GURL(chrome::kChromeUISettingsURL), |
| + content::Referrer(), CURRENT_TAB, |
| + content::PAGE_TRANSITION_LINK, false); |
| + webContents_->OpenURL(params); |
| + } |
| [self close]; |
| } |
| @@ -98,6 +116,9 @@ void ShiftOriginY(NSView* view, CGFloat amount) { |
| NSSize delta = NSMakeSize(0.0, totalYOffset); |
| + if (!isSyncDialog_ && [errorMessage_ length] != 0) |
| + [messageTextField_ setStringValue:errorMessage_]; |
| + |
| // Resize bubble and window to hold the controls. |
| [GTMUILocalizerAndLayoutTweaker |
| resizeViewWithoutAutoResizingSubViews:[self view] |
| @@ -119,11 +140,23 @@ void ShiftOriginY(NSView* view, CGFloat amount) { |
| // Set the text. |
| NSString* learnMoreText = l10n_util::GetNSStringWithFixup(IDS_LEARN_MORE); |
| - NSString* messageText = |
| - l10n_util::GetNSStringWithFixup(IDS_ONE_CLICK_SIGNIN_DIALOG_MESSAGE); |
| - messageText = [messageText stringByAppendingString:@" "]; |
| + NSString* messageText; |
| + |
| + ui::ResourceBundle::FontStyle fontStyle = isSyncDialog_ ? |
| + chrome_style::kTextFontStyle : ui::ResourceBundle::SmallFont; |
| NSFont* font = ui::ResourceBundle::GetSharedInstance().GetFont( |
| - chrome_style::kTextFontStyle).GetNativeFont(); |
| + fontStyle).GetNativeFont(); |
| + |
| + // The non-modal bubble already has a text content and only needs the |
| + // Learn More link (in a smaller font). |
| + if (isSyncDialog_) { |
| + messageText = l10n_util::GetNSStringWithFixup( |
| + IDS_ONE_CLICK_SIGNIN_DIALOG_MESSAGE); |
| + messageText = [messageText stringByAppendingString:@" "]; |
|
Alexei Svitkine (slow)
2013/04/22 18:16:51
What the reason for appending a space here?
noms (inactive)
2013/04/23 18:52:48
In the modal dialog, the Learn More link is append
|
| + } else { |
| + messageText = @""; |
| + } |
| + |
| NSColor* linkColor = |
| gfx::SkColorToCalibratedNSColor(chrome_style::GetLinkColor()); |
| [informativeTextView_ setMessageAndLink:messageText |
| @@ -153,8 +186,11 @@ void ShiftOriginY(NSView* view, CGFloat amount) { |
| - (BOOL)textView:(NSTextView*)textView |
| clickedOnLink:(id)link |
| atIndex:(NSUInteger)charIndex { |
| + WindowOpenDisposition location = isSyncDialog_ ? |
| + NEW_WINDOW : NEW_FOREGROUND_TAB; |
| + |
| content::OpenURLParams params(GURL(chrome::kChromeSyncLearnMoreURL), |
| - content::Referrer(), NEW_WINDOW, |
| + content::Referrer(), location, |
| content::PAGE_TRANSITION_LINK, false); |
| webContents_->OpenURL(params); |
| return YES; |