- add sources.
[platform/framework/web/crosswalk.git] / src / content / shell / browser / shell_login_dialog.h
1 // Copyright 2013 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 CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_
7
8 #include "base/compiler_specific.h"
9 #include "base/strings/string16.h"
10 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
11
12 #if defined(TOOLKIT_GTK)
13 #include "ui/base/gtk/gtk_signal.h"
14 #endif
15
16 #if defined(OS_MACOSX)
17 #if __OBJC__
18 @class ShellLoginDialogHelper;
19 #else
20 class ShellLoginDialogHelper;
21 #endif  // __OBJC__
22 #endif  // defined(OS_MACOSX)
23
24 namespace net {
25 class AuthChallengeInfo;
26 class URLRequest;
27 }
28
29 namespace content {
30
31 // This class provides a dialog box to ask the user for credentials. Useful in
32 // ResourceDispatcherHostDelegate::CreateLoginDelegate.
33 class ShellLoginDialog : public ResourceDispatcherHostLoginDelegate {
34  public:
35   // Threading: IO thread.
36   ShellLoginDialog(net::AuthChallengeInfo* auth_info, net::URLRequest* request);
37
38   // ResourceDispatcherHostLoginDelegate implementation:
39   // Threading: IO thread.
40   virtual void OnRequestCancelled() OVERRIDE;
41
42   // Called by the platform specific code when the user responds. Public because
43   // the aforementioned platform specific code may not have access to private
44   // members. Not to be called from client code.
45   // Threading: UI thread.
46   void UserAcceptedAuth(const string16& username, const string16& password);
47   void UserCancelledAuth();
48
49  protected:
50   // Threading: any
51   virtual ~ShellLoginDialog();
52
53  private:
54   // All the methods that begin with Platform need to be implemented by the
55   // platform specific LoginDialog implementation.
56   // Creates the dialog.
57   // Threading: UI thread.
58   void PlatformCreateDialog(const string16& message);
59   // Called from the destructor to let each platform do any necessary cleanup.
60   // Threading: UI thread.
61   void PlatformCleanUp();
62   // Called from OnRequestCancelled if the request was cancelled.
63   // Threading: UI thread.
64   void PlatformRequestCancelled();
65
66   // Sets up dialog creation.
67   // Threading: UI thread.
68   void PrepDialog(const string16& host, const string16& realm);
69
70   // Sends the authentication to the requester.
71   // Threading: IO thread.
72   void SendAuthToRequester(bool success,
73                            const string16& username,
74                            const string16& password);
75
76   // Who/where/what asked for the authentication.
77   // Threading: IO thread.
78   scoped_refptr<net::AuthChallengeInfo> auth_info_;
79
80   // The request that wants login data.
81   // Threading: IO thread.
82   net::URLRequest* request_;
83
84 #if defined(OS_MACOSX)
85   // Threading: UI thread.
86   ShellLoginDialogHelper* helper_;  // owned
87 #elif defined(TOOLKIT_GTK)
88   GtkWidget* username_entry_;
89   GtkWidget* password_entry_;
90   GtkWidget* root_;
91   CHROMEGTK_CALLBACK_1(ShellLoginDialog, void, OnResponse, int);
92 #endif
93 };
94
95 }  // namespace content
96
97 #endif  // CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_