AuthRequestedEventArgs.cs 1.7 KB

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