MockCookieManager.cs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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.Threading.Tasks;
  15. namespace Vuplex.WebView {
  16. /// <summary>
  17. /// Mock ICookieManager implementation used for running in the Unity editor.
  18. /// </summary>
  19. class MockCookieManager : ICookieManager {
  20. public static MockCookieManager Instance {
  21. get {
  22. if (_instance == null) {
  23. _instance = new MockCookieManager();
  24. }
  25. return _instance;
  26. }
  27. }
  28. public Task<bool> DeleteCookies(string url, string cookieName = null) => MockWebView.DeleteCookies(url, cookieName);
  29. public Task<Cookie[]> GetCookies(string url, string cookieName = null) => MockWebView.GetCookies(url, cookieName);
  30. public Task<bool> SetCookie(Cookie cookie) => MockWebView.SetCookie(cookie);
  31. static MockCookieManager _instance;
  32. }
  33. }