CefSchemeRegistrar.cs 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. namespace Xilium.CefGlue
  2. {
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Diagnostics;
  6. using System.Runtime.InteropServices;
  7. using Xilium.CefGlue.Interop;
  8. /// <summary>
  9. /// Class that manages custom scheme registrations.
  10. /// </summary>
  11. public sealed unsafe partial class CefSchemeRegistrar
  12. {
  13. internal void ReleaseObject()
  14. {
  15. _self = null;
  16. }
  17. /// <summary>
  18. /// Register a custom scheme. This method should not be called for the built-in
  19. /// HTTP, HTTPS, FILE, FTP, ABOUT and DATA schemes.
  20. /// See cef_scheme_options_t for possible values for |options|.
  21. /// This function may be called on any thread. It should only be called once
  22. /// per unique |scheme_name| value. If |scheme_name| is already registered or
  23. /// if an error occurs this method will return false.
  24. /// </summary>
  25. public bool AddCustomScheme(string schemeName, CefSchemeOptions options)
  26. {
  27. if (schemeName == null) throw new ArgumentNullException("schemeName");
  28. fixed (char* schemeName_str = schemeName)
  29. {
  30. var n_schemeName = new cef_string_t(schemeName_str, schemeName.Length);
  31. return cef_scheme_registrar_t.add_custom_scheme(
  32. _self,
  33. &n_schemeName,
  34. (int)options
  35. ) != 0;
  36. }
  37. }
  38. }
  39. }