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