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.
5 #ifndef CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_
6 #define CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_
8 #include "base/compiler_specific.h"
9 #include "base/strings/string16.h"
10 #include "content/public/browser/resource_dispatcher_host_login_delegate.h"
12 #if defined(TOOLKIT_GTK)
13 #include "ui/base/gtk/gtk_signal.h"
16 #if defined(OS_MACOSX)
18 @
class ShellLoginDialogHelper
;
20 class ShellLoginDialogHelper
;
22 #endif // defined(OS_MACOSX)
25 class AuthChallengeInfo
;
31 // This class provides a dialog box to ask the user for credentials. Useful in
32 // ResourceDispatcherHostDelegate::CreateLoginDelegate.
33 class ShellLoginDialog
: public ResourceDispatcherHostLoginDelegate
{
35 // Threading: IO thread.
36 ShellLoginDialog(net::AuthChallengeInfo
* auth_info
, net::URLRequest
* request
);
38 // ResourceDispatcherHostLoginDelegate implementation:
39 // Threading: IO thread.
40 virtual void OnRequestCancelled() OVERRIDE
;
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();
51 virtual ~ShellLoginDialog();
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();
66 // Sets up dialog creation.
67 // Threading: UI thread.
68 void PrepDialog(const string16
& host
, const string16
& realm
);
70 // Sends the authentication to the requester.
71 // Threading: IO thread.
72 void SendAuthToRequester(bool success
,
73 const string16
& username
,
74 const string16
& password
);
76 // Who/where/what asked for the authentication.
77 // Threading: IO thread.
78 scoped_refptr
<net::AuthChallengeInfo
> auth_info_
;
80 // The request that wants login data.
81 // Threading: IO thread.
82 net::URLRequest
* request_
;
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_
;
91 CHROMEGTK_CALLBACK_1(ShellLoginDialog
, void, OnResponse
, int);
95 } // namespace content
97 #endif // CONTENT_SHELL_BROWSER_SHELL_LOGIN_DIALOG_H_