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