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