AuthRequestedEventArgs.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright (c) 2024 Vuplex Inc. All rights reserved.
  2. //
  3. // Licensed under the Vuplex Commercial Software Library License, you may
  4. // not use this file except in compliance with the License. You may obtain
  5. // a copy of the License at
  6. //
  7. // https://vuplex.com/commercial-library-license
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. using System;
  15. namespace Vuplex.WebView {
  16. /// <summary>
  17. /// Event args for IWithAuth.AuthRequested. Either Continue() or Cancel() must be called in order
  18. /// to resume the page.
  19. /// </summary>
  20. public class AuthRequestedEventArgs : EventArgs {
  21. public AuthRequestedEventArgs(string host, bool isProxy, Action<string, string> continueCallback, Action cancelCallback) {
  22. Host = host;
  23. IsProxy = isProxy;
  24. _continueCallback = continueCallback;
  25. _cancelCallback = cancelCallback;
  26. }
  27. /// <summary>
  28. /// The host that requested authentication.
  29. /// </summary>
  30. public readonly string Host;
  31. /// <summary>
  32. /// Indicates whether the auth request is for connecting to a proxy server.
  33. /// </summary>
  34. public readonly bool IsProxy;
  35. /// <summary>
  36. /// Declines authentication and resumes the page.
  37. /// </summary>
  38. public void Cancel() => _cancelCallback();
  39. /// <summary>
  40. /// Sends the credentials for authentication.
  41. /// </summary>
  42. public void Continue(string username, string password) => _continueCallback(username, password);
  43. Action _cancelCallback;
  44. Action<string, string> _continueCallback;
  45. }
  46. }