1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef CHROME_BROWSER_UI_COCOA_ONE_CLICK_SIGNIN_VIEW_CONTROLLER_H_ 6 #define CHROME_BROWSER_UI_COCOA_ONE_CLICK_SIGNIN_VIEW_CONTROLLER_H_ 7 8 #import <Cocoa/Cocoa.h> 9 10 #include "base/callback.h" 11 #include "base/mac/scoped_nsobject.h" 12 #include "chrome/browser/ui/browser_window.h" 13 14 @class BrowserWindowController; 15 namespace content { 16 class WebContents; 17 } 18 @class HyperlinkTextView; 19 20 // View controller for the one-click signin confirmation UI. 21 @interface OneClickSigninViewController : NSViewController<NSTextViewDelegate> { 22 @private 23 IBOutlet NSTextField* messageTextField_; 24 IBOutlet NSTextField* informativePlaceholderTextField_; 25 IBOutlet NSButton* advancedLink_; 26 IBOutlet NSButton* closeButton_; 27 28 // This is YES if this is the modal sync confirmation dialog. 29 BOOL isSyncDialog_; 30 31 // This is YES if the user clicked the Learn More link before another action. 32 BOOL clickedLearnMore_; 33 34 // The user's email address to be used for sync. 35 string16 email_; 36 37 // Alternate error message to be displayed. 38 base::scoped_nsobject<NSString> errorMessage_; 39 40 // Text fields don't work as well with embedded links as text views, but 41 // text views cannot conveniently be created in IB. The xib file contains 42 // a text field |informativePlaceholderTextField_| that's replaced by this 43 // text view |promo_| in -awakeFromNib. 44 base::scoped_nsobject<HyperlinkTextView> informativeTextView_; 45 BrowserWindow::StartSyncCallback startSyncCallback_; 46 base::Closure closeCallback_; 47 content::WebContents* webContents_; 48 } 49 50 // Initializes the controller from a nib file, with an alternate |errorMessage| 51 // that can be displayed in the case of an authentication error. 52 // |syncCallback| is called to start sync for the given |email|, if 53 // |isSyncDialog| is YES. |webContents| is used to open the Learn More and 54 // Advanced links and |callback| is called when the view is closing. 55 - (id)initWithNibName:(NSString*)nibName 56 webContents:(content::WebContents*)webContents 57 syncCallback:(const BrowserWindow::StartSyncCallback&)syncCallback 58 closeCallback:(const base::Closure&)callback 59 isSyncDialog:(BOOL)isSyncDialog 60 email:(const string16&)email 61 errorMessage:(NSString*)errorMessage; 62 63 // Called before the view is closed. 64 - (void)viewWillClose; 65 66 // Starts sync and closes the bubble. 67 - (IBAction)ok:(id)sender; 68 69 // Starts sync and closes the bubble. 70 - (IBAction)onClickClose:(id)sender; 71 72 // Does not start sync and closes the bubble. 73 - (IBAction)onClickUndo:(id)sender; 74 75 // Calls |advancedCallback_|. 76 - (IBAction)onClickAdvancedLink:(id)sender; 77 78 @end 79 80 #endif // CHROME_BROWSER_UI_COCOA_ONE_CLICK_SIGNIN_VIEW_CONTROLLER_H_ 81