IWithSettableUserAgent.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. namespace Vuplex.WebView {
  15. /// <summary>
  16. /// An interface implemented by a webview if it supports changing the
  17. /// [User-Agent](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent) of
  18. /// an individual webview instance.
  19. /// </summary>
  20. /// <example>
  21. /// <code>
  22. /// await webViewPrefab.WaitUntilInitialized();
  23. /// var webViewWithUserAgent = webViewPrefab.WebView as IWithSettableUserAgent;
  24. /// if (webViewWithUserAgent != null) {
  25. /// // Set a flag indicating a mobile User-Agent.
  26. /// webViewWithUserAgent.SetUserAgent(true);
  27. /// // OR set a custom User-Agent string.
  28. /// webViewWithUserAgent.SetUserAgent("Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Firefox/91.0");
  29. /// }
  30. /// </code>
  31. /// </example>
  32. /// <seealso cref="Web.SetUserAgent"/>
  33. public interface IWithSettableUserAgent {
  34. /// <summary>
  35. /// Configures the webview instance to use a mobile or desktop
  36. /// [User-Agent](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent).
  37. /// By default, webviews use the browser engine's default User-Agent, but you
  38. /// can force them to use a mobile User-Agent by calling `SetUserAgent(true)` or a
  39. /// desktop User-Agent with `SetUserAgent(false)`.
  40. /// </summary>
  41. void SetUserAgent(bool mobile);
  42. /// <summary>
  43. /// Configures the webview instance to use a custom.
  44. /// [User-Agent](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent).
  45. /// </summary>
  46. void SetUserAgent(string userAgent);
  47. }
  48. }