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;
15namespace content {
16class 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* titleTextField_;
25  IBOutlet NSTextField* informativePlaceholderTextField_;
26  IBOutlet NSButton* advancedLink_;
27  IBOutlet NSButton* closeButton_;
28
29  // This is YES if this is the modal sync confirmation dialog.
30  BOOL isSyncDialog_;
31
32  // This is YES if the user clicked the Learn More link before another action.
33  BOOL clickedLearnMore_;
34
35  // The user's email address to be used for sync.
36  base::string16 email_;
37
38  // Alternate error message to be displayed.
39  base::scoped_nsobject<NSString> errorMessage_;
40
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_;
49}
50
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;
63
64// Called before the view is closed.
65- (void)viewWillClose;
66
67// Starts sync and closes the bubble.
68- (IBAction)ok:(id)sender;
69
70// Starts sync and closes the bubble.
71- (IBAction)onClickClose:(id)sender;
72
73// Does not start sync and closes the bubble.
74- (IBAction)onClickUndo:(id)sender;
75
76// Calls |advancedCallback_|.
77- (IBAction)onClickAdvancedLink:(id)sender;
78
79@end
80
81#endif  // CHROME_BROWSER_UI_COCOA_ONE_CLICK_SIGNIN_VIEW_CONTROLLER_H_
82