IWithDownloads.cs 2.2 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. /// An interface implemented by a webview if it supports file downloads.
  20. /// </summary>
  21. /// <example>
  22. /// var webViewWithDownloads = webViewPrefab.WebView as IWithDownloads;
  23. /// if (webViewWithDownloads != null) {
  24. /// webViewWithDownloads.SetDownloadsEnabled(true);
  25. /// webViewWithDownloads.DownloadProgressChanged += (sender, eventArgs) => {
  26. /// Debug.Log(
  27. /// $@"DownloadProgressChanged:
  28. /// Type: {eventArgs.Type},
  29. /// Url: {eventArgs.Url},
  30. /// Progress: {eventArgs.Progress},
  31. /// FilePath: {eventArgs.FilePath},
  32. /// ContentType: {eventArgs.ContentType}"
  33. /// );
  34. /// if (eventArgs.Type == ProgressChangeType.Finished) {
  35. /// Debug.Log("Download finished");
  36. /// File.Move(eventArgs.FilePath, someOtherLocation);
  37. /// }
  38. /// };
  39. /// }
  40. /// </example>
  41. public interface IWithDownloads {
  42. /// <summary>
  43. /// Sets whether file downloads are enabled. The default is disabled.
  44. /// </summary>
  45. void SetDownloadsEnabled(bool enabled);
  46. /// <summary>
  47. /// Indicates that the progress of a file download changed. Files are downloaded to
  48. /// Application.temporaryCachePath, but you can move them to a different
  49. /// location after they finish downloading
  50. /// </summary>
  51. event EventHandler<DownloadChangedEventArgs> DownloadProgressChanged;
  52. }
  53. }