-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathUnityAppWebBrowser.cs
More file actions
59 lines (52 loc) · 1.93 KB
/
Copy pathUnityAppWebBrowser.cs
File metadata and controls
59 lines (52 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
using DCL.Multiplayer.Connections.DecentralandUrls;
using Global.AppArgs;
using System;
using UnityEngine;
#if ALTTESTER
using DCL.Diagnostics;
using System.IO;
#endif
namespace DCL.Browser
{
public class UnityAppWebBrowser : IWebBrowser
{
private readonly IDecentralandUrlsSource decentralandUrlsSource;
private readonly IAppArgs? appArgs;
public UnityAppWebBrowser(IDecentralandUrlsSource decentralandUrlsSource, IAppArgs? appArgs = null)
{
this.decentralandUrlsSource = decentralandUrlsSource;
this.appArgs = appArgs;
}
public void OpenUrl(string url)
{
var escaped = Uri.EscapeUriString(url);
#if ALTTESTER
// Only skip the system browser when an AltTester cross-stack test is actually driving
// this session (client launched with --alttester). Those tests read auth-url.txt and
// navigate their own browser. Without the flag — Editor and dev/QA standalone builds,
// which all carry the ALTTESTER compile define — we must still open the browser or
// wallet login can never complete. The block is stripped from release builds entirely.
if (appArgs?.HasFlag(AppArgsFlags.ALTTESTER) == true)
{
try
{
var path = Path.Combine(Application.persistentDataPath, "auth-url.txt");
File.WriteAllText(path, escaped);
}
catch (Exception e)
{
ReportHub.LogException(e, ReportCategory.AUTHENTICATION);
}
return;
}
#endif
Application.OpenURL(escaped);
}
public void OpenUrl(DecentralandUrl url)
{
OpenUrl(decentralandUrlsSource.Url(url));
}
public string GetUrl(DecentralandUrl url) =>
decentralandUrlsSource.Url(url);
}
}