StandaloneCookieManager.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Copyright (c) 2022 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. #if UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX
  15. using System.Threading.Tasks;
  16. namespace Vuplex.WebView {
  17. /// <summary>
  18. /// The ICookieManager implementation for Windows and macOS.
  19. /// </summary>
  20. public class StandaloneCookieManager : ICookieManager {
  21. public static StandaloneCookieManager Instance {
  22. get {
  23. if (_instance == null) {
  24. _instance = new StandaloneCookieManager();
  25. }
  26. return _instance;
  27. }
  28. }
  29. public Task<bool> DeleteCookies(string url, string cookieName = null) => StandaloneWebView.DeleteCookies(url, cookieName);
  30. public Task<Cookie[]> GetCookies(string url, string cookieName = null) => StandaloneWebView.GetCookies(url, cookieName);
  31. public Task<bool> SetCookie(Cookie cookie) => StandaloneWebView.SetCookie(cookie);
  32. static StandaloneCookieManager _instance;
  33. }
  34. }
  35. #endif