diff --git a/CefSharp.Example/CefSharp.Example.csproj b/CefSharp.Example/CefSharp.Example.csproj index 3937e4a777..4ecb652932 100644 --- a/CefSharp.Example/CefSharp.Example.csproj +++ b/CefSharp.Example/CefSharp.Example.csproj @@ -76,7 +76,6 @@ - diff --git a/CefSharp.Example/DevTools/DevToolsExtensions.cs b/CefSharp.Example/DevTools/DevToolsExtensions.cs index c382c1134c..e759ac460b 100644 --- a/CefSharp.Example/DevTools/DevToolsExtensions.cs +++ b/CefSharp.Example/DevTools/DevToolsExtensions.cs @@ -1,6 +1,4 @@ using System; -using System.Text; -using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; @@ -8,7 +6,6 @@ namespace CefSharp.Example.DevTools { public static class DevToolsExtensions { - private static int LastMessageId = 600000; /// /// Calls Page.captureScreenshot without any optional params /// (Results in PNG image of default viewport) @@ -23,11 +20,11 @@ public static async Task CaptureScreenShotAsPng(this IWebBrowser chromiu // throw new System.Exception("Page hasn't loaded"); //} - var host = chromiumWebBrowser.GetBrowserHost(); + var browser = chromiumWebBrowser.GetBrowser(); - if (host == null || host.IsDisposed) + if (browser == null || browser.IsDisposed) { - throw new Exception("BrowserHost is Null or Disposed"); + throw new Exception("browser is Null or Disposed"); } //var param = new Dictionary @@ -35,46 +32,17 @@ public static async Task CaptureScreenShotAsPng(this IWebBrowser chromiu // { "format", "png" }, //} - var msgId = Interlocked.Increment(ref LastMessageId); - - var observer = new TaskMethodDevToolsMessageObserver(msgId); - //Make sure to dispose of our observer registration when done - //TODO: Create a single observer that maps tasks to Id's - //Or at least create one for each type, events and method - using (var observerRegistration = host.AddDevToolsMessageObserver(observer)) + using (var devToolsClient = browser.GetDevToolsClient()) { - //Page.captureScreenshot defaults to PNG, all params are optional - //for this DevTools method - int id = 0; const string methodName = "Page.captureScreenshot"; - //TODO: Simplify this, we can use an Func to reduce code duplication - if (Cef.CurrentlyOnThread(CefThreadIds.TID_UI)) - { - id = host.ExecuteDevToolsMethod(msgId, methodName); - } - else - { - id = await Cef.UIThreadTaskFactory.StartNew(() => - { - return host.ExecuteDevToolsMethod(msgId, methodName); - }); - } - - if (id != msgId) - { - throw new Exception("Message Id doesn't match the provided Id"); - } - - var result = await observer.Task; - - var success = result.Item1; + var result = await devToolsClient.ExecuteDevToolsMethodAsync(methodName); - dynamic response = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(result.Item2)); + dynamic response = JsonConvert.DeserializeObject(result.ResultAsJsonString); //Success - if (success) + if (result.Success) { return Convert.FromBase64String((string)response.data); } diff --git a/CefSharp.Example/DevTools/TaskMethodDevToolsMessageObserver.cs b/CefSharp.Example/DevTools/TaskMethodDevToolsMessageObserver.cs deleted file mode 100644 index 714f9f5a34..0000000000 --- a/CefSharp.Example/DevTools/TaskMethodDevToolsMessageObserver.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.IO; -using System.Threading.Tasks; -using CefSharp.Callback; - -namespace CefSharp.Example.DevTools -{ - /// - /// For capturing the response from a DevTools Method - /// (Doesn't handle DevTools events) - /// - public class TaskMethodDevToolsMessageObserver : IDevToolsMessageObserver - { - private readonly TaskCompletionSource> taskCompletionSource = new TaskCompletionSource>(TaskCreationOptions.RunContinuationsAsynchronously); - private readonly int matchMessageId; - - public TaskMethodDevToolsMessageObserver(int messageId) - { - matchMessageId = messageId; - } - - void IDisposable.Dispose() - { - - } - - void IDevToolsMessageObserver.OnDevToolsAgentAttached(IBrowser browser) - { - - } - - void IDevToolsMessageObserver.OnDevToolsAgentDetached(IBrowser browser) - { - - } - - void IDevToolsMessageObserver.OnDevToolsEvent(IBrowser browser, string method, Stream parameters) - { - - } - - bool IDevToolsMessageObserver.OnDevToolsMessage(IBrowser browser, Stream message) - { - return false; - } - - void IDevToolsMessageObserver.OnDevToolsMethodResult(IBrowser browser, int messageId, bool success, Stream result) - { - //We found the message Id we're after - if (matchMessageId == messageId) - { - var memoryStream = new MemoryStream((int)result.Length); - - result.CopyTo(memoryStream); - - var response = Tuple.Create(success, memoryStream.ToArray()); - - taskCompletionSource.TrySetResult(response); - } - } - - public Task> Task - { - get { return taskCompletionSource.Task; } - } - } -} diff --git a/CefSharp.OffScreen.Example/Program.cs b/CefSharp.OffScreen.Example/Program.cs index 8311176326..0deccd9924 100644 --- a/CefSharp.OffScreen.Example/Program.cs +++ b/CefSharp.OffScreen.Example/Program.cs @@ -77,6 +77,13 @@ private static async void MainAsync(string cachePath, double zoomLevel) } await LoadPageAsync(browser); + using (var devToolsClient = browser.GetDevToolsClient()) + { + var response = await devToolsClient.Browser.GetVersionAsync(); + var jsVersion = response.JsVersion; + //var success = await devToolsClient.Network.ClearBrowserCacheAsync(); + } + //Check preferences on the CEF UI Thread await Cef.UIThreadTaskFactory.StartNew(delegate { diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj index 336428ff2e..f95b8ccabf 100644 --- a/CefSharp/CefSharp.csproj +++ b/CefSharp/CefSharp.csproj @@ -104,6 +104,234 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CefSharp/DevTools/Browser/Bounds.cs b/CefSharp/DevTools/Browser/Bounds.cs new file mode 100644 index 0000000000..8159e9e285 --- /dev/null +++ b/CefSharp/DevTools/Browser/Bounds.cs @@ -0,0 +1,61 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + /// + /// Browser window bounds information + /// + public class Bounds : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The offset from the left edge of the screen to the window in pixels. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("left"), IsRequired = (false))] + public int? Left + { + get; + set; + } + + /// + /// The offset from the top edge of the screen to the window in pixels. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("top"), IsRequired = (false))] + public int? Top + { + get; + set; + } + + /// + /// The window width in pixels. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("width"), IsRequired = (false))] + public int? Width + { + get; + set; + } + + /// + /// The window height in pixels. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("height"), IsRequired = (false))] + public int? Height + { + get; + set; + } + + /// + /// The window state. Default to normal. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("windowState"), IsRequired = (false))] + public string WindowState + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Browser/Browser.cs b/CefSharp/DevTools/Browser/Browser.cs new file mode 100644 index 0000000000..c73d6f0415 --- /dev/null +++ b/CefSharp/DevTools/Browser/Browser.cs @@ -0,0 +1,39 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + using System.Linq; + + /// + /// The Browser domain defines methods and events for browser managing. + /// + public partial class Browser : DevToolsDomainBase + { + public Browser(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Close browser gracefully. + /// + public async System.Threading.Tasks.Task CloseAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Browser.close", dict); + return result; + } + + /// + /// Returns version information. + /// + public async System.Threading.Tasks.Task GetVersionAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Browser.getVersion", dict); + return result.DeserializeJson(); + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Browser/Bucket.cs b/CefSharp/DevTools/Browser/Bucket.cs new file mode 100644 index 0000000000..b7b9ad1df6 --- /dev/null +++ b/CefSharp/DevTools/Browser/Bucket.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + /// + /// Chrome histogram bucket. + /// + public class Bucket : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Minimum value (inclusive). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("low"), IsRequired = (true))] + public int Low + { + get; + set; + } + + /// + /// Maximum value (exclusive). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("high"), IsRequired = (true))] + public int High + { + get; + set; + } + + /// + /// Number of samples. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("count"), IsRequired = (true))] + public int Count + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Browser/Enums/PermissionSetting.cs b/CefSharp/DevTools/Browser/Enums/PermissionSetting.cs new file mode 100644 index 0000000000..6c03d262d3 --- /dev/null +++ b/CefSharp/DevTools/Browser/Enums/PermissionSetting.cs @@ -0,0 +1,27 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + /// + /// PermissionSetting + /// + public enum PermissionSetting + { + /// + /// granted + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("granted"))] + Granted, + /// + /// denied + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("denied"))] + Denied, + /// + /// prompt + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("prompt"))] + Prompt + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Browser/Enums/PermissionType.cs b/CefSharp/DevTools/Browser/Enums/PermissionType.cs new file mode 100644 index 0000000000..17e408e00b --- /dev/null +++ b/CefSharp/DevTools/Browser/Enums/PermissionType.cs @@ -0,0 +1,117 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + /// + /// PermissionType + /// + public enum PermissionType + { + /// + /// accessibilityEvents + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("accessibilityEvents"))] + AccessibilityEvents, + /// + /// audioCapture + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("audioCapture"))] + AudioCapture, + /// + /// backgroundSync + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("backgroundSync"))] + BackgroundSync, + /// + /// backgroundFetch + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("backgroundFetch"))] + BackgroundFetch, + /// + /// clipboardReadWrite + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("clipboardReadWrite"))] + ClipboardReadWrite, + /// + /// clipboardSanitizedWrite + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("clipboardSanitizedWrite"))] + ClipboardSanitizedWrite, + /// + /// durableStorage + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("durableStorage"))] + DurableStorage, + /// + /// flash + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("flash"))] + Flash, + /// + /// geolocation + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("geolocation"))] + Geolocation, + /// + /// midi + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("midi"))] + Midi, + /// + /// midiSysex + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("midiSysex"))] + MidiSysex, + /// + /// nfc + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("nfc"))] + Nfc, + /// + /// notifications + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("notifications"))] + Notifications, + /// + /// paymentHandler + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("paymentHandler"))] + PaymentHandler, + /// + /// periodicBackgroundSync + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("periodicBackgroundSync"))] + PeriodicBackgroundSync, + /// + /// protectedMediaIdentifier + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("protectedMediaIdentifier"))] + ProtectedMediaIdentifier, + /// + /// sensors + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("sensors"))] + Sensors, + /// + /// videoCapture + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("videoCapture"))] + VideoCapture, + /// + /// idleDetection + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("idleDetection"))] + IdleDetection, + /// + /// wakeLockScreen + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("wakeLockScreen"))] + WakeLockScreen, + /// + /// wakeLockSystem + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("wakeLockSystem"))] + WakeLockSystem + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Browser/Enums/WindowState.cs b/CefSharp/DevTools/Browser/Enums/WindowState.cs new file mode 100644 index 0000000000..a35033a0be --- /dev/null +++ b/CefSharp/DevTools/Browser/Enums/WindowState.cs @@ -0,0 +1,32 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + /// + /// The state of the browser window. + /// + public enum WindowState + { + /// + /// normal + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("normal"))] + Normal, + /// + /// minimized + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("minimized"))] + Minimized, + /// + /// maximized + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("maximized"))] + Maximized, + /// + /// fullscreen + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("fullscreen"))] + Fullscreen + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Browser/GetVersionResponse.cs b/CefSharp/DevTools/Browser/GetVersionResponse.cs new file mode 100644 index 0000000000..c429a92d55 --- /dev/null +++ b/CefSharp/DevTools/Browser/GetVersionResponse.cs @@ -0,0 +1,102 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + /// + /// GetVersionResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetVersionResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string protocolVersion + { + get; + set; + } + + /// + /// Protocol version. + /// + public string ProtocolVersion + { + get + { + return protocolVersion; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string product + { + get; + set; + } + + /// + /// Product name. + /// + public string Product + { + get + { + return product; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string revision + { + get; + set; + } + + /// + /// Product revision. + /// + public string Revision + { + get + { + return revision; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string userAgent + { + get; + set; + } + + /// + /// User-Agent. + /// + public string UserAgent + { + get + { + return userAgent; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string jsVersion + { + get; + set; + } + + /// + /// V8 version. + /// + public string JsVersion + { + get + { + return jsVersion; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Browser/Histogram.cs b/CefSharp/DevTools/Browser/Histogram.cs new file mode 100644 index 0000000000..43a91c9d2d --- /dev/null +++ b/CefSharp/DevTools/Browser/Histogram.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + /// + /// Chrome histogram. + /// + public class Histogram : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Sum of sample values. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sum"), IsRequired = (true))] + public int Sum + { + get; + set; + } + + /// + /// Total number of samples. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("count"), IsRequired = (true))] + public int Count + { + get; + set; + } + + /// + /// Buckets. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("buckets"), IsRequired = (true))] + public System.Collections.Generic.IList Buckets + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Browser/PermissionDescriptor.cs b/CefSharp/DevTools/Browser/PermissionDescriptor.cs new file mode 100644 index 0000000000..fe2f3b7b95 --- /dev/null +++ b/CefSharp/DevTools/Browser/PermissionDescriptor.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Browser +{ + /// + /// Definition of PermissionDescriptor defined in the Permissions API: + public class PermissionDescriptor : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Name of permission. + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// For "midi" permission, may also specify sysex control. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sysex"), IsRequired = (false))] + public bool? Sysex + { + get; + set; + } + + /// + /// For "push" permission, may specify userVisibleOnly. + [System.Runtime.Serialization.DataMemberAttribute(Name = ("userVisibleOnly"), IsRequired = (false))] + public bool? UserVisibleOnly + { + get; + set; + } + + /// + /// For "clipboard" permission, may specify allowWithoutSanitization. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("allowWithoutSanitization"), IsRequired = (false))] + public bool? AllowWithoutSanitization + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Console/Console.cs b/CefSharp/DevTools/Console/Console.cs new file mode 100644 index 0000000000..292d8c412c --- /dev/null +++ b/CefSharp/DevTools/Console/Console.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Console +{ + using System.Linq; + + /// + /// This domain is deprecated - use Runtime or Log instead. + /// + public partial class Console : DevToolsDomainBase + { + public Console(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Does nothing. + /// + public async System.Threading.Tasks.Task ClearMessagesAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Console.clearMessages", dict); + return result; + } + + /// + /// Disables console domain, prevents further console messages from being reported to the client. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Console.disable", dict); + return result; + } + + /// + /// Enables console domain, sends the messages collected so far to the client by means of the + public async System.Threading.Tasks.Task EnableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Console.enable", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Console/ConsoleMessage.cs b/CefSharp/DevTools/Console/ConsoleMessage.cs new file mode 100644 index 0000000000..13481c4362 --- /dev/null +++ b/CefSharp/DevTools/Console/ConsoleMessage.cs @@ -0,0 +1,71 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Console +{ + /// + /// Console message. + /// + public class ConsoleMessage : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Message source. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("source"), IsRequired = (true))] + public string Source + { + get; + set; + } + + /// + /// Message severity. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("level"), IsRequired = (true))] + public string Level + { + get; + set; + } + + /// + /// Message text. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("text"), IsRequired = (true))] + public string Text + { + get; + set; + } + + /// + /// URL of the message origin. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (false))] + public string Url + { + get; + set; + } + + /// + /// Line number in the resource that generated this message (1-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("line"), IsRequired = (false))] + public int? Line + { + get; + set; + } + + /// + /// Column number in the resource that generated this message (1-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("column"), IsRequired = (false))] + public int? Column + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/BackendNode.cs b/CefSharp/DevTools/DOM/BackendNode.cs new file mode 100644 index 0000000000..e2298a0f5c --- /dev/null +++ b/CefSharp/DevTools/DOM/BackendNode.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// Backend node with a friendly name. + /// + public class BackendNode : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// `Node`'s nodeType. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("nodeType"), IsRequired = (true))] + public int NodeType + { + get; + set; + } + + /// + /// `Node`'s nodeName. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("nodeName"), IsRequired = (true))] + public string NodeName + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("backendNodeId"), IsRequired = (true))] + public int BackendNodeId + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/BoxModel.cs b/CefSharp/DevTools/DOM/BoxModel.cs new file mode 100644 index 0000000000..9793cb68b1 --- /dev/null +++ b/CefSharp/DevTools/DOM/BoxModel.cs @@ -0,0 +1,81 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// Box model. + /// + public class BoxModel : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Content box + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("content"), IsRequired = (true))] + public long Content + { + get; + set; + } + + /// + /// Padding box + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("padding"), IsRequired = (true))] + public long Padding + { + get; + set; + } + + /// + /// Border box + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("border"), IsRequired = (true))] + public long Border + { + get; + set; + } + + /// + /// Margin box + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("margin"), IsRequired = (true))] + public long Margin + { + get; + set; + } + + /// + /// Node width + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("width"), IsRequired = (true))] + public int Width + { + get; + set; + } + + /// + /// Node height + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("height"), IsRequired = (true))] + public int Height + { + get; + set; + } + + /// + /// Shape outside coordinates + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("shapeOutside"), IsRequired = (false))] + public ShapeOutsideInfo ShapeOutside + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/CSSComputedStyleProperty.cs b/CefSharp/DevTools/DOM/CSSComputedStyleProperty.cs new file mode 100644 index 0000000000..d812a4d8d0 --- /dev/null +++ b/CefSharp/DevTools/DOM/CSSComputedStyleProperty.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// CSSComputedStyleProperty + /// + public class CSSComputedStyleProperty : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Computed style property name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Computed style property value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public string Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/DOM.cs b/CefSharp/DevTools/DOM/DOM.cs new file mode 100644 index 0000000000..19a25f16e3 --- /dev/null +++ b/CefSharp/DevTools/DOM/DOM.cs @@ -0,0 +1,463 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + using System.Linq; + + /// + /// This domain exposes DOM read/write operations. Each DOM Node is represented with its mirror object + public partial class DOM : DevToolsDomainBase + { + public DOM(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Describes node given its id, does not require domain to be enabled. Does not start tracking any + public async System.Threading.Tasks.Task DescribeNodeAsync(int? nodeId = null, int? backendNodeId = null, string objectId = null, int? depth = null, bool? pierce = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (nodeId.HasValue) + { + dict.Add("nodeId", nodeId.Value); + } + + if (backendNodeId.HasValue) + { + dict.Add("backendNodeId", backendNodeId.Value); + } + + if (!(string.IsNullOrEmpty(objectId))) + { + dict.Add("objectId", objectId); + } + + if (depth.HasValue) + { + dict.Add("depth", depth.Value); + } + + if (pierce.HasValue) + { + dict.Add("pierce", pierce.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.describeNode", dict); + return result.DeserializeJson(); + } + + /// + /// Disables DOM agent for the given page. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("DOM.disable", dict); + return result; + } + + /// + /// Enables DOM agent for the given page. + /// + public async System.Threading.Tasks.Task EnableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("DOM.enable", dict); + return result; + } + + /// + /// Focuses the given element. + /// + public async System.Threading.Tasks.Task FocusAsync(int? nodeId = null, int? backendNodeId = null, string objectId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (nodeId.HasValue) + { + dict.Add("nodeId", nodeId.Value); + } + + if (backendNodeId.HasValue) + { + dict.Add("backendNodeId", backendNodeId.Value); + } + + if (!(string.IsNullOrEmpty(objectId))) + { + dict.Add("objectId", objectId); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.focus", dict); + return result; + } + + /// + /// Returns attributes for the specified node. + /// + public async System.Threading.Tasks.Task GetAttributesAsync(int nodeId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.getAttributes", dict); + return result.DeserializeJson(); + } + + /// + /// Returns boxes for the given node. + /// + public async System.Threading.Tasks.Task GetBoxModelAsync(int? nodeId = null, int? backendNodeId = null, string objectId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (nodeId.HasValue) + { + dict.Add("nodeId", nodeId.Value); + } + + if (backendNodeId.HasValue) + { + dict.Add("backendNodeId", backendNodeId.Value); + } + + if (!(string.IsNullOrEmpty(objectId))) + { + dict.Add("objectId", objectId); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.getBoxModel", dict); + return result.DeserializeJson(); + } + + /// + /// Returns the root DOM node (and optionally the subtree) to the caller. + /// + public async System.Threading.Tasks.Task GetDocumentAsync(int? depth = null, bool? pierce = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (depth.HasValue) + { + dict.Add("depth", depth.Value); + } + + if (pierce.HasValue) + { + dict.Add("pierce", pierce.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.getDocument", dict); + return result.DeserializeJson(); + } + + /// + /// Returns the root DOM node (and optionally the subtree) to the caller. + public async System.Threading.Tasks.Task GetFlattenedDocumentAsync(int? depth = null, bool? pierce = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (depth.HasValue) + { + dict.Add("depth", depth.Value); + } + + if (pierce.HasValue) + { + dict.Add("pierce", pierce.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.getFlattenedDocument", dict); + return result.DeserializeJson(); + } + + /// + /// Returns node id at given location. Depending on whether DOM domain is enabled, nodeId is + public async System.Threading.Tasks.Task GetNodeForLocationAsync(int x, int y, bool? includeUserAgentShadowDOM = null, bool? ignorePointerEventsNone = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("x", x); + dict.Add("y", y); + if (includeUserAgentShadowDOM.HasValue) + { + dict.Add("includeUserAgentShadowDOM", includeUserAgentShadowDOM.Value); + } + + if (ignorePointerEventsNone.HasValue) + { + dict.Add("ignorePointerEventsNone", ignorePointerEventsNone.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.getNodeForLocation", dict); + return result.DeserializeJson(); + } + + /// + /// Returns node's HTML markup. + /// + public async System.Threading.Tasks.Task GetOuterHTMLAsync(int? nodeId = null, int? backendNodeId = null, string objectId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (nodeId.HasValue) + { + dict.Add("nodeId", nodeId.Value); + } + + if (backendNodeId.HasValue) + { + dict.Add("backendNodeId", backendNodeId.Value); + } + + if (!(string.IsNullOrEmpty(objectId))) + { + dict.Add("objectId", objectId); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.getOuterHTML", dict); + return result.DeserializeJson(); + } + + /// + /// Hides any highlight. + /// + public async System.Threading.Tasks.Task HideHighlightAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("DOM.hideHighlight", dict); + return result; + } + + /// + /// Highlights DOM node. + /// + public async System.Threading.Tasks.Task HighlightNodeAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("DOM.highlightNode", dict); + return result; + } + + /// + /// Highlights given rectangle. + /// + public async System.Threading.Tasks.Task HighlightRectAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("DOM.highlightRect", dict); + return result; + } + + /// + /// Moves node into the new container, places it before the given anchor. + /// + public async System.Threading.Tasks.Task MoveToAsync(int nodeId, int targetNodeId, int? insertBeforeNodeId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("targetNodeId", targetNodeId); + if (insertBeforeNodeId.HasValue) + { + dict.Add("insertBeforeNodeId", insertBeforeNodeId.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.moveTo", dict); + return result.DeserializeJson(); + } + + /// + /// Executes `querySelector` on a given node. + /// + public async System.Threading.Tasks.Task QuerySelectorAsync(int nodeId, string selector) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("selector", selector); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.querySelector", dict); + return result.DeserializeJson(); + } + + /// + /// Executes `querySelectorAll` on a given node. + /// + public async System.Threading.Tasks.Task QuerySelectorAllAsync(int nodeId, string selector) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("selector", selector); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.querySelectorAll", dict); + return result.DeserializeJson(); + } + + /// + /// Removes attribute with given name from an element with given id. + /// + public async System.Threading.Tasks.Task RemoveAttributeAsync(int nodeId, string name) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("name", name); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.removeAttribute", dict); + return result; + } + + /// + /// Removes node with given id. + /// + public async System.Threading.Tasks.Task RemoveNodeAsync(int nodeId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.removeNode", dict); + return result; + } + + /// + /// Requests that children of the node with given id are returned to the caller in form of + public async System.Threading.Tasks.Task RequestChildNodesAsync(int nodeId, int? depth = null, bool? pierce = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + if (depth.HasValue) + { + dict.Add("depth", depth.Value); + } + + if (pierce.HasValue) + { + dict.Add("pierce", pierce.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.requestChildNodes", dict); + return result; + } + + /// + /// Requests that the node is sent to the caller given the JavaScript node object reference. All + public async System.Threading.Tasks.Task RequestNodeAsync(string objectId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("objectId", objectId); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.requestNode", dict); + return result.DeserializeJson(); + } + + /// + /// Resolves the JavaScript node object for a given NodeId or BackendNodeId. + /// + public async System.Threading.Tasks.Task ResolveNodeAsync(int? nodeId = null, int? backendNodeId = null, string objectGroup = null, int? executionContextId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (nodeId.HasValue) + { + dict.Add("nodeId", nodeId.Value); + } + + if (backendNodeId.HasValue) + { + dict.Add("backendNodeId", backendNodeId.Value); + } + + if (!(string.IsNullOrEmpty(objectGroup))) + { + dict.Add("objectGroup", objectGroup); + } + + if (executionContextId.HasValue) + { + dict.Add("executionContextId", executionContextId.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.resolveNode", dict); + return result.DeserializeJson(); + } + + /// + /// Sets attribute for an element with given id. + /// + public async System.Threading.Tasks.Task SetAttributeValueAsync(int nodeId, string name, string value) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("name", name); + dict.Add("value", value); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.setAttributeValue", dict); + return result; + } + + /// + /// Sets attributes on element with given id. This method is useful when user edits some existing + public async System.Threading.Tasks.Task SetAttributesAsTextAsync(int nodeId, string text, string name = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("text", text); + if (!(string.IsNullOrEmpty(name))) + { + dict.Add("name", name); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.setAttributesAsText", dict); + return result; + } + + /// + /// Sets files for the given file input element. + /// + public async System.Threading.Tasks.Task SetFileInputFilesAsync(string files, int? nodeId = null, int? backendNodeId = null, string objectId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("files", files); + if (nodeId.HasValue) + { + dict.Add("nodeId", nodeId.Value); + } + + if (backendNodeId.HasValue) + { + dict.Add("backendNodeId", backendNodeId.Value); + } + + if (!(string.IsNullOrEmpty(objectId))) + { + dict.Add("objectId", objectId); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOM.setFileInputFiles", dict); + return result; + } + + /// + /// Sets node name for a node with given id. + /// + public async System.Threading.Tasks.Task SetNodeNameAsync(int nodeId, string name) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("name", name); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.setNodeName", dict); + return result.DeserializeJson(); + } + + /// + /// Sets node value for a node with given id. + /// + public async System.Threading.Tasks.Task SetNodeValueAsync(int nodeId, string value) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("value", value); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.setNodeValue", dict); + return result; + } + + /// + /// Sets node HTML markup, returns new node id. + /// + public async System.Threading.Tasks.Task SetOuterHTMLAsync(int nodeId, string outerHTML) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("outerHTML", outerHTML); + var result = await _client.ExecuteDevToolsMethodAsync("DOM.setOuterHTML", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/DescribeNodeResponse.cs b/CefSharp/DevTools/DOM/DescribeNodeResponse.cs new file mode 100644 index 0000000000..c3fdffe1df --- /dev/null +++ b/CefSharp/DevTools/DOM/DescribeNodeResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// DescribeNodeResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class DescribeNodeResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal Node node + { + get; + set; + } + + /// + /// Node description. + /// + public Node Node + { + get + { + return node; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/Enums/PseudoType.cs b/CefSharp/DevTools/DOM/Enums/PseudoType.cs new file mode 100644 index 0000000000..478efd7e5b --- /dev/null +++ b/CefSharp/DevTools/DOM/Enums/PseudoType.cs @@ -0,0 +1,92 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// Pseudo element type. + /// + public enum PseudoType + { + /// + /// first-line + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("first-line"))] + FirstLine, + /// + /// first-letter + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("first-letter"))] + FirstLetter, + /// + /// before + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("before"))] + Before, + /// + /// after + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("after"))] + After, + /// + /// marker + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("marker"))] + Marker, + /// + /// backdrop + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("backdrop"))] + Backdrop, + /// + /// selection + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("selection"))] + Selection, + /// + /// first-line-inherited + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("first-line-inherited"))] + FirstLineInherited, + /// + /// scrollbar + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("scrollbar"))] + Scrollbar, + /// + /// scrollbar-thumb + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("scrollbar-thumb"))] + ScrollbarThumb, + /// + /// scrollbar-button + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("scrollbar-button"))] + ScrollbarButton, + /// + /// scrollbar-track + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("scrollbar-track"))] + ScrollbarTrack, + /// + /// scrollbar-track-piece + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("scrollbar-track-piece"))] + ScrollbarTrackPiece, + /// + /// scrollbar-corner + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("scrollbar-corner"))] + ScrollbarCorner, + /// + /// resizer + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("resizer"))] + Resizer, + /// + /// input-list-button + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("input-list-button"))] + InputListButton + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/Enums/ShadowRootType.cs b/CefSharp/DevTools/DOM/Enums/ShadowRootType.cs new file mode 100644 index 0000000000..1cb152952a --- /dev/null +++ b/CefSharp/DevTools/DOM/Enums/ShadowRootType.cs @@ -0,0 +1,27 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// Shadow root type. + /// + public enum ShadowRootType + { + /// + /// user-agent + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("user-agent"))] + UserAgent, + /// + /// open + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("open"))] + Open, + /// + /// closed + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("closed"))] + Closed + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/GetAttributesResponse.cs b/CefSharp/DevTools/DOM/GetAttributesResponse.cs new file mode 100644 index 0000000000..f327cb6ae0 --- /dev/null +++ b/CefSharp/DevTools/DOM/GetAttributesResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// GetAttributesResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetAttributesResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string attributes + { + get; + set; + } + + /// + /// An interleaved array of node attribute names and values. + /// + public string Attributes + { + get + { + return attributes; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/GetBoxModelResponse.cs b/CefSharp/DevTools/DOM/GetBoxModelResponse.cs new file mode 100644 index 0000000000..cc31df2e8c --- /dev/null +++ b/CefSharp/DevTools/DOM/GetBoxModelResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// GetBoxModelResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetBoxModelResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal BoxModel model + { + get; + set; + } + + /// + /// Box model for the node. + /// + public BoxModel Model + { + get + { + return model; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/GetDocumentResponse.cs b/CefSharp/DevTools/DOM/GetDocumentResponse.cs new file mode 100644 index 0000000000..e2e221fb3a --- /dev/null +++ b/CefSharp/DevTools/DOM/GetDocumentResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// GetDocumentResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetDocumentResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal Node root + { + get; + set; + } + + /// + /// Resulting node. + /// + public Node Root + { + get + { + return root; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/GetFlattenedDocumentResponse.cs b/CefSharp/DevTools/DOM/GetFlattenedDocumentResponse.cs new file mode 100644 index 0000000000..7f5cb62b0f --- /dev/null +++ b/CefSharp/DevTools/DOM/GetFlattenedDocumentResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// GetFlattenedDocumentResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetFlattenedDocumentResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList nodes + { + get; + set; + } + + /// + /// Resulting node. + /// + public System.Collections.Generic.IList Nodes + { + get + { + return nodes; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/GetNodeForLocationResponse.cs b/CefSharp/DevTools/DOM/GetNodeForLocationResponse.cs new file mode 100644 index 0000000000..a2a95f0d8e --- /dev/null +++ b/CefSharp/DevTools/DOM/GetNodeForLocationResponse.cs @@ -0,0 +1,66 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// GetNodeForLocationResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetNodeForLocationResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal int backendNodeId + { + get; + set; + } + + /// + /// Resulting node. + /// + public int BackendNodeId + { + get + { + return backendNodeId; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string frameId + { + get; + set; + } + + /// + /// Frame this node belongs to. + /// + public string FrameId + { + get + { + return frameId; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal int? nodeId + { + get; + set; + } + + /// + /// Id of the node at given coordinates, only when enabled and requested document. + /// + public int? NodeId + { + get + { + return nodeId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/GetOuterHTMLResponse.cs b/CefSharp/DevTools/DOM/GetOuterHTMLResponse.cs new file mode 100644 index 0000000000..4b6f24a239 --- /dev/null +++ b/CefSharp/DevTools/DOM/GetOuterHTMLResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// GetOuterHTMLResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetOuterHTMLResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string outerHTML + { + get; + set; + } + + /// + /// Outer HTML markup. + /// + public string OuterHTML + { + get + { + return outerHTML; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/MoveToResponse.cs b/CefSharp/DevTools/DOM/MoveToResponse.cs new file mode 100644 index 0000000000..23705da1b1 --- /dev/null +++ b/CefSharp/DevTools/DOM/MoveToResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// MoveToResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class MoveToResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal int nodeId + { + get; + set; + } + + /// + /// New id of the moved node. + /// + public int NodeId + { + get + { + return nodeId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/Node.cs b/CefSharp/DevTools/DOM/Node.cs new file mode 100644 index 0000000000..be44a61fa7 --- /dev/null +++ b/CefSharp/DevTools/DOM/Node.cs @@ -0,0 +1,289 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. + public class Node : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Node identifier that is passed into the rest of the DOM messages as the `nodeId`. Backend + [System.Runtime.Serialization.DataMemberAttribute(Name = ("nodeId"), IsRequired = (true))] + public int NodeId + { + get; + set; + } + + /// + /// The id of the parent node if any. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("parentId"), IsRequired = (false))] + public int? ParentId + { + get; + set; + } + + /// + /// The BackendNodeId for this node. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("backendNodeId"), IsRequired = (true))] + public int BackendNodeId + { + get; + set; + } + + /// + /// `Node`'s nodeType. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("nodeType"), IsRequired = (true))] + public int NodeType + { + get; + set; + } + + /// + /// `Node`'s nodeName. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("nodeName"), IsRequired = (true))] + public string NodeName + { + get; + set; + } + + /// + /// `Node`'s localName. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("localName"), IsRequired = (true))] + public string LocalName + { + get; + set; + } + + /// + /// `Node`'s nodeValue. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("nodeValue"), IsRequired = (true))] + public string NodeValue + { + get; + set; + } + + /// + /// Child count for `Container` nodes. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("childNodeCount"), IsRequired = (false))] + public int? ChildNodeCount + { + get; + set; + } + + /// + /// Child nodes of this node when requested with children. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("children"), IsRequired = (false))] + public System.Collections.Generic.IList Children + { + get; + set; + } + + /// + /// Attributes of the `Element` node in the form of flat array `[name1, value1, name2, value2]`. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("attributes"), IsRequired = (false))] + public string Attributes + { + get; + set; + } + + /// + /// Document URL that `Document` or `FrameOwner` node points to. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("documentURL"), IsRequired = (false))] + public string DocumentURL + { + get; + set; + } + + /// + /// Base URL that `Document` or `FrameOwner` node uses for URL completion. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("baseURL"), IsRequired = (false))] + public string BaseURL + { + get; + set; + } + + /// + /// `DocumentType`'s publicId. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("publicId"), IsRequired = (false))] + public string PublicId + { + get; + set; + } + + /// + /// `DocumentType`'s systemId. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("systemId"), IsRequired = (false))] + public string SystemId + { + get; + set; + } + + /// + /// `DocumentType`'s internalSubset. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("internalSubset"), IsRequired = (false))] + public string InternalSubset + { + get; + set; + } + + /// + /// `Document`'s XML version in case of XML documents. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("xmlVersion"), IsRequired = (false))] + public string XmlVersion + { + get; + set; + } + + /// + /// `Attr`'s name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (false))] + public string Name + { + get; + set; + } + + /// + /// `Attr`'s value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (false))] + public string Value + { + get; + set; + } + + /// + /// Pseudo element type for this node. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pseudoType"), IsRequired = (false))] + public string PseudoType + { + get; + set; + } + + /// + /// Shadow root type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("shadowRootType"), IsRequired = (false))] + public string ShadowRootType + { + get; + set; + } + + /// + /// Frame ID for frame owner elements. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("frameId"), IsRequired = (false))] + public string FrameId + { + get; + set; + } + + /// + /// Content document for frame owner elements. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("contentDocument"), IsRequired = (false))] + public Node ContentDocument + { + get; + set; + } + + /// + /// Shadow root list for given element host. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("shadowRoots"), IsRequired = (false))] + public System.Collections.Generic.IList ShadowRoots + { + get; + set; + } + + /// + /// Content document fragment for template elements. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("templateContent"), IsRequired = (false))] + public Node TemplateContent + { + get; + set; + } + + /// + /// Pseudo elements associated with this node. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pseudoElements"), IsRequired = (false))] + public System.Collections.Generic.IList PseudoElements + { + get; + set; + } + + /// + /// Import document for the HTMLImport links. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("importedDocument"), IsRequired = (false))] + public Node ImportedDocument + { + get; + set; + } + + /// + /// Distributed nodes for given insertion point. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("distributedNodes"), IsRequired = (false))] + public System.Collections.Generic.IList DistributedNodes + { + get; + set; + } + + /// + /// Whether the node is SVG. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("isSVG"), IsRequired = (false))] + public bool? IsSVG + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/QuerySelectorAllResponse.cs b/CefSharp/DevTools/DOM/QuerySelectorAllResponse.cs new file mode 100644 index 0000000000..0c4ecf47af --- /dev/null +++ b/CefSharp/DevTools/DOM/QuerySelectorAllResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// QuerySelectorAllResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class QuerySelectorAllResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal int nodeIds + { + get; + set; + } + + /// + /// Query selector result. + /// + public int NodeIds + { + get + { + return nodeIds; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/QuerySelectorResponse.cs b/CefSharp/DevTools/DOM/QuerySelectorResponse.cs new file mode 100644 index 0000000000..37c677363f --- /dev/null +++ b/CefSharp/DevTools/DOM/QuerySelectorResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// QuerySelectorResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class QuerySelectorResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal int nodeId + { + get; + set; + } + + /// + /// Query selector result. + /// + public int NodeId + { + get + { + return nodeId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/RGBA.cs b/CefSharp/DevTools/DOM/RGBA.cs new file mode 100644 index 0000000000..46ec405a42 --- /dev/null +++ b/CefSharp/DevTools/DOM/RGBA.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// A structure holding an RGBA color. + /// + public class RGBA : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The red component, in the [0-255] range. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("r"), IsRequired = (true))] + public int R + { + get; + set; + } + + /// + /// The green component, in the [0-255] range. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("g"), IsRequired = (true))] + public int G + { + get; + set; + } + + /// + /// The blue component, in the [0-255] range. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("b"), IsRequired = (true))] + public int B + { + get; + set; + } + + /// + /// The alpha component, in the [0-1] range (default: 1). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("a"), IsRequired = (false))] + public long? A + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/Rect.cs b/CefSharp/DevTools/DOM/Rect.cs new file mode 100644 index 0000000000..d7c496a1d3 --- /dev/null +++ b/CefSharp/DevTools/DOM/Rect.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// Rectangle. + /// + public class Rect : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// X coordinate + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("x"), IsRequired = (true))] + public long X + { + get; + set; + } + + /// + /// Y coordinate + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("y"), IsRequired = (true))] + public long Y + { + get; + set; + } + + /// + /// Rectangle width + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("width"), IsRequired = (true))] + public long Width + { + get; + set; + } + + /// + /// Rectangle height + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("height"), IsRequired = (true))] + public long Height + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/RequestNodeResponse.cs b/CefSharp/DevTools/DOM/RequestNodeResponse.cs new file mode 100644 index 0000000000..7695929f45 --- /dev/null +++ b/CefSharp/DevTools/DOM/RequestNodeResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// RequestNodeResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class RequestNodeResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal int nodeId + { + get; + set; + } + + /// + /// Node id for given object. + /// + public int NodeId + { + get + { + return nodeId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/ResolveNodeResponse.cs b/CefSharp/DevTools/DOM/ResolveNodeResponse.cs new file mode 100644 index 0000000000..352dab568e --- /dev/null +++ b/CefSharp/DevTools/DOM/ResolveNodeResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// ResolveNodeResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class ResolveNodeResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal Runtime.RemoteObject @object + { + get; + set; + } + + /// + /// JavaScript object wrapper for given node. + /// + public Runtime.RemoteObject Object + { + get + { + return @object; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/SetNodeNameResponse.cs b/CefSharp/DevTools/DOM/SetNodeNameResponse.cs new file mode 100644 index 0000000000..1c335e40d7 --- /dev/null +++ b/CefSharp/DevTools/DOM/SetNodeNameResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// SetNodeNameResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class SetNodeNameResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal int nodeId + { + get; + set; + } + + /// + /// New node's id. + /// + public int NodeId + { + get + { + return nodeId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOM/ShapeOutsideInfo.cs b/CefSharp/DevTools/DOM/ShapeOutsideInfo.cs new file mode 100644 index 0000000000..12af60db0d --- /dev/null +++ b/CefSharp/DevTools/DOM/ShapeOutsideInfo.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOM +{ + /// + /// CSS Shape Outside details. + /// + public class ShapeOutsideInfo : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Shape bounds + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("bounds"), IsRequired = (true))] + public long Bounds + { + get; + set; + } + + /// + /// Shape coordinate details + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("shape"), IsRequired = (true))] + public object Shape + { + get; + set; + } + + /// + /// Margin shape bounds + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("marginShape"), IsRequired = (true))] + public object MarginShape + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOMDebugger/DOMDebugger.cs b/CefSharp/DevTools/DOMDebugger/DOMDebugger.cs new file mode 100644 index 0000000000..fe36a766bf --- /dev/null +++ b/CefSharp/DevTools/DOMDebugger/DOMDebugger.cs @@ -0,0 +1,117 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOMDebugger +{ + using System.Linq; + + /// + /// DOM debugging allows setting breakpoints on particular DOM operations and events. JavaScript + public partial class DOMDebugger : DevToolsDomainBase + { + public DOMDebugger(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Returns event listeners of the given object. + /// + public async System.Threading.Tasks.Task GetEventListenersAsync(string objectId, int? depth = null, bool? pierce = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("objectId", objectId); + if (depth.HasValue) + { + dict.Add("depth", depth.Value); + } + + if (pierce.HasValue) + { + dict.Add("pierce", pierce.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOMDebugger.getEventListeners", dict); + return result.DeserializeJson(); + } + + /// + /// Removes DOM breakpoint that was set using `setDOMBreakpoint`. + /// + public async System.Threading.Tasks.Task RemoveDOMBreakpointAsync(int nodeId, string type) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("type", type); + var result = await _client.ExecuteDevToolsMethodAsync("DOMDebugger.removeDOMBreakpoint", dict); + return result; + } + + /// + /// Removes breakpoint on particular DOM event. + /// + public async System.Threading.Tasks.Task RemoveEventListenerBreakpointAsync(string eventName, string targetName = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("eventName", eventName); + if (!(string.IsNullOrEmpty(targetName))) + { + dict.Add("targetName", targetName); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOMDebugger.removeEventListenerBreakpoint", dict); + return result; + } + + /// + /// Removes breakpoint from XMLHttpRequest. + /// + public async System.Threading.Tasks.Task RemoveXHRBreakpointAsync(string url) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("url", url); + var result = await _client.ExecuteDevToolsMethodAsync("DOMDebugger.removeXHRBreakpoint", dict); + return result; + } + + /// + /// Sets breakpoint on particular operation with DOM. + /// + public async System.Threading.Tasks.Task SetDOMBreakpointAsync(int nodeId, string type) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("nodeId", nodeId); + dict.Add("type", type); + var result = await _client.ExecuteDevToolsMethodAsync("DOMDebugger.setDOMBreakpoint", dict); + return result; + } + + /// + /// Sets breakpoint on particular DOM event. + /// + public async System.Threading.Tasks.Task SetEventListenerBreakpointAsync(string eventName, string targetName = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("eventName", eventName); + if (!(string.IsNullOrEmpty(targetName))) + { + dict.Add("targetName", targetName); + } + + var result = await _client.ExecuteDevToolsMethodAsync("DOMDebugger.setEventListenerBreakpoint", dict); + return result; + } + + /// + /// Sets breakpoint on XMLHttpRequest. + /// + public async System.Threading.Tasks.Task SetXHRBreakpointAsync(string url) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("url", url); + var result = await _client.ExecuteDevToolsMethodAsync("DOMDebugger.setXHRBreakpoint", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOMDebugger/Enums/DOMBreakpointType.cs b/CefSharp/DevTools/DOMDebugger/Enums/DOMBreakpointType.cs new file mode 100644 index 0000000000..acef5d3276 --- /dev/null +++ b/CefSharp/DevTools/DOMDebugger/Enums/DOMBreakpointType.cs @@ -0,0 +1,27 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOMDebugger +{ + /// + /// DOM breakpoint type. + /// + public enum DOMBreakpointType + { + /// + /// subtree-modified + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("subtree-modified"))] + SubtreeModified, + /// + /// attribute-modified + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("attribute-modified"))] + AttributeModified, + /// + /// node-removed + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("node-removed"))] + NodeRemoved + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOMDebugger/EventListener.cs b/CefSharp/DevTools/DOMDebugger/EventListener.cs new file mode 100644 index 0000000000..b6314fd5cc --- /dev/null +++ b/CefSharp/DevTools/DOMDebugger/EventListener.cs @@ -0,0 +1,111 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOMDebugger +{ + /// + /// Object event listener. + /// + public class EventListener : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// `EventListener`'s type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// `EventListener`'s useCapture. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("useCapture"), IsRequired = (true))] + public bool UseCapture + { + get; + set; + } + + /// + /// `EventListener`'s passive flag. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("passive"), IsRequired = (true))] + public bool Passive + { + get; + set; + } + + /// + /// `EventListener`'s once flag. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("once"), IsRequired = (true))] + public bool Once + { + get; + set; + } + + /// + /// Script id of the handler code. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scriptId"), IsRequired = (true))] + public string ScriptId + { + get; + set; + } + + /// + /// Line number in the script (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (true))] + public int LineNumber + { + get; + set; + } + + /// + /// Column number in the script (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("columnNumber"), IsRequired = (true))] + public int ColumnNumber + { + get; + set; + } + + /// + /// Event handler function value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("handler"), IsRequired = (false))] + public Runtime.RemoteObject Handler + { + get; + set; + } + + /// + /// Event original handler function value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("originalHandler"), IsRequired = (false))] + public Runtime.RemoteObject OriginalHandler + { + get; + set; + } + + /// + /// Node the listener is added to (if any). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("backendNodeId"), IsRequired = (false))] + public int? BackendNodeId + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DOMDebugger/GetEventListenersResponse.cs b/CefSharp/DevTools/DOMDebugger/GetEventListenersResponse.cs new file mode 100644 index 0000000000..ce28f07739 --- /dev/null +++ b/CefSharp/DevTools/DOMDebugger/GetEventListenersResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.DOMDebugger +{ + /// + /// GetEventListenersResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetEventListenersResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList listeners + { + get; + set; + } + + /// + /// Array of relevant listeners. + /// + public System.Collections.Generic.IList Listeners + { + get + { + return listeners; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/BreakLocation.cs b/CefSharp/DevTools/Debugger/BreakLocation.cs new file mode 100644 index 0000000000..363c67b46e --- /dev/null +++ b/CefSharp/DevTools/Debugger/BreakLocation.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// BreakLocation + /// + public class BreakLocation : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Script identifier as reported in the `Debugger.scriptParsed`. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scriptId"), IsRequired = (true))] + public string ScriptId + { + get; + set; + } + + /// + /// Line number in the script (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (true))] + public int LineNumber + { + get; + set; + } + + /// + /// Column number in the script (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("columnNumber"), IsRequired = (false))] + public int? ColumnNumber + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (false))] + public string Type + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/CallFrame.cs b/CefSharp/DevTools/Debugger/CallFrame.cs new file mode 100644 index 0000000000..f79d66d67b --- /dev/null +++ b/CefSharp/DevTools/Debugger/CallFrame.cs @@ -0,0 +1,91 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// JavaScript call frame. Array of call frames form the call stack. + /// + public class CallFrame : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Call frame identifier. This identifier is only valid while the virtual machine is paused. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("callFrameId"), IsRequired = (true))] + public string CallFrameId + { + get; + set; + } + + /// + /// Name of the JavaScript function called on this call frame. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("functionName"), IsRequired = (true))] + public string FunctionName + { + get; + set; + } + + /// + /// Location in the source code. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("functionLocation"), IsRequired = (false))] + public Location FunctionLocation + { + get; + set; + } + + /// + /// Location in the source code. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("location"), IsRequired = (true))] + public Location Location + { + get; + set; + } + + /// + /// JavaScript script name or url. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// Scope chain for this call frame. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scopeChain"), IsRequired = (true))] + public System.Collections.Generic.IList ScopeChain + { + get; + set; + } + + /// + /// `this` object for this call frame. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("this"), IsRequired = (true))] + public Runtime.RemoteObject This + { + get; + set; + } + + /// + /// The value being returned, if the function is at return point. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("returnValue"), IsRequired = (false))] + public Runtime.RemoteObject ReturnValue + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/DebugSymbols.cs b/CefSharp/DevTools/Debugger/DebugSymbols.cs new file mode 100644 index 0000000000..e1f92ef9da --- /dev/null +++ b/CefSharp/DevTools/Debugger/DebugSymbols.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// Debug symbols available for a wasm script. + /// + public class DebugSymbols : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Type of the debug symbols. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// URL of the external symbol source. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("externalURL"), IsRequired = (false))] + public string ExternalURL + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/Debugger.cs b/CefSharp/DevTools/Debugger/Debugger.cs new file mode 100644 index 0000000000..4794c5807b --- /dev/null +++ b/CefSharp/DevTools/Debugger/Debugger.cs @@ -0,0 +1,396 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + using System.Linq; + + /// + /// Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing + public partial class Debugger : DevToolsDomainBase + { + public Debugger(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Continues execution until specific location is reached. + /// + public async System.Threading.Tasks.Task ContinueToLocationAsync(Location location, string targetCallFrames = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("location", location.ToDictionary()); + if (!(string.IsNullOrEmpty(targetCallFrames))) + { + dict.Add("targetCallFrames", targetCallFrames); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.continueToLocation", dict); + return result; + } + + /// + /// Disables debugger for given page. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.disable", dict); + return result; + } + + /// + /// Enables debugger for the given page. Clients should not assume that the debugging has been + public async System.Threading.Tasks.Task EnableAsync(long? maxScriptsCacheSize = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (maxScriptsCacheSize.HasValue) + { + dict.Add("maxScriptsCacheSize", maxScriptsCacheSize.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.enable", dict); + return result.DeserializeJson(); + } + + /// + /// Evaluates expression on a given call frame. + /// + public async System.Threading.Tasks.Task EvaluateOnCallFrameAsync(string callFrameId, string expression, string objectGroup = null, bool? includeCommandLineAPI = null, bool? silent = null, bool? returnByValue = null, bool? generatePreview = null, bool? throwOnSideEffect = null, long? timeout = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("callFrameId", callFrameId); + dict.Add("expression", expression); + if (!(string.IsNullOrEmpty(objectGroup))) + { + dict.Add("objectGroup", objectGroup); + } + + if (includeCommandLineAPI.HasValue) + { + dict.Add("includeCommandLineAPI", includeCommandLineAPI.Value); + } + + if (silent.HasValue) + { + dict.Add("silent", silent.Value); + } + + if (returnByValue.HasValue) + { + dict.Add("returnByValue", returnByValue.Value); + } + + if (generatePreview.HasValue) + { + dict.Add("generatePreview", generatePreview.Value); + } + + if (throwOnSideEffect.HasValue) + { + dict.Add("throwOnSideEffect", throwOnSideEffect.Value); + } + + if (timeout.HasValue) + { + dict.Add("timeout", timeout.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.evaluateOnCallFrame", dict); + return result.DeserializeJson(); + } + + /// + /// Returns possible locations for breakpoint. scriptId in start and end range locations should be + public async System.Threading.Tasks.Task GetPossibleBreakpointsAsync(Location start, Location end = null, bool? restrictToFunction = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("start", start.ToDictionary()); + if ((end) != (null)) + { + dict.Add("end", end.ToDictionary()); + } + + if (restrictToFunction.HasValue) + { + dict.Add("restrictToFunction", restrictToFunction.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.getPossibleBreakpoints", dict); + return result.DeserializeJson(); + } + + /// + /// Returns source for the script with given id. + /// + public async System.Threading.Tasks.Task GetScriptSourceAsync(string scriptId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("scriptId", scriptId); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.getScriptSource", dict); + return result.DeserializeJson(); + } + + /// + /// This command is deprecated. Use getScriptSource instead. + /// + public async System.Threading.Tasks.Task GetWasmBytecodeAsync(string scriptId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("scriptId", scriptId); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.getWasmBytecode", dict); + return result.DeserializeJson(); + } + + /// + /// Stops on the next JavaScript statement. + /// + public async System.Threading.Tasks.Task PauseAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.pause", dict); + return result; + } + + /// + /// Removes JavaScript breakpoint. + /// + public async System.Threading.Tasks.Task RemoveBreakpointAsync(string breakpointId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("breakpointId", breakpointId); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.removeBreakpoint", dict); + return result; + } + + /// + /// Restarts particular call frame from the beginning. + /// + public async System.Threading.Tasks.Task RestartFrameAsync(string callFrameId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("callFrameId", callFrameId); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.restartFrame", dict); + return result.DeserializeJson(); + } + + /// + /// Resumes JavaScript execution. + /// + public async System.Threading.Tasks.Task ResumeAsync(bool? terminateOnResume = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (terminateOnResume.HasValue) + { + dict.Add("terminateOnResume", terminateOnResume.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.resume", dict); + return result; + } + + /// + /// Searches for given string in script content. + /// + public async System.Threading.Tasks.Task SearchInContentAsync(string scriptId, string query, bool? caseSensitive = null, bool? isRegex = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("scriptId", scriptId); + dict.Add("query", query); + if (caseSensitive.HasValue) + { + dict.Add("caseSensitive", caseSensitive.Value); + } + + if (isRegex.HasValue) + { + dict.Add("isRegex", isRegex.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.searchInContent", dict); + return result.DeserializeJson(); + } + + /// + /// Enables or disables async call stacks tracking. + /// + public async System.Threading.Tasks.Task SetAsyncCallStackDepthAsync(int maxDepth) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("maxDepth", maxDepth); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setAsyncCallStackDepth", dict); + return result; + } + + /// + /// Sets JavaScript breakpoint at a given location. + /// + public async System.Threading.Tasks.Task SetBreakpointAsync(Location location, string condition = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("location", location.ToDictionary()); + if (!(string.IsNullOrEmpty(condition))) + { + dict.Add("condition", condition); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setBreakpoint", dict); + return result.DeserializeJson(); + } + + /// + /// Sets instrumentation breakpoint. + /// + public async System.Threading.Tasks.Task SetInstrumentationBreakpointAsync(string instrumentation) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("instrumentation", instrumentation); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setInstrumentationBreakpoint", dict); + return result.DeserializeJson(); + } + + /// + /// Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this + public async System.Threading.Tasks.Task SetBreakpointByUrlAsync(int lineNumber, string url = null, string urlRegex = null, string scriptHash = null, int? columnNumber = null, string condition = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("lineNumber", lineNumber); + if (!(string.IsNullOrEmpty(url))) + { + dict.Add("url", url); + } + + if (!(string.IsNullOrEmpty(urlRegex))) + { + dict.Add("urlRegex", urlRegex); + } + + if (!(string.IsNullOrEmpty(scriptHash))) + { + dict.Add("scriptHash", scriptHash); + } + + if (columnNumber.HasValue) + { + dict.Add("columnNumber", columnNumber.Value); + } + + if (!(string.IsNullOrEmpty(condition))) + { + dict.Add("condition", condition); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setBreakpointByUrl", dict); + return result.DeserializeJson(); + } + + /// + /// Activates / deactivates all breakpoints on the page. + /// + public async System.Threading.Tasks.Task SetBreakpointsActiveAsync(bool active) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("active", active); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setBreakpointsActive", dict); + return result; + } + + /// + /// Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or + public async System.Threading.Tasks.Task SetPauseOnExceptionsAsync(string state) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("state", state); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setPauseOnExceptions", dict); + return result; + } + + /// + /// Edits JavaScript source live. + /// + public async System.Threading.Tasks.Task SetScriptSourceAsync(string scriptId, string scriptSource, bool? dryRun = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("scriptId", scriptId); + dict.Add("scriptSource", scriptSource); + if (dryRun.HasValue) + { + dict.Add("dryRun", dryRun.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setScriptSource", dict); + return result.DeserializeJson(); + } + + /// + /// Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc). + /// + public async System.Threading.Tasks.Task SetSkipAllPausesAsync(bool skip) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("skip", skip); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setSkipAllPauses", dict); + return result; + } + + /// + /// Changes value of variable in a callframe. Object-based scopes are not supported and must be + public async System.Threading.Tasks.Task SetVariableValueAsync(int scopeNumber, string variableName, Runtime.CallArgument newValue, string callFrameId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("scopeNumber", scopeNumber); + dict.Add("variableName", variableName); + dict.Add("newValue", newValue.ToDictionary()); + dict.Add("callFrameId", callFrameId); + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.setVariableValue", dict); + return result; + } + + /// + /// Steps into the function call. + /// + public async System.Threading.Tasks.Task StepIntoAsync(bool? breakOnAsyncCall = null, System.Collections.Generic.IList skipList = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (breakOnAsyncCall.HasValue) + { + dict.Add("breakOnAsyncCall", breakOnAsyncCall.Value); + } + + if ((skipList) != (null)) + { + dict.Add("skipList", skipList.Select(x => x.ToDictionary())); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.stepInto", dict); + return result; + } + + /// + /// Steps out of the function call. + /// + public async System.Threading.Tasks.Task StepOutAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.stepOut", dict); + return result; + } + + /// + /// Steps over the statement. + /// + public async System.Threading.Tasks.Task StepOverAsync(System.Collections.Generic.IList skipList = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if ((skipList) != (null)) + { + dict.Add("skipList", skipList.Select(x => x.ToDictionary())); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Debugger.stepOver", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/EnableResponse.cs b/CefSharp/DevTools/Debugger/EnableResponse.cs new file mode 100644 index 0000000000..39556a184e --- /dev/null +++ b/CefSharp/DevTools/Debugger/EnableResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// EnableResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class EnableResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string debuggerId + { + get; + set; + } + + /// + /// Unique identifier of the debugger. + /// + public string DebuggerId + { + get + { + return debuggerId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/Enums/ScriptLanguage.cs b/CefSharp/DevTools/Debugger/Enums/ScriptLanguage.cs new file mode 100644 index 0000000000..668c527574 --- /dev/null +++ b/CefSharp/DevTools/Debugger/Enums/ScriptLanguage.cs @@ -0,0 +1,22 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// Enum of possible script languages. + /// + public enum ScriptLanguage + { + /// + /// JavaScript + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("JavaScript"))] + JavaScript, + /// + /// WebAssembly + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("WebAssembly"))] + WebAssembly + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/EvaluateOnCallFrameResponse.cs b/CefSharp/DevTools/Debugger/EvaluateOnCallFrameResponse.cs new file mode 100644 index 0000000000..2da6f5461c --- /dev/null +++ b/CefSharp/DevTools/Debugger/EvaluateOnCallFrameResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// EvaluateOnCallFrameResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class EvaluateOnCallFrameResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal Runtime.RemoteObject result + { + get; + set; + } + + /// + /// Object wrapper for the evaluation result. + /// + public Runtime.RemoteObject Result + { + get + { + return result; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal Runtime.ExceptionDetails exceptionDetails + { + get; + set; + } + + /// + /// Exception details. + /// + public Runtime.ExceptionDetails ExceptionDetails + { + get + { + return exceptionDetails; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/GetPossibleBreakpointsResponse.cs b/CefSharp/DevTools/Debugger/GetPossibleBreakpointsResponse.cs new file mode 100644 index 0000000000..1da0671166 --- /dev/null +++ b/CefSharp/DevTools/Debugger/GetPossibleBreakpointsResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// GetPossibleBreakpointsResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetPossibleBreakpointsResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList locations + { + get; + set; + } + + /// + /// List of the possible breakpoint locations. + /// + public System.Collections.Generic.IList Locations + { + get + { + return locations; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/GetScriptSourceResponse.cs b/CefSharp/DevTools/Debugger/GetScriptSourceResponse.cs new file mode 100644 index 0000000000..7813745933 --- /dev/null +++ b/CefSharp/DevTools/Debugger/GetScriptSourceResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// GetScriptSourceResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetScriptSourceResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string scriptSource + { + get; + set; + } + + /// + /// Script source (empty in case of Wasm bytecode). + /// + public string ScriptSource + { + get + { + return scriptSource; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string bytecode + { + get; + set; + } + + /// + /// Wasm bytecode. + /// + public string Bytecode + { + get + { + return bytecode; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/GetWasmBytecodeResponse.cs b/CefSharp/DevTools/Debugger/GetWasmBytecodeResponse.cs new file mode 100644 index 0000000000..c0ede4157c --- /dev/null +++ b/CefSharp/DevTools/Debugger/GetWasmBytecodeResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// GetWasmBytecodeResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetWasmBytecodeResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string bytecode + { + get; + set; + } + + /// + /// Script source. + /// + public string Bytecode + { + get + { + return bytecode; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/Location.cs b/CefSharp/DevTools/Debugger/Location.cs new file mode 100644 index 0000000000..a1b4c04d77 --- /dev/null +++ b/CefSharp/DevTools/Debugger/Location.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// Location in the source code. + /// + public class Location : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Script identifier as reported in the `Debugger.scriptParsed`. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scriptId"), IsRequired = (true))] + public string ScriptId + { + get; + set; + } + + /// + /// Line number in the script (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (true))] + public int LineNumber + { + get; + set; + } + + /// + /// Column number in the script (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("columnNumber"), IsRequired = (false))] + public int? ColumnNumber + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/LocationRange.cs b/CefSharp/DevTools/Debugger/LocationRange.cs new file mode 100644 index 0000000000..63d25ae490 --- /dev/null +++ b/CefSharp/DevTools/Debugger/LocationRange.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// Location range within one script. + /// + public class LocationRange : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scriptId"), IsRequired = (true))] + public string ScriptId + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("start"), IsRequired = (true))] + public ScriptPosition Start + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("end"), IsRequired = (true))] + public ScriptPosition End + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/RestartFrameResponse.cs b/CefSharp/DevTools/Debugger/RestartFrameResponse.cs new file mode 100644 index 0000000000..b1bb1defb3 --- /dev/null +++ b/CefSharp/DevTools/Debugger/RestartFrameResponse.cs @@ -0,0 +1,66 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// RestartFrameResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class RestartFrameResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList callFrames + { + get; + set; + } + + /// + /// New stack trace. + /// + public System.Collections.Generic.IList CallFrames + { + get + { + return callFrames; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal Runtime.StackTrace asyncStackTrace + { + get; + set; + } + + /// + /// Async stack trace, if any. + /// + public Runtime.StackTrace AsyncStackTrace + { + get + { + return asyncStackTrace; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal Runtime.StackTraceId asyncStackTraceId + { + get; + set; + } + + /// + /// Async stack trace, if any. + /// + public Runtime.StackTraceId AsyncStackTraceId + { + get + { + return asyncStackTraceId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/Scope.cs b/CefSharp/DevTools/Debugger/Scope.cs new file mode 100644 index 0000000000..7a34abbec1 --- /dev/null +++ b/CefSharp/DevTools/Debugger/Scope.cs @@ -0,0 +1,60 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// Scope description. + /// + public class Scope : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Scope type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// Object representing the scope. For `global` and `with` scopes it represents the actual + [System.Runtime.Serialization.DataMemberAttribute(Name = ("object"), IsRequired = (true))] + public Runtime.RemoteObject Object + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (false))] + public string Name + { + get; + set; + } + + /// + /// Location in the source code where scope starts + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("startLocation"), IsRequired = (false))] + public Location StartLocation + { + get; + set; + } + + /// + /// Location in the source code where scope ends + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("endLocation"), IsRequired = (false))] + public Location EndLocation + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/ScriptPosition.cs b/CefSharp/DevTools/Debugger/ScriptPosition.cs new file mode 100644 index 0000000000..ff43deba6c --- /dev/null +++ b/CefSharp/DevTools/Debugger/ScriptPosition.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// Location in the source code. + /// + public class ScriptPosition : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (true))] + public int LineNumber + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("columnNumber"), IsRequired = (true))] + public int ColumnNumber + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/SearchInContentResponse.cs b/CefSharp/DevTools/Debugger/SearchInContentResponse.cs new file mode 100644 index 0000000000..f9d1944200 --- /dev/null +++ b/CefSharp/DevTools/Debugger/SearchInContentResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// SearchInContentResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class SearchInContentResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList result + { + get; + set; + } + + /// + /// List of search matches. + /// + public System.Collections.Generic.IList Result + { + get + { + return result; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/SearchMatch.cs b/CefSharp/DevTools/Debugger/SearchMatch.cs new file mode 100644 index 0000000000..b5b01ea2bf --- /dev/null +++ b/CefSharp/DevTools/Debugger/SearchMatch.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// Search match for resource. + /// + public class SearchMatch : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Line number in resource content. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (true))] + public long LineNumber + { + get; + set; + } + + /// + /// Line with match content. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineContent"), IsRequired = (true))] + public string LineContent + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/SetBreakpointByUrlResponse.cs b/CefSharp/DevTools/Debugger/SetBreakpointByUrlResponse.cs new file mode 100644 index 0000000000..6ce8418850 --- /dev/null +++ b/CefSharp/DevTools/Debugger/SetBreakpointByUrlResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// SetBreakpointByUrlResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class SetBreakpointByUrlResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string breakpointId + { + get; + set; + } + + /// + /// Id of the created breakpoint for further reference. + /// + public string BreakpointId + { + get + { + return breakpointId; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList locations + { + get; + set; + } + + /// + /// List of the locations this breakpoint resolved into upon addition. + /// + public System.Collections.Generic.IList Locations + { + get + { + return locations; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/SetBreakpointResponse.cs b/CefSharp/DevTools/Debugger/SetBreakpointResponse.cs new file mode 100644 index 0000000000..530498a923 --- /dev/null +++ b/CefSharp/DevTools/Debugger/SetBreakpointResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// SetBreakpointResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class SetBreakpointResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string breakpointId + { + get; + set; + } + + /// + /// Id of the created breakpoint for further reference. + /// + public string BreakpointId + { + get + { + return breakpointId; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal Location actualLocation + { + get; + set; + } + + /// + /// Location this breakpoint resolved into. + /// + public Location ActualLocation + { + get + { + return actualLocation; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/SetInstrumentationBreakpointResponse.cs b/CefSharp/DevTools/Debugger/SetInstrumentationBreakpointResponse.cs new file mode 100644 index 0000000000..1ac5b2afcd --- /dev/null +++ b/CefSharp/DevTools/Debugger/SetInstrumentationBreakpointResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// SetInstrumentationBreakpointResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class SetInstrumentationBreakpointResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string breakpointId + { + get; + set; + } + + /// + /// Id of the created breakpoint for further reference. + /// + public string BreakpointId + { + get + { + return breakpointId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Debugger/SetScriptSourceResponse.cs b/CefSharp/DevTools/Debugger/SetScriptSourceResponse.cs new file mode 100644 index 0000000000..726152fd2c --- /dev/null +++ b/CefSharp/DevTools/Debugger/SetScriptSourceResponse.cs @@ -0,0 +1,102 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Debugger +{ + /// + /// SetScriptSourceResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class SetScriptSourceResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList callFrames + { + get; + set; + } + + /// + /// New stack trace in case editing has happened while VM was stopped. + /// + public System.Collections.Generic.IList CallFrames + { + get + { + return callFrames; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal bool? stackChanged + { + get; + set; + } + + /// + /// Whether current call stack was modified after applying the changes. + /// + public bool? StackChanged + { + get + { + return stackChanged; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal Runtime.StackTrace asyncStackTrace + { + get; + set; + } + + /// + /// Async stack trace, if any. + /// + public Runtime.StackTrace AsyncStackTrace + { + get + { + return asyncStackTrace; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal Runtime.StackTraceId asyncStackTraceId + { + get; + set; + } + + /// + /// Async stack trace, if any. + /// + public Runtime.StackTraceId AsyncStackTraceId + { + get + { + return asyncStackTraceId; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal Runtime.ExceptionDetails exceptionDetails + { + get; + set; + } + + /// + /// Exception details if any. + /// + public Runtime.ExceptionDetails ExceptionDetails + { + get + { + return exceptionDetails; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DevToolsClient.Generated.cs b/CefSharp/DevTools/DevToolsClient.Generated.cs new file mode 100644 index 0000000000..468ec62e58 --- /dev/null +++ b/CefSharp/DevTools/DevToolsClient.Generated.cs @@ -0,0 +1,179 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools +{ + /// + /// Generated DevToolsClient methods + /// + public partial class DevToolsClient + { + private CefSharp.DevTools.Browser.Browser _Browser; + public CefSharp.DevTools.Browser.Browser Browser + { + get + { + if ((_Browser) == (null)) + { + _Browser = (new CefSharp.DevTools.Browser.Browser(this)); + } + + return _Browser; + } + } + + private CefSharp.DevTools.DOM.DOM _DOM; + public CefSharp.DevTools.DOM.DOM DOM + { + get + { + if ((_DOM) == (null)) + { + _DOM = (new CefSharp.DevTools.DOM.DOM(this)); + } + + return _DOM; + } + } + + private CefSharp.DevTools.DOMDebugger.DOMDebugger _DOMDebugger; + public CefSharp.DevTools.DOMDebugger.DOMDebugger DOMDebugger + { + get + { + if ((_DOMDebugger) == (null)) + { + _DOMDebugger = (new CefSharp.DevTools.DOMDebugger.DOMDebugger(this)); + } + + return _DOMDebugger; + } + } + + private CefSharp.DevTools.Emulation.Emulation _Emulation; + public CefSharp.DevTools.Emulation.Emulation Emulation + { + get + { + if ((_Emulation) == (null)) + { + _Emulation = (new CefSharp.DevTools.Emulation.Emulation(this)); + } + + return _Emulation; + } + } + + private CefSharp.DevTools.IO.IO _IO; + public CefSharp.DevTools.IO.IO IO + { + get + { + if ((_IO) == (null)) + { + _IO = (new CefSharp.DevTools.IO.IO(this)); + } + + return _IO; + } + } + + private CefSharp.DevTools.Input.Input _Input; + public CefSharp.DevTools.Input.Input Input + { + get + { + if ((_Input) == (null)) + { + _Input = (new CefSharp.DevTools.Input.Input(this)); + } + + return _Input; + } + } + + private CefSharp.DevTools.Log.Log _Log; + public CefSharp.DevTools.Log.Log Log + { + get + { + if ((_Log) == (null)) + { + _Log = (new CefSharp.DevTools.Log.Log(this)); + } + + return _Log; + } + } + + private CefSharp.DevTools.Network.Network _Network; + public CefSharp.DevTools.Network.Network Network + { + get + { + if ((_Network) == (null)) + { + _Network = (new CefSharp.DevTools.Network.Network(this)); + } + + return _Network; + } + } + + private CefSharp.DevTools.Page.Page _Page; + public CefSharp.DevTools.Page.Page Page + { + get + { + if ((_Page) == (null)) + { + _Page = (new CefSharp.DevTools.Page.Page(this)); + } + + return _Page; + } + } + + private CefSharp.DevTools.Performance.Performance _Performance; + public CefSharp.DevTools.Performance.Performance Performance + { + get + { + if ((_Performance) == (null)) + { + _Performance = (new CefSharp.DevTools.Performance.Performance(this)); + } + + return _Performance; + } + } + + private CefSharp.DevTools.Security.Security _Security; + public CefSharp.DevTools.Security.Security Security + { + get + { + if ((_Security) == (null)) + { + _Security = (new CefSharp.DevTools.Security.Security(this)); + } + + return _Security; + } + } + + private CefSharp.DevTools.Target.Target _Target; + public CefSharp.DevTools.Target.Target Target + { + get + { + if ((_Target) == (null)) + { + _Target = (new CefSharp.DevTools.Target.Target(this)); + } + + return _Target; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/DevToolsClient.cs b/CefSharp/DevTools/DevToolsClient.cs new file mode 100644 index 0000000000..62dcee84d5 --- /dev/null +++ b/CefSharp/DevTools/DevToolsClient.cs @@ -0,0 +1,174 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.IO; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using CefSharp.Callback; +using CefSharp.Internals; + +namespace CefSharp.DevTools +{ + /// + /// DevToolClient + /// + public partial class DevToolsClient : IDevToolsMessageObserver + { + private readonly ConcurrentDictionary> queuedCommandResults = new ConcurrentDictionary>(); + private int lastMessageId; + private IBrowser browser; + private IRegistration devToolsRegistration; + private bool devToolsAttached; + + /// + /// DevToolsEvent + /// + public EventHandler DevToolsEvent; + + /// + /// DevToolsClient + /// + /// Browser associated with this DevTools client + public DevToolsClient(IBrowser browser) + { + this.browser = browser; + + lastMessageId = browser.Identifier * 100000; + } + + public void SetDevToolsObserverRegistration(IRegistration devToolsRegistration) + { + this.devToolsRegistration = devToolsRegistration; + } + + /// + /// Execute a method call over the DevTools protocol. This method can be called on any thread. + /// See the DevTools protocol documentation at https://chromedevtools.github.io/devtools-protocol/ for details + /// of supported methods and the expected dictionary contents. + /// + /// is the method name + /// are the method parameters represented as a dictionary, + /// which may be empty. + /// return a Task that can be awaited to obtain the method result + public async Task ExecuteDevToolsMethodAsync(string method, IDictionary parameters = null) + { + if (browser == null || browser.IsDisposed) + { + //TODO: Queue up commands where possible + return new DevToolsMethodResult { Success = false }; + } + + var messageId = Interlocked.Increment(ref lastMessageId); + + var taskCompletionSource = new TaskCompletionSource(); + + if (!queuedCommandResults.TryAdd(messageId, taskCompletionSource)) + { + return new DevToolsMethodResult { Success = false }; + } + + var browserHost = browser.GetHost(); + + if (CefThread.CurrentlyOnUiThread) + { + var returnedMessageId = browserHost.ExecuteDevToolsMethod(messageId, method, parameters); + if (returnedMessageId == 0) + { + return new DevToolsMethodResult { Success = false }; + } + } + + if (CefThread.CanExecuteOnUiThread) + { + var returnedMessageId = await CefThread.ExecuteOnUiThread(() => + { + return browserHost.ExecuteDevToolsMethod(messageId, method, parameters); + }).ConfigureAwait(false); + + if (returnedMessageId == 0) + { + return new DevToolsMethodResult { Success = false }; + } + } + + return await taskCompletionSource.Task; + } + + void IDisposable.Dispose() + { + devToolsRegistration?.Dispose(); + devToolsRegistration = null; + browser = null; + } + + void IDevToolsMessageObserver.OnDevToolsAgentAttached(IBrowser browser) + { + devToolsAttached = true; + } + + void IDevToolsMessageObserver.OnDevToolsAgentDetached(IBrowser browser) + { + devToolsAttached = false; + } + + void IDevToolsMessageObserver.OnDevToolsEvent(IBrowser browser, string method, Stream parameters) + { + //TODO: Improve this + var memoryStream = new MemoryStream((int)parameters.Length); + parameters.CopyTo(memoryStream); + + var paramsAsJsonString = Encoding.UTF8.GetString(memoryStream.ToArray()); + + DevToolsEvent?.Invoke(this, new DevToolsEventArgs(method, paramsAsJsonString)); + } + + bool IDevToolsMessageObserver.OnDevToolsMessage(IBrowser browser, Stream message) + { + return false; + } + + void IDevToolsMessageObserver.OnDevToolsMethodResult(IBrowser browser, int messageId, bool success, Stream result) + { + TaskCompletionSource taskCompletionSource = null; + + if (queuedCommandResults.TryRemove(messageId, out taskCompletionSource)) + { + var methodResult = new DevToolsMethodResult + { + Success = success + }; + + //TODO: Improve this + var memoryStream = new MemoryStream((int)result.Length); + + result.CopyTo(memoryStream); + + methodResult.ResultAsJsonString = Encoding.UTF8.GetString(memoryStream.ToArray()); + + if (success) + { + Task.Run(() => + { + //Make sure continuation runs on Thread Pool + taskCompletionSource.TrySetResult(methodResult); + }); + } + else + { + Task.Run(() => + { + //TODO: Improve format error message + //Make sure continuation runs on Thread Pool + taskCompletionSource.TrySetException(new DevToolsClientException(methodResult.ResultAsJsonString)); + }); + } + + } + } + } +} diff --git a/CefSharp/DevTools/DevToolsClientException.cs b/CefSharp/DevTools/DevToolsClientException.cs new file mode 100644 index 0000000000..0c4ba82b80 --- /dev/null +++ b/CefSharp/DevTools/DevToolsClientException.cs @@ -0,0 +1,40 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +using System; + +namespace CefSharp.DevTools +{ + /// + /// The exception that is thrown when there's a problem executing a DevTools protocol method. + /// + public class DevToolsClientException : Exception + { + /// + /// Initializes a new instance of the class with its message + /// string set to a default message. + /// + public DevToolsClientException() : base("Error occurred whilst executing DevTools protocol method") + { + } + + /// + /// Initializes a new instance of the class with a specified error message. + /// + /// message + public DevToolsClientException(string message) : base(message) + { + } + + /// + /// Initializes a new instance of the class with a specified error message + /// and an inner exception. + /// + /// message + /// inner exception + public DevToolsClientException(string message, Exception inner) : base(message, inner) + { + } + } +} diff --git a/CefSharp/DevTools/DevToolsDomainBase.cs b/CefSharp/DevTools/DevToolsDomainBase.cs new file mode 100644 index 0000000000..d294a90024 --- /dev/null +++ b/CefSharp/DevTools/DevToolsDomainBase.cs @@ -0,0 +1,12 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + + +namespace CefSharp.DevTools +{ + public abstract class DevToolsDomainBase + { + + } +} diff --git a/CefSharp/DevTools/DevToolsDomainEntityBase.cs b/CefSharp/DevTools/DevToolsDomainEntityBase.cs new file mode 100644 index 0000000000..3463ef2d9a --- /dev/null +++ b/CefSharp/DevTools/DevToolsDomainEntityBase.cs @@ -0,0 +1,57 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + + +using System; +using System.Collections.Generic; +using System.Runtime.Serialization; + +namespace CefSharp.DevTools +{ + public abstract class DevToolsDomainEntityBase + { + public IDictionary ToDictionary() + { + var dict = new Dictionary(); + + var properties = GetType().GetProperties(); + + foreach (var prop in properties) + { + var dataMemberAttribute = (DataMemberAttribute)Attribute.GetCustomAttribute(prop, typeof(DataMemberAttribute), false); + var propertyName = dataMemberAttribute.Name; + var propertyRequired = dataMemberAttribute.IsRequired; + var propertyValue = prop.GetValue(this); + + if (propertyRequired && propertyValue == null) + { + throw new DevToolsClientException(prop.Name + " is required"); + } + + //Not required and value null, don't add to dictionary + if (propertyValue == null) + { + continue; + } + + var propertyValueType = propertyValue.GetType(); + + if (typeof(DevToolsDomainEntityBase).IsAssignableFrom(propertyValueType)) + { + propertyValue = ((DevToolsDomainEntityBase)(propertyValue)).ToDictionary(); + } + + if (propertyValueType.IsEnum) + { + var enumMemberAttribute = (EnumMemberAttribute)Attribute.GetCustomAttribute(prop, typeof(EnumMemberAttribute), false); + propertyValue = enumMemberAttribute.Value; + } + + dict.Add(propertyName, propertyValue); + } + + return dict; + } + } +} diff --git a/CefSharp/DevTools/DevToolsEventArgs.cs b/CefSharp/DevTools/DevToolsEventArgs.cs new file mode 100644 index 0000000000..d0f5110f8b --- /dev/null +++ b/CefSharp/DevTools/DevToolsEventArgs.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + + +using System; + +namespace CefSharp.DevTools +{ + /// + /// DevTools Event EventAargs + /// + public class DevToolsEventArgs : EventArgs + { + /// + /// Method + /// + public string EventName { get; private set; } + + /// + /// Event paramaters as Json string + /// + public string ParametersAsJsonString { get; private set; } + + public DevToolsEventArgs(string eventName, string paramsAsJsonString) + { + EventName = eventName; + ParametersAsJsonString = paramsAsJsonString; + } + } +} diff --git a/CefSharp/DevTools/DevToolsMethodResult.cs b/CefSharp/DevTools/DevToolsMethodResult.cs new file mode 100644 index 0000000000..a9b838886d --- /dev/null +++ b/CefSharp/DevTools/DevToolsMethodResult.cs @@ -0,0 +1,47 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +using System.IO; +using System.Runtime.Serialization.Json; +using System.Text; + +namespace CefSharp.DevTools +{ + /// + /// DevTools Method Result + /// + public class DevToolsMethodResult + { + /// + /// MessageId + /// + public int MessageId { get; set; } + + /// + /// Success + /// + public bool Success { get; set; } + + /// + /// Method Result as Json string + /// + public string ResultAsJsonString { get; set; } + + internal T DeserializeJson() + { + if (Success) + { + var bytes = Encoding.UTF8.GetBytes(ResultAsJsonString); + using (var ms = new MemoryStream(bytes)) + { + var dcs = new DataContractJsonSerializer(typeof(T)); + return (T)dcs.ReadObject(ms); + } + } + + throw new DevToolsClientException(ResultAsJsonString); + } + + } +} diff --git a/CefSharp/DevTools/Emulation/CanEmulateResponse.cs b/CefSharp/DevTools/Emulation/CanEmulateResponse.cs new file mode 100644 index 0000000000..548d3d14ea --- /dev/null +++ b/CefSharp/DevTools/Emulation/CanEmulateResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Emulation +{ + /// + /// CanEmulateResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CanEmulateResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal bool result + { + get; + set; + } + + /// + /// True if emulation is supported. + /// + public bool Result + { + get + { + return result; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Emulation/DisplayFeature.cs b/CefSharp/DevTools/Emulation/DisplayFeature.cs new file mode 100644 index 0000000000..5bab65dc71 --- /dev/null +++ b/CefSharp/DevTools/Emulation/DisplayFeature.cs @@ -0,0 +1,39 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Emulation +{ + /// + /// DisplayFeature + /// + public class DisplayFeature : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Orientation of a display feature in relation to screen + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("orientation"), IsRequired = (true))] + public string Orientation + { + get; + set; + } + + /// + /// The offset from the screen origin in either the x (for vertical + [System.Runtime.Serialization.DataMemberAttribute(Name = ("offset"), IsRequired = (true))] + public int Offset + { + get; + set; + } + + /// + /// A display feature may mask content such that it is not physically + [System.Runtime.Serialization.DataMemberAttribute(Name = ("maskLength"), IsRequired = (true))] + public int MaskLength + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Emulation/Emulation.cs b/CefSharp/DevTools/Emulation/Emulation.cs new file mode 100644 index 0000000000..d494cd4c6b --- /dev/null +++ b/CefSharp/DevTools/Emulation/Emulation.cs @@ -0,0 +1,218 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Emulation +{ + using System.Linq; + + /// + /// This domain emulates different environments for the page. + /// + public partial class Emulation : DevToolsDomainBase + { + public Emulation(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Tells whether emulation is supported. + /// + public async System.Threading.Tasks.Task CanEmulateAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.canEmulate", dict); + return result.DeserializeJson(); + } + + /// + /// Clears the overriden device metrics. + /// + public async System.Threading.Tasks.Task ClearDeviceMetricsOverrideAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.clearDeviceMetricsOverride", dict); + return result; + } + + /// + /// Clears the overriden Geolocation Position and Error. + /// + public async System.Threading.Tasks.Task ClearGeolocationOverrideAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.clearGeolocationOverride", dict); + return result; + } + + /// + /// Sets or clears an override of the default background color of the frame. This override is used + public async System.Threading.Tasks.Task SetDefaultBackgroundColorOverrideAsync(DOM.RGBA color = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if ((color) != (null)) + { + dict.Add("color", color.ToDictionary()); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.setDefaultBackgroundColorOverride", dict); + return result; + } + + /// + /// Overrides the values of device screen dimensions (window.screen.width, window.screen.height, + public async System.Threading.Tasks.Task SetDeviceMetricsOverrideAsync(int width, int height, long deviceScaleFactor, bool mobile, long? scale = null, int? screenWidth = null, int? screenHeight = null, int? positionX = null, int? positionY = null, bool? dontSetVisibleSize = null, ScreenOrientation screenOrientation = null, Page.Viewport viewport = null, DisplayFeature displayFeature = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("width", width); + dict.Add("height", height); + dict.Add("deviceScaleFactor", deviceScaleFactor); + dict.Add("mobile", mobile); + if (scale.HasValue) + { + dict.Add("scale", scale.Value); + } + + if (screenWidth.HasValue) + { + dict.Add("screenWidth", screenWidth.Value); + } + + if (screenHeight.HasValue) + { + dict.Add("screenHeight", screenHeight.Value); + } + + if (positionX.HasValue) + { + dict.Add("positionX", positionX.Value); + } + + if (positionY.HasValue) + { + dict.Add("positionY", positionY.Value); + } + + if (dontSetVisibleSize.HasValue) + { + dict.Add("dontSetVisibleSize", dontSetVisibleSize.Value); + } + + if ((screenOrientation) != (null)) + { + dict.Add("screenOrientation", screenOrientation.ToDictionary()); + } + + if ((viewport) != (null)) + { + dict.Add("viewport", viewport.ToDictionary()); + } + + if ((displayFeature) != (null)) + { + dict.Add("displayFeature", displayFeature.ToDictionary()); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.setDeviceMetricsOverride", dict); + return result; + } + + /// + /// Emulates the given media type or media feature for CSS media queries. + /// + public async System.Threading.Tasks.Task SetEmulatedMediaAsync(string media = null, System.Collections.Generic.IList features = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (!(string.IsNullOrEmpty(media))) + { + dict.Add("media", media); + } + + if ((features) != (null)) + { + dict.Add("features", features.Select(x => x.ToDictionary())); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.setEmulatedMedia", dict); + return result; + } + + /// + /// Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position + public async System.Threading.Tasks.Task SetGeolocationOverrideAsync(long? latitude = null, long? longitude = null, long? accuracy = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (latitude.HasValue) + { + dict.Add("latitude", latitude.Value); + } + + if (longitude.HasValue) + { + dict.Add("longitude", longitude.Value); + } + + if (accuracy.HasValue) + { + dict.Add("accuracy", accuracy.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.setGeolocationOverride", dict); + return result; + } + + /// + /// Switches script execution in the page. + /// + public async System.Threading.Tasks.Task SetScriptExecutionDisabledAsync(bool value) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("value", value); + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.setScriptExecutionDisabled", dict); + return result; + } + + /// + /// Enables touch on platforms which do not support them. + /// + public async System.Threading.Tasks.Task SetTouchEmulationEnabledAsync(bool enabled, int? maxTouchPoints = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("enabled", enabled); + if (maxTouchPoints.HasValue) + { + dict.Add("maxTouchPoints", maxTouchPoints.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.setTouchEmulationEnabled", dict); + return result; + } + + /// + /// Allows overriding user agent with the given string. + /// + public async System.Threading.Tasks.Task SetUserAgentOverrideAsync(string userAgent, string acceptLanguage = null, string platform = null, UserAgentMetadata userAgentMetadata = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("userAgent", userAgent); + if (!(string.IsNullOrEmpty(acceptLanguage))) + { + dict.Add("acceptLanguage", acceptLanguage); + } + + if (!(string.IsNullOrEmpty(platform))) + { + dict.Add("platform", platform); + } + + if ((userAgentMetadata) != (null)) + { + dict.Add("userAgentMetadata", userAgentMetadata.ToDictionary()); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Emulation.setUserAgentOverride", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Emulation/Enums/VirtualTimePolicy.cs b/CefSharp/DevTools/Emulation/Enums/VirtualTimePolicy.cs new file mode 100644 index 0000000000..a00d9d75cc --- /dev/null +++ b/CefSharp/DevTools/Emulation/Enums/VirtualTimePolicy.cs @@ -0,0 +1,26 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Emulation +{ + /// + /// advance: If the scheduler runs out of immediate work, the virtual time base may fast forward to + public enum VirtualTimePolicy + { + /// + /// advance + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("advance"))] + Advance, + /// + /// pause + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("pause"))] + Pause, + /// + /// pauseIfNetworkFetchesPending + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("pauseIfNetworkFetchesPending"))] + PauseIfNetworkFetchesPending + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Emulation/MediaFeature.cs b/CefSharp/DevTools/Emulation/MediaFeature.cs new file mode 100644 index 0000000000..6f44c52caf --- /dev/null +++ b/CefSharp/DevTools/Emulation/MediaFeature.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Emulation +{ + /// + /// MediaFeature + /// + public class MediaFeature : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public string Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Emulation/ScreenOrientation.cs b/CefSharp/DevTools/Emulation/ScreenOrientation.cs new file mode 100644 index 0000000000..c06c3523be --- /dev/null +++ b/CefSharp/DevTools/Emulation/ScreenOrientation.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Emulation +{ + /// + /// Screen orientation. + /// + public class ScreenOrientation : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Orientation type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// Orientation angle. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("angle"), IsRequired = (true))] + public int Angle + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Emulation/UserAgentBrandVersion.cs b/CefSharp/DevTools/Emulation/UserAgentBrandVersion.cs new file mode 100644 index 0000000000..1d04dda323 --- /dev/null +++ b/CefSharp/DevTools/Emulation/UserAgentBrandVersion.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Emulation +{ + /// + /// Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints + /// + public class UserAgentBrandVersion : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("brand"), IsRequired = (true))] + public string Brand + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("version"), IsRequired = (true))] + public string Version + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Emulation/UserAgentMetadata.cs b/CefSharp/DevTools/Emulation/UserAgentMetadata.cs new file mode 100644 index 0000000000..0ff06e2745 --- /dev/null +++ b/CefSharp/DevTools/Emulation/UserAgentMetadata.cs @@ -0,0 +1,81 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Emulation +{ + /// + /// Used to specify User Agent Cient Hints to emulate. See https://wicg.github.io/ua-client-hints + /// + public class UserAgentMetadata : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("brands"), IsRequired = (true))] + public System.Collections.Generic.IList Brands + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("fullVersion"), IsRequired = (true))] + public string FullVersion + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("platform"), IsRequired = (true))] + public string Platform + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("platformVersion"), IsRequired = (true))] + public string PlatformVersion + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("architecture"), IsRequired = (true))] + public string Architecture + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("model"), IsRequired = (true))] + public string Model + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mobile"), IsRequired = (true))] + public bool Mobile + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Headers.cs b/CefSharp/DevTools/Headers.cs new file mode 100644 index 0000000000..f5f158f0d9 --- /dev/null +++ b/CefSharp/DevTools/Headers.cs @@ -0,0 +1,17 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. + +using System.Collections.Specialized; + +namespace CefSharp.DevTools +{ + //TODO: Properly implement this type + public class Headers : NameValueCollection + { + public NameValueCollection ToDictionary() + { + return this; + } + } +} diff --git a/CefSharp/DevTools/IO/IO.cs b/CefSharp/DevTools/IO/IO.cs new file mode 100644 index 0000000000..455cfc93e4 --- /dev/null +++ b/CefSharp/DevTools/IO/IO.cs @@ -0,0 +1,62 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.IO +{ + using System.Linq; + + /// + /// Input/Output operations for streams produced by DevTools. + /// + public partial class IO : DevToolsDomainBase + { + public IO(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Close the stream, discard any temporary backing storage. + /// + public async System.Threading.Tasks.Task CloseAsync(string handle) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("handle", handle); + var result = await _client.ExecuteDevToolsMethodAsync("IO.close", dict); + return result; + } + + /// + /// Read a chunk of the stream + /// + public async System.Threading.Tasks.Task ReadAsync(string handle, int? offset = null, int? size = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("handle", handle); + if (offset.HasValue) + { + dict.Add("offset", offset.Value); + } + + if (size.HasValue) + { + dict.Add("size", size.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("IO.read", dict); + return result.DeserializeJson(); + } + + /// + /// Return UUID of Blob object specified by a remote object id. + /// + public async System.Threading.Tasks.Task ResolveBlobAsync(string objectId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("objectId", objectId); + var result = await _client.ExecuteDevToolsMethodAsync("IO.resolveBlob", dict); + return result.DeserializeJson(); + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/IO/ReadResponse.cs b/CefSharp/DevTools/IO/ReadResponse.cs new file mode 100644 index 0000000000..e27aba306d --- /dev/null +++ b/CefSharp/DevTools/IO/ReadResponse.cs @@ -0,0 +1,66 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.IO +{ + /// + /// ReadResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class ReadResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal bool? base64Encoded + { + get; + set; + } + + /// + /// Set if the data is base64-encoded + /// + public bool? Base64Encoded + { + get + { + return base64Encoded; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string data + { + get; + set; + } + + /// + /// Data that were read. + /// + public string Data + { + get + { + return data; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal bool eof + { + get; + set; + } + + /// + /// Set if the end-of-file condition occured while reading. + /// + public bool Eof + { + get + { + return eof; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/IO/ResolveBlobResponse.cs b/CefSharp/DevTools/IO/ResolveBlobResponse.cs new file mode 100644 index 0000000000..1bc3f09abe --- /dev/null +++ b/CefSharp/DevTools/IO/ResolveBlobResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.IO +{ + /// + /// ResolveBlobResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class ResolveBlobResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string uuid + { + get; + set; + } + + /// + /// UUID of the specified Blob. + /// + public string Uuid + { + get + { + return uuid; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Input/Enums/GestureSourceType.cs b/CefSharp/DevTools/Input/Enums/GestureSourceType.cs new file mode 100644 index 0000000000..e6dc3e3c5e --- /dev/null +++ b/CefSharp/DevTools/Input/Enums/GestureSourceType.cs @@ -0,0 +1,27 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Input +{ + /// + /// GestureSourceType + /// + public enum GestureSourceType + { + /// + /// default + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("default"))] + Default, + /// + /// touch + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("touch"))] + Touch, + /// + /// mouse + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("mouse"))] + Mouse + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Input/Enums/MouseButton.cs b/CefSharp/DevTools/Input/Enums/MouseButton.cs new file mode 100644 index 0000000000..a69b21e01f --- /dev/null +++ b/CefSharp/DevTools/Input/Enums/MouseButton.cs @@ -0,0 +1,42 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Input +{ + /// + /// MouseButton + /// + public enum MouseButton + { + /// + /// none + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("none"))] + None, + /// + /// left + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("left"))] + Left, + /// + /// middle + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("middle"))] + Middle, + /// + /// right + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("right"))] + Right, + /// + /// back + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("back"))] + Back, + /// + /// forward + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("forward"))] + Forward + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Input/Input.cs b/CefSharp/DevTools/Input/Input.cs new file mode 100644 index 0000000000..df09a889d3 --- /dev/null +++ b/CefSharp/DevTools/Input/Input.cs @@ -0,0 +1,186 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Input +{ + using System.Linq; + + /// + /// Input + /// + public partial class Input : DevToolsDomainBase + { + public Input(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Dispatches a key event to the page. + /// + public async System.Threading.Tasks.Task DispatchKeyEventAsync(string type, int? modifiers = null, long? timestamp = null, string text = null, string unmodifiedText = null, string keyIdentifier = null, string code = null, string key = null, int? windowsVirtualKeyCode = null, int? nativeVirtualKeyCode = null, bool? autoRepeat = null, bool? isKeypad = null, bool? isSystemKey = null, int? location = null, string commands = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("type", type); + if (modifiers.HasValue) + { + dict.Add("modifiers", modifiers.Value); + } + + if (timestamp.HasValue) + { + dict.Add("timestamp", timestamp.Value); + } + + if (!(string.IsNullOrEmpty(text))) + { + dict.Add("text", text); + } + + if (!(string.IsNullOrEmpty(unmodifiedText))) + { + dict.Add("unmodifiedText", unmodifiedText); + } + + if (!(string.IsNullOrEmpty(keyIdentifier))) + { + dict.Add("keyIdentifier", keyIdentifier); + } + + if (!(string.IsNullOrEmpty(code))) + { + dict.Add("code", code); + } + + if (!(string.IsNullOrEmpty(key))) + { + dict.Add("key", key); + } + + if (windowsVirtualKeyCode.HasValue) + { + dict.Add("windowsVirtualKeyCode", windowsVirtualKeyCode.Value); + } + + if (nativeVirtualKeyCode.HasValue) + { + dict.Add("nativeVirtualKeyCode", nativeVirtualKeyCode.Value); + } + + if (autoRepeat.HasValue) + { + dict.Add("autoRepeat", autoRepeat.Value); + } + + if (isKeypad.HasValue) + { + dict.Add("isKeypad", isKeypad.Value); + } + + if (isSystemKey.HasValue) + { + dict.Add("isSystemKey", isSystemKey.Value); + } + + if (location.HasValue) + { + dict.Add("location", location.Value); + } + + if (!(string.IsNullOrEmpty(commands))) + { + dict.Add("commands", commands); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Input.dispatchKeyEvent", dict); + return result; + } + + /// + /// Dispatches a mouse event to the page. + /// + public async System.Threading.Tasks.Task DispatchMouseEventAsync(string type, long x, long y, int? modifiers = null, long? timestamp = null, string button = null, int? buttons = null, int? clickCount = null, long? deltaX = null, long? deltaY = null, string pointerType = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("type", type); + dict.Add("x", x); + dict.Add("y", y); + if (modifiers.HasValue) + { + dict.Add("modifiers", modifiers.Value); + } + + if (timestamp.HasValue) + { + dict.Add("timestamp", timestamp.Value); + } + + if (!(string.IsNullOrEmpty(button))) + { + dict.Add("button", button); + } + + if (buttons.HasValue) + { + dict.Add("buttons", buttons.Value); + } + + if (clickCount.HasValue) + { + dict.Add("clickCount", clickCount.Value); + } + + if (deltaX.HasValue) + { + dict.Add("deltaX", deltaX.Value); + } + + if (deltaY.HasValue) + { + dict.Add("deltaY", deltaY.Value); + } + + if (!(string.IsNullOrEmpty(pointerType))) + { + dict.Add("pointerType", pointerType); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Input.dispatchMouseEvent", dict); + return result; + } + + /// + /// Dispatches a touch event to the page. + /// + public async System.Threading.Tasks.Task DispatchTouchEventAsync(string type, System.Collections.Generic.IList touchPoints, int? modifiers = null, long? timestamp = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("type", type); + dict.Add("touchPoints", touchPoints.Select(x => x.ToDictionary())); + if (modifiers.HasValue) + { + dict.Add("modifiers", modifiers.Value); + } + + if (timestamp.HasValue) + { + dict.Add("timestamp", timestamp.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Input.dispatchTouchEvent", dict); + return result; + } + + /// + /// Ignores input events (useful while auditing page). + /// + public async System.Threading.Tasks.Task SetIgnoreInputEventsAsync(bool ignore) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("ignore", ignore); + var result = await _client.ExecuteDevToolsMethodAsync("Input.setIgnoreInputEvents", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Input/TouchPoint.cs b/CefSharp/DevTools/Input/TouchPoint.cs new file mode 100644 index 0000000000..5df9497aea --- /dev/null +++ b/CefSharp/DevTools/Input/TouchPoint.cs @@ -0,0 +1,80 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Input +{ + /// + /// TouchPoint + /// + public class TouchPoint : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// X coordinate of the event relative to the main frame's viewport in CSS pixels. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("x"), IsRequired = (true))] + public long X + { + get; + set; + } + + /// + /// Y coordinate of the event relative to the main frame's viewport in CSS pixels. 0 refers to + [System.Runtime.Serialization.DataMemberAttribute(Name = ("y"), IsRequired = (true))] + public long Y + { + get; + set; + } + + /// + /// X radius of the touch area (default: 1.0). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("radiusX"), IsRequired = (false))] + public long? RadiusX + { + get; + set; + } + + /// + /// Y radius of the touch area (default: 1.0). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("radiusY"), IsRequired = (false))] + public long? RadiusY + { + get; + set; + } + + /// + /// Rotation angle (default: 0.0). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("rotationAngle"), IsRequired = (false))] + public long? RotationAngle + { + get; + set; + } + + /// + /// Force (default: 1.0). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("force"), IsRequired = (false))] + public long? Force + { + get; + set; + } + + /// + /// Identifier used to track touch sources between events, must be unique within an event. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("id"), IsRequired = (false))] + public long? Id + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Log/Log.cs b/CefSharp/DevTools/Log/Log.cs new file mode 100644 index 0000000000..e529fe0898 --- /dev/null +++ b/CefSharp/DevTools/Log/Log.cs @@ -0,0 +1,69 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Log +{ + using System.Linq; + + /// + /// Provides access to log entries. + /// + public partial class Log : DevToolsDomainBase + { + public Log(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Clears the log. + /// + public async System.Threading.Tasks.Task ClearAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Log.clear", dict); + return result; + } + + /// + /// Disables log domain, prevents further log entries from being reported to the client. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Log.disable", dict); + return result; + } + + /// + /// Enables log domain, sends the entries collected so far to the client by means of the + public async System.Threading.Tasks.Task EnableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Log.enable", dict); + return result; + } + + /// + /// start violation reporting. + /// + public async System.Threading.Tasks.Task StartViolationsReportAsync(System.Collections.Generic.IList config) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("config", config.Select(x => x.ToDictionary())); + var result = await _client.ExecuteDevToolsMethodAsync("Log.startViolationsReport", dict); + return result; + } + + /// + /// Stop violation reporting. + /// + public async System.Threading.Tasks.Task StopViolationsReportAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Log.stopViolationsReport", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Log/LogEntry.cs b/CefSharp/DevTools/Log/LogEntry.cs new file mode 100644 index 0000000000..3008a2602c --- /dev/null +++ b/CefSharp/DevTools/Log/LogEntry.cs @@ -0,0 +1,111 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Log +{ + /// + /// Log entry. + /// + public class LogEntry : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Log entry source. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("source"), IsRequired = (true))] + public string Source + { + get; + set; + } + + /// + /// Log entry severity. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("level"), IsRequired = (true))] + public string Level + { + get; + set; + } + + /// + /// Logged text. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("text"), IsRequired = (true))] + public string Text + { + get; + set; + } + + /// + /// Timestamp when this entry was added. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("timestamp"), IsRequired = (true))] + public long Timestamp + { + get; + set; + } + + /// + /// URL of the resource if known. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (false))] + public string Url + { + get; + set; + } + + /// + /// Line number in the resource. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (false))] + public int? LineNumber + { + get; + set; + } + + /// + /// JavaScript stack trace. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("stackTrace"), IsRequired = (false))] + public Runtime.StackTrace StackTrace + { + get; + set; + } + + /// + /// Identifier of the network request associated with this entry. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("networkRequestId"), IsRequired = (false))] + public string NetworkRequestId + { + get; + set; + } + + /// + /// Identifier of the worker associated with this entry. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("workerId"), IsRequired = (false))] + public string WorkerId + { + get; + set; + } + + /// + /// Call arguments. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("args"), IsRequired = (false))] + public System.Collections.Generic.IList Args + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Log/ViolationSetting.cs b/CefSharp/DevTools/Log/ViolationSetting.cs new file mode 100644 index 0000000000..cbf5aba25e --- /dev/null +++ b/CefSharp/DevTools/Log/ViolationSetting.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Log +{ + /// + /// Violation configuration setting. + /// + public class ViolationSetting : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Violation type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Time threshold to trigger upon. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("threshold"), IsRequired = (true))] + public long Threshold + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/AuthChallenge.cs b/CefSharp/DevTools/Network/AuthChallenge.cs new file mode 100644 index 0000000000..a15e239926 --- /dev/null +++ b/CefSharp/DevTools/Network/AuthChallenge.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Authorization challenge for HTTP status code 401 or 407. + /// + public class AuthChallenge : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Source of the authentication challenge. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("source"), IsRequired = (false))] + public string Source + { + get; + set; + } + + /// + /// Origin of the challenger. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("origin"), IsRequired = (true))] + public string Origin + { + get; + set; + } + + /// + /// The authentication scheme used, such as basic or digest + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scheme"), IsRequired = (true))] + public string Scheme + { + get; + set; + } + + /// + /// The realm of the challenge. May be empty. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("realm"), IsRequired = (true))] + public string Realm + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/AuthChallengeResponse.cs b/CefSharp/DevTools/Network/AuthChallengeResponse.cs new file mode 100644 index 0000000000..32544568fd --- /dev/null +++ b/CefSharp/DevTools/Network/AuthChallengeResponse.cs @@ -0,0 +1,38 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Response to an AuthChallenge. + /// + public class AuthChallengeResponse : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The decision on what to do in response to the authorization challenge. Default means + [System.Runtime.Serialization.DataMemberAttribute(Name = ("response"), IsRequired = (true))] + public string Response + { + get; + set; + } + + /// + /// The username to provide, possibly empty. Should only be set if response is + [System.Runtime.Serialization.DataMemberAttribute(Name = ("username"), IsRequired = (false))] + public string Username + { + get; + set; + } + + /// + /// The password to provide, possibly empty. Should only be set if response is + [System.Runtime.Serialization.DataMemberAttribute(Name = ("password"), IsRequired = (false))] + public string Password + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/BlockedCookieWithReason.cs b/CefSharp/DevTools/Network/BlockedCookieWithReason.cs new file mode 100644 index 0000000000..b27b581cd3 --- /dev/null +++ b/CefSharp/DevTools/Network/BlockedCookieWithReason.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// A cookie with was not sent with a request with the corresponding reason. + /// + public class BlockedCookieWithReason : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The reason(s) the cookie was blocked. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("blockedReasons"), IsRequired = (true))] + public string BlockedReasons + { + get; + set; + } + + /// + /// The cookie object representing the cookie which was not sent. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("cookie"), IsRequired = (true))] + public Cookie Cookie + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/BlockedSetCookieWithReason.cs b/CefSharp/DevTools/Network/BlockedSetCookieWithReason.cs new file mode 100644 index 0000000000..d12a81ccd2 --- /dev/null +++ b/CefSharp/DevTools/Network/BlockedSetCookieWithReason.cs @@ -0,0 +1,39 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// A cookie which was not stored from a response with the corresponding reason. + /// + public class BlockedSetCookieWithReason : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The reason(s) this cookie was blocked. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("blockedReasons"), IsRequired = (true))] + public string BlockedReasons + { + get; + set; + } + + /// + /// The string representing this individual cookie as it would appear in the header. + [System.Runtime.Serialization.DataMemberAttribute(Name = ("cookieLine"), IsRequired = (true))] + public string CookieLine + { + get; + set; + } + + /// + /// The cookie object which represents the cookie which was not stored. It is optional because + [System.Runtime.Serialization.DataMemberAttribute(Name = ("cookie"), IsRequired = (false))] + public Cookie Cookie + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/CachedResource.cs b/CefSharp/DevTools/Network/CachedResource.cs new file mode 100644 index 0000000000..024217684c --- /dev/null +++ b/CefSharp/DevTools/Network/CachedResource.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Information about the cached resource. + /// + public class CachedResource : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Resource URL. This is the url of the original network request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// Type of this resource. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// Cached response data. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("response"), IsRequired = (false))] + public Response Response + { + get; + set; + } + + /// + /// Cached response body size. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("bodySize"), IsRequired = (true))] + public long BodySize + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/CanClearBrowserCacheResponse.cs b/CefSharp/DevTools/Network/CanClearBrowserCacheResponse.cs new file mode 100644 index 0000000000..017fa5b0fe --- /dev/null +++ b/CefSharp/DevTools/Network/CanClearBrowserCacheResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// CanClearBrowserCacheResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CanClearBrowserCacheResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal bool result + { + get; + set; + } + + /// + /// True if browser cache can be cleared. + /// + public bool Result + { + get + { + return result; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/CanClearBrowserCookiesResponse.cs b/CefSharp/DevTools/Network/CanClearBrowserCookiesResponse.cs new file mode 100644 index 0000000000..5dfee53eaa --- /dev/null +++ b/CefSharp/DevTools/Network/CanClearBrowserCookiesResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// CanClearBrowserCookiesResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CanClearBrowserCookiesResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal bool result + { + get; + set; + } + + /// + /// True if browser cookies can be cleared. + /// + public bool Result + { + get + { + return result; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/CanEmulateNetworkConditionsResponse.cs b/CefSharp/DevTools/Network/CanEmulateNetworkConditionsResponse.cs new file mode 100644 index 0000000000..57ff400955 --- /dev/null +++ b/CefSharp/DevTools/Network/CanEmulateNetworkConditionsResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// CanEmulateNetworkConditionsResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CanEmulateNetworkConditionsResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal bool result + { + get; + set; + } + + /// + /// True if emulation of network conditions is supported. + /// + public bool Result + { + get + { + return result; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Cookie.cs b/CefSharp/DevTools/Network/Cookie.cs new file mode 100644 index 0000000000..d0c02f16e9 --- /dev/null +++ b/CefSharp/DevTools/Network/Cookie.cs @@ -0,0 +1,121 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Cookie object + /// + public class Cookie : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Cookie name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Cookie value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public string Value + { + get; + set; + } + + /// + /// Cookie domain. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("domain"), IsRequired = (true))] + public string Domain + { + get; + set; + } + + /// + /// Cookie path. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("path"), IsRequired = (true))] + public string Path + { + get; + set; + } + + /// + /// Cookie expiration date as the number of seconds since the UNIX epoch. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("expires"), IsRequired = (true))] + public long Expires + { + get; + set; + } + + /// + /// Cookie size. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("size"), IsRequired = (true))] + public int Size + { + get; + set; + } + + /// + /// True if cookie is http-only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("httpOnly"), IsRequired = (true))] + public bool HttpOnly + { + get; + set; + } + + /// + /// True if cookie is secure. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("secure"), IsRequired = (true))] + public bool Secure + { + get; + set; + } + + /// + /// True in case of session cookie. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("session"), IsRequired = (true))] + public bool Session + { + get; + set; + } + + /// + /// Cookie SameSite type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sameSite"), IsRequired = (false))] + public string SameSite + { + get; + set; + } + + /// + /// Cookie Priority + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("priority"), IsRequired = (true))] + public string Priority + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/CookieParam.cs b/CefSharp/DevTools/Network/CookieParam.cs new file mode 100644 index 0000000000..99983785f3 --- /dev/null +++ b/CefSharp/DevTools/Network/CookieParam.cs @@ -0,0 +1,110 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Cookie parameter object + /// + public class CookieParam : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Cookie name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Cookie value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public string Value + { + get; + set; + } + + /// + /// The request-URI to associate with the setting of the cookie. This value can affect the + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (false))] + public string Url + { + get; + set; + } + + /// + /// Cookie domain. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("domain"), IsRequired = (false))] + public string Domain + { + get; + set; + } + + /// + /// Cookie path. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("path"), IsRequired = (false))] + public string Path + { + get; + set; + } + + /// + /// True if cookie is secure. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("secure"), IsRequired = (false))] + public bool? Secure + { + get; + set; + } + + /// + /// True if cookie is http-only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("httpOnly"), IsRequired = (false))] + public bool? HttpOnly + { + get; + set; + } + + /// + /// Cookie SameSite type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sameSite"), IsRequired = (false))] + public string SameSite + { + get; + set; + } + + /// + /// Cookie expiration date, session cookie if not set + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("expires"), IsRequired = (false))] + public long? Expires + { + get; + set; + } + + /// + /// Cookie Priority. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("priority"), IsRequired = (false))] + public string Priority + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/CrossOriginEmbedderPolicyStatus.cs b/CefSharp/DevTools/Network/CrossOriginEmbedderPolicyStatus.cs new file mode 100644 index 0000000000..43b64a0369 --- /dev/null +++ b/CefSharp/DevTools/Network/CrossOriginEmbedderPolicyStatus.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// CrossOriginEmbedderPolicyStatus + /// + public class CrossOriginEmbedderPolicyStatus : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public string Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/CrossOriginOpenerPolicyStatus.cs b/CefSharp/DevTools/Network/CrossOriginOpenerPolicyStatus.cs new file mode 100644 index 0000000000..e03e8d3c33 --- /dev/null +++ b/CefSharp/DevTools/Network/CrossOriginOpenerPolicyStatus.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// CrossOriginOpenerPolicyStatus + /// + public class CrossOriginOpenerPolicyStatus : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public string Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/BlockedReason.cs b/CefSharp/DevTools/Network/Enums/BlockedReason.cs new file mode 100644 index 0000000000..ddae6ac002 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/BlockedReason.cs @@ -0,0 +1,77 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// The reason why request was blocked. + /// + public enum BlockedReason + { + /// + /// other + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("other"))] + Other, + /// + /// csp + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("csp"))] + Csp, + /// + /// mixed-content + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("mixed-content"))] + MixedContent, + /// + /// origin + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("origin"))] + Origin, + /// + /// inspector + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("inspector"))] + Inspector, + /// + /// subresource-filter + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("subresource-filter"))] + SubresourceFilter, + /// + /// content-type + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("content-type"))] + ContentType, + /// + /// collapsed-by-client + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("collapsed-by-client"))] + CollapsedByClient, + /// + /// coep-frame-resource-needs-coep-header + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("coep-frame-resource-needs-coep-header"))] + CoepFrameResourceNeedsCoepHeader, + /// + /// coop-sandboxed-iframe-cannot-navigate-to-coop-page + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("coop-sandboxed-iframe-cannot-navigate-to-coop-page"))] + CoopSandboxedIframeCannotNavigateToCoopPage, + /// + /// corp-not-same-origin + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("corp-not-same-origin"))] + CorpNotSameOrigin, + /// + /// corp-not-same-origin-after-defaulted-to-same-origin-by-coep + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("corp-not-same-origin-after-defaulted-to-same-origin-by-coep"))] + CorpNotSameOriginAfterDefaultedToSameOriginByCoep, + /// + /// corp-not-same-site + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("corp-not-same-site"))] + CorpNotSameSite + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/CertificateTransparencyCompliance.cs b/CefSharp/DevTools/Network/Enums/CertificateTransparencyCompliance.cs new file mode 100644 index 0000000000..43789763e6 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/CertificateTransparencyCompliance.cs @@ -0,0 +1,27 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Whether the request complied with Certificate Transparency policy. + /// + public enum CertificateTransparencyCompliance + { + /// + /// unknown + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("unknown"))] + Unknown, + /// + /// not-compliant + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("not-compliant"))] + NotCompliant, + /// + /// compliant + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("compliant"))] + Compliant + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/ConnectionType.cs b/CefSharp/DevTools/Network/Enums/ConnectionType.cs new file mode 100644 index 0000000000..124d8e299a --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/ConnectionType.cs @@ -0,0 +1,57 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// The underlying connection technology that the browser is supposedly using. + /// + public enum ConnectionType + { + /// + /// none + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("none"))] + None, + /// + /// cellular2g + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("cellular2g"))] + Cellular2g, + /// + /// cellular3g + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("cellular3g"))] + Cellular3g, + /// + /// cellular4g + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("cellular4g"))] + Cellular4g, + /// + /// bluetooth + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("bluetooth"))] + Bluetooth, + /// + /// ethernet + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("ethernet"))] + Ethernet, + /// + /// wifi + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("wifi"))] + Wifi, + /// + /// wimax + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("wimax"))] + Wimax, + /// + /// other + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("other"))] + Other + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/CookieBlockedReason.cs b/CefSharp/DevTools/Network/Enums/CookieBlockedReason.cs new file mode 100644 index 0000000000..9c69fbb86a --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/CookieBlockedReason.cs @@ -0,0 +1,57 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Types of reasons why a cookie may not be sent with a request. + /// + public enum CookieBlockedReason + { + /// + /// SecureOnly + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SecureOnly"))] + SecureOnly, + /// + /// NotOnPath + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("NotOnPath"))] + NotOnPath, + /// + /// DomainMismatch + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("DomainMismatch"))] + DomainMismatch, + /// + /// SameSiteStrict + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameSiteStrict"))] + SameSiteStrict, + /// + /// SameSiteLax + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameSiteLax"))] + SameSiteLax, + /// + /// SameSiteUnspecifiedTreatedAsLax + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameSiteUnspecifiedTreatedAsLax"))] + SameSiteUnspecifiedTreatedAsLax, + /// + /// SameSiteNoneInsecure + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameSiteNoneInsecure"))] + SameSiteNoneInsecure, + /// + /// UserPreferences + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("UserPreferences"))] + UserPreferences, + /// + /// UnknownError + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("UnknownError"))] + UnknownError + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/CookiePriority.cs b/CefSharp/DevTools/Network/Enums/CookiePriority.cs new file mode 100644 index 0000000000..7922ddab86 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/CookiePriority.cs @@ -0,0 +1,26 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Represents the cookie's 'Priority' status: + public enum CookiePriority + { + /// + /// Low + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Low"))] + Low, + /// + /// Medium + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Medium"))] + Medium, + /// + /// High + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("High"))] + High + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/CookieSameSite.cs b/CefSharp/DevTools/Network/Enums/CookieSameSite.cs new file mode 100644 index 0000000000..bd603fd020 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/CookieSameSite.cs @@ -0,0 +1,26 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Represents the cookie's 'SameSite' status: + public enum CookieSameSite + { + /// + /// Strict + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Strict"))] + Strict, + /// + /// Lax + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Lax"))] + Lax, + /// + /// None + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("None"))] + None + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/CrossOriginEmbedderPolicyValue.cs b/CefSharp/DevTools/Network/Enums/CrossOriginEmbedderPolicyValue.cs new file mode 100644 index 0000000000..3d687d9173 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/CrossOriginEmbedderPolicyValue.cs @@ -0,0 +1,22 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// CrossOriginEmbedderPolicyValue + /// + public enum CrossOriginEmbedderPolicyValue + { + /// + /// None + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("None"))] + None, + /// + /// RequireCorp + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("RequireCorp"))] + RequireCorp + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/CrossOriginOpenerPolicyValue.cs b/CefSharp/DevTools/Network/Enums/CrossOriginOpenerPolicyValue.cs new file mode 100644 index 0000000000..09092c6359 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/CrossOriginOpenerPolicyValue.cs @@ -0,0 +1,32 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// CrossOriginOpenerPolicyValue + /// + public enum CrossOriginOpenerPolicyValue + { + /// + /// SameOrigin + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameOrigin"))] + SameOrigin, + /// + /// SameOriginAllowPopups + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameOriginAllowPopups"))] + SameOriginAllowPopups, + /// + /// UnsafeNone + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("UnsafeNone"))] + UnsafeNone, + /// + /// SameOriginPlusCoep + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameOriginPlusCoep"))] + SameOriginPlusCoep + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/ErrorReason.cs b/CefSharp/DevTools/Network/Enums/ErrorReason.cs new file mode 100644 index 0000000000..7611ed1943 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/ErrorReason.cs @@ -0,0 +1,82 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Network level fetch failure reason. + /// + public enum ErrorReason + { + /// + /// Failed + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Failed"))] + Failed, + /// + /// Aborted + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Aborted"))] + Aborted, + /// + /// TimedOut + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("TimedOut"))] + TimedOut, + /// + /// AccessDenied + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("AccessDenied"))] + AccessDenied, + /// + /// ConnectionClosed + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("ConnectionClosed"))] + ConnectionClosed, + /// + /// ConnectionReset + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("ConnectionReset"))] + ConnectionReset, + /// + /// ConnectionRefused + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("ConnectionRefused"))] + ConnectionRefused, + /// + /// ConnectionAborted + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("ConnectionAborted"))] + ConnectionAborted, + /// + /// ConnectionFailed + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("ConnectionFailed"))] + ConnectionFailed, + /// + /// NameNotResolved + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("NameNotResolved"))] + NameNotResolved, + /// + /// InternetDisconnected + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("InternetDisconnected"))] + InternetDisconnected, + /// + /// AddressUnreachable + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("AddressUnreachable"))] + AddressUnreachable, + /// + /// BlockedByClient + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("BlockedByClient"))] + BlockedByClient, + /// + /// BlockedByResponse + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("BlockedByResponse"))] + BlockedByResponse + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/InterceptionStage.cs b/CefSharp/DevTools/Network/Enums/InterceptionStage.cs new file mode 100644 index 0000000000..38e53a2827 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/InterceptionStage.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Stages of the interception to begin intercepting. Request will intercept before the request is + public enum InterceptionStage + { + /// + /// Request + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Request"))] + Request, + /// + /// HeadersReceived + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("HeadersReceived"))] + HeadersReceived + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/ResourcePriority.cs b/CefSharp/DevTools/Network/Enums/ResourcePriority.cs new file mode 100644 index 0000000000..79902c4f78 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/ResourcePriority.cs @@ -0,0 +1,37 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Loading priority of a resource request. + /// + public enum ResourcePriority + { + /// + /// VeryLow + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("VeryLow"))] + VeryLow, + /// + /// Low + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Low"))] + Low, + /// + /// Medium + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Medium"))] + Medium, + /// + /// High + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("High"))] + High, + /// + /// VeryHigh + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("VeryHigh"))] + VeryHigh + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/ResourceType.cs b/CefSharp/DevTools/Network/Enums/ResourceType.cs new file mode 100644 index 0000000000..68c1272b6f --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/ResourceType.cs @@ -0,0 +1,92 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Resource type as it was perceived by the rendering engine. + /// + public enum ResourceType + { + /// + /// Document + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Document"))] + Document, + /// + /// Stylesheet + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Stylesheet"))] + Stylesheet, + /// + /// Image + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Image"))] + Image, + /// + /// Media + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Media"))] + Media, + /// + /// Font + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Font"))] + Font, + /// + /// Script + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Script"))] + Script, + /// + /// TextTrack + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("TextTrack"))] + TextTrack, + /// + /// XHR + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("XHR"))] + XHR, + /// + /// Fetch + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Fetch"))] + Fetch, + /// + /// EventSource + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("EventSource"))] + EventSource, + /// + /// WebSocket + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("WebSocket"))] + WebSocket, + /// + /// Manifest + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Manifest"))] + Manifest, + /// + /// SignedExchange + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SignedExchange"))] + SignedExchange, + /// + /// Ping + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Ping"))] + Ping, + /// + /// CSPViolationReport + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("CSPViolationReport"))] + CSPViolationReport, + /// + /// Other + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Other"))] + Other + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/ServiceWorkerResponseSource.cs b/CefSharp/DevTools/Network/Enums/ServiceWorkerResponseSource.cs new file mode 100644 index 0000000000..1031a1f0cb --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/ServiceWorkerResponseSource.cs @@ -0,0 +1,32 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Source of serviceworker response. + /// + public enum ServiceWorkerResponseSource + { + /// + /// cache-storage + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("cache-storage"))] + CacheStorage, + /// + /// http-cache + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("http-cache"))] + HttpCache, + /// + /// fallback-code + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("fallback-code"))] + FallbackCode, + /// + /// network + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("network"))] + Network + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/SetCookieBlockedReason.cs b/CefSharp/DevTools/Network/Enums/SetCookieBlockedReason.cs new file mode 100644 index 0000000000..6026a04288 --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/SetCookieBlockedReason.cs @@ -0,0 +1,72 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Types of reasons why a cookie may not be stored from a response. + /// + public enum SetCookieBlockedReason + { + /// + /// SecureOnly + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SecureOnly"))] + SecureOnly, + /// + /// SameSiteStrict + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameSiteStrict"))] + SameSiteStrict, + /// + /// SameSiteLax + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameSiteLax"))] + SameSiteLax, + /// + /// SameSiteUnspecifiedTreatedAsLax + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameSiteUnspecifiedTreatedAsLax"))] + SameSiteUnspecifiedTreatedAsLax, + /// + /// SameSiteNoneInsecure + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SameSiteNoneInsecure"))] + SameSiteNoneInsecure, + /// + /// UserPreferences + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("UserPreferences"))] + UserPreferences, + /// + /// SyntaxError + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SyntaxError"))] + SyntaxError, + /// + /// SchemeNotSupported + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SchemeNotSupported"))] + SchemeNotSupported, + /// + /// OverwriteSecure + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("OverwriteSecure"))] + OverwriteSecure, + /// + /// InvalidDomain + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("InvalidDomain"))] + InvalidDomain, + /// + /// InvalidPrefix + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("InvalidPrefix"))] + InvalidPrefix, + /// + /// UnknownError + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("UnknownError"))] + UnknownError + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Enums/SignedExchangeErrorField.cs b/CefSharp/DevTools/Network/Enums/SignedExchangeErrorField.cs new file mode 100644 index 0000000000..f91011690d --- /dev/null +++ b/CefSharp/DevTools/Network/Enums/SignedExchangeErrorField.cs @@ -0,0 +1,42 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Field type for a signed exchange related error. + /// + public enum SignedExchangeErrorField + { + /// + /// signatureSig + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("signatureSig"))] + SignatureSig, + /// + /// signatureIntegrity + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("signatureIntegrity"))] + SignatureIntegrity, + /// + /// signatureCertUrl + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("signatureCertUrl"))] + SignatureCertUrl, + /// + /// signatureCertSha256 + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("signatureCertSha256"))] + SignatureCertSha256, + /// + /// signatureValidityUrl + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("signatureValidityUrl"))] + SignatureValidityUrl, + /// + /// signatureTimestamps + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("signatureTimestamps"))] + SignatureTimestamps + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/GetAllCookiesResponse.cs b/CefSharp/DevTools/Network/GetAllCookiesResponse.cs new file mode 100644 index 0000000000..5c758af650 --- /dev/null +++ b/CefSharp/DevTools/Network/GetAllCookiesResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// GetAllCookiesResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetAllCookiesResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList cookies + { + get; + set; + } + + /// + /// Array of cookie objects. + /// + public System.Collections.Generic.IList Cookies + { + get + { + return cookies; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/GetCookiesResponse.cs b/CefSharp/DevTools/Network/GetCookiesResponse.cs new file mode 100644 index 0000000000..355979d352 --- /dev/null +++ b/CefSharp/DevTools/Network/GetCookiesResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// GetCookiesResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetCookiesResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList cookies + { + get; + set; + } + + /// + /// Array of cookie objects. + /// + public System.Collections.Generic.IList Cookies + { + get + { + return cookies; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/GetRequestPostDataResponse.cs b/CefSharp/DevTools/Network/GetRequestPostDataResponse.cs new file mode 100644 index 0000000000..89cef9fd8a --- /dev/null +++ b/CefSharp/DevTools/Network/GetRequestPostDataResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// GetRequestPostDataResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetRequestPostDataResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string postData + { + get; + set; + } + + /// + /// Request body string, omitting files from multipart requests + /// + public string PostData + { + get + { + return postData; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/GetResponseBodyResponse.cs b/CefSharp/DevTools/Network/GetResponseBodyResponse.cs new file mode 100644 index 0000000000..84f0f99f6c --- /dev/null +++ b/CefSharp/DevTools/Network/GetResponseBodyResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// GetResponseBodyResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetResponseBodyResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string body + { + get; + set; + } + + /// + /// Response body. + /// + public string Body + { + get + { + return body; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal bool base64Encoded + { + get; + set; + } + + /// + /// True, if content was sent as base64. + /// + public bool Base64Encoded + { + get + { + return base64Encoded; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Initiator.cs b/CefSharp/DevTools/Network/Initiator.cs new file mode 100644 index 0000000000..62fc21b60b --- /dev/null +++ b/CefSharp/DevTools/Network/Initiator.cs @@ -0,0 +1,50 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Information about the request initiator. + /// + public class Initiator : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Type of this initiator. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// Initiator JavaScript stack trace, set for Script only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("stack"), IsRequired = (false))] + public Runtime.StackTrace Stack + { + get; + set; + } + + /// + /// Initiator URL, set for Parser type or for Script type (when script is importing module) or for SignedExchange type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (false))] + public string Url + { + get; + set; + } + + /// + /// Initiator line number, set for Parser type or for Script type (when script is importing + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (false))] + public long? LineNumber + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Network.cs b/CefSharp/DevTools/Network/Network.cs new file mode 100644 index 0000000000..5253187ae5 --- /dev/null +++ b/CefSharp/DevTools/Network/Network.cs @@ -0,0 +1,304 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + using System.Linq; + + /// + /// Network domain allows tracking network activities of the page. It exposes information about http, + public partial class Network : DevToolsDomainBase + { + public Network(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Tells whether clearing browser cache is supported. + /// + public async System.Threading.Tasks.Task CanClearBrowserCacheAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Network.canClearBrowserCache", dict); + return result.DeserializeJson(); + } + + /// + /// Tells whether clearing browser cookies is supported. + /// + public async System.Threading.Tasks.Task CanClearBrowserCookiesAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Network.canClearBrowserCookies", dict); + return result.DeserializeJson(); + } + + /// + /// Tells whether emulation of network conditions is supported. + /// + public async System.Threading.Tasks.Task CanEmulateNetworkConditionsAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Network.canEmulateNetworkConditions", dict); + return result.DeserializeJson(); + } + + /// + /// Clears browser cache. + /// + public async System.Threading.Tasks.Task ClearBrowserCacheAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Network.clearBrowserCache", dict); + return result; + } + + /// + /// Clears browser cookies. + /// + public async System.Threading.Tasks.Task ClearBrowserCookiesAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Network.clearBrowserCookies", dict); + return result; + } + + /// + /// Deletes browser cookies with matching name and url or domain/path pair. + /// + public async System.Threading.Tasks.Task DeleteCookiesAsync(string name, string url = null, string domain = null, string path = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("name", name); + if (!(string.IsNullOrEmpty(url))) + { + dict.Add("url", url); + } + + if (!(string.IsNullOrEmpty(domain))) + { + dict.Add("domain", domain); + } + + if (!(string.IsNullOrEmpty(path))) + { + dict.Add("path", path); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Network.deleteCookies", dict); + return result; + } + + /// + /// Disables network tracking, prevents network events from being sent to the client. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Network.disable", dict); + return result; + } + + /// + /// Activates emulation of network conditions. + /// + public async System.Threading.Tasks.Task EmulateNetworkConditionsAsync(bool offline, long latency, long downloadThroughput, long uploadThroughput, string connectionType = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("offline", offline); + dict.Add("latency", latency); + dict.Add("downloadThroughput", downloadThroughput); + dict.Add("uploadThroughput", uploadThroughput); + if (!(string.IsNullOrEmpty(connectionType))) + { + dict.Add("connectionType", connectionType); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Network.emulateNetworkConditions", dict); + return result; + } + + /// + /// Enables network tracking, network events will now be delivered to the client. + /// + public async System.Threading.Tasks.Task EnableAsync(int? maxTotalBufferSize = null, int? maxResourceBufferSize = null, int? maxPostDataSize = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (maxTotalBufferSize.HasValue) + { + dict.Add("maxTotalBufferSize", maxTotalBufferSize.Value); + } + + if (maxResourceBufferSize.HasValue) + { + dict.Add("maxResourceBufferSize", maxResourceBufferSize.Value); + } + + if (maxPostDataSize.HasValue) + { + dict.Add("maxPostDataSize", maxPostDataSize.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Network.enable", dict); + return result; + } + + /// + /// Returns all browser cookies. Depending on the backend support, will return detailed cookie + public async System.Threading.Tasks.Task GetAllCookiesAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Network.getAllCookies", dict); + return result.DeserializeJson(); + } + + /// + /// Returns all browser cookies for the current URL. Depending on the backend support, will return + public async System.Threading.Tasks.Task GetCookiesAsync(string urls = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (!(string.IsNullOrEmpty(urls))) + { + dict.Add("urls", urls); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Network.getCookies", dict); + return result.DeserializeJson(); + } + + /// + /// Returns content served for the given request. + /// + public async System.Threading.Tasks.Task GetResponseBodyAsync(string requestId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("requestId", requestId); + var result = await _client.ExecuteDevToolsMethodAsync("Network.getResponseBody", dict); + return result.DeserializeJson(); + } + + /// + /// Returns post data sent with the request. Returns an error when no data was sent with the request. + /// + public async System.Threading.Tasks.Task GetRequestPostDataAsync(string requestId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("requestId", requestId); + var result = await _client.ExecuteDevToolsMethodAsync("Network.getRequestPostData", dict); + return result.DeserializeJson(); + } + + /// + /// Toggles ignoring cache for each request. If `true`, cache will not be used. + /// + public async System.Threading.Tasks.Task SetCacheDisabledAsync(bool cacheDisabled) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("cacheDisabled", cacheDisabled); + var result = await _client.ExecuteDevToolsMethodAsync("Network.setCacheDisabled", dict); + return result; + } + + /// + /// Sets a cookie with the given cookie data; may overwrite equivalent cookies if they exist. + /// + public async System.Threading.Tasks.Task SetCookieAsync(string name, string value, string url = null, string domain = null, string path = null, bool? secure = null, bool? httpOnly = null, string sameSite = null, long? expires = null, string priority = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("name", name); + dict.Add("value", value); + if (!(string.IsNullOrEmpty(url))) + { + dict.Add("url", url); + } + + if (!(string.IsNullOrEmpty(domain))) + { + dict.Add("domain", domain); + } + + if (!(string.IsNullOrEmpty(path))) + { + dict.Add("path", path); + } + + if (secure.HasValue) + { + dict.Add("secure", secure.Value); + } + + if (httpOnly.HasValue) + { + dict.Add("httpOnly", httpOnly.Value); + } + + if (!(string.IsNullOrEmpty(sameSite))) + { + dict.Add("sameSite", sameSite); + } + + if (expires.HasValue) + { + dict.Add("expires", expires.Value); + } + + if (!(string.IsNullOrEmpty(priority))) + { + dict.Add("priority", priority); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Network.setCookie", dict); + return result.DeserializeJson(); + } + + /// + /// Sets given cookies. + /// + public async System.Threading.Tasks.Task SetCookiesAsync(System.Collections.Generic.IList cookies) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("cookies", cookies.Select(x => x.ToDictionary())); + var result = await _client.ExecuteDevToolsMethodAsync("Network.setCookies", dict); + return result; + } + + /// + /// Specifies whether to always send extra HTTP headers with the requests from this page. + /// + public async System.Threading.Tasks.Task SetExtraHTTPHeadersAsync(Headers headers) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("headers", headers.ToDictionary()); + var result = await _client.ExecuteDevToolsMethodAsync("Network.setExtraHTTPHeaders", dict); + return result; + } + + /// + /// Allows overriding user agent with the given string. + /// + public async System.Threading.Tasks.Task SetUserAgentOverrideAsync(string userAgent, string acceptLanguage = null, string platform = null, Emulation.UserAgentMetadata userAgentMetadata = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("userAgent", userAgent); + if (!(string.IsNullOrEmpty(acceptLanguage))) + { + dict.Add("acceptLanguage", acceptLanguage); + } + + if (!(string.IsNullOrEmpty(platform))) + { + dict.Add("platform", platform); + } + + if ((userAgentMetadata) != (null)) + { + dict.Add("userAgentMetadata", userAgentMetadata.ToDictionary()); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Network.setUserAgentOverride", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/PostDataEntry.cs b/CefSharp/DevTools/Network/PostDataEntry.cs new file mode 100644 index 0000000000..1f9ab483cf --- /dev/null +++ b/CefSharp/DevTools/Network/PostDataEntry.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Post data entry for HTTP request + /// + public class PostDataEntry : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("bytes"), IsRequired = (false))] + public string Bytes + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Request.cs b/CefSharp/DevTools/Network/Request.cs new file mode 100644 index 0000000000..91fb7112f8 --- /dev/null +++ b/CefSharp/DevTools/Network/Request.cs @@ -0,0 +1,121 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// HTTP request data. + /// + public class Request : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Request URL (without fragment). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// Fragment of the requested URL starting with hash, if present. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("urlFragment"), IsRequired = (false))] + public string UrlFragment + { + get; + set; + } + + /// + /// HTTP request method. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("method"), IsRequired = (true))] + public string Method + { + get; + set; + } + + /// + /// HTTP request headers. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("headers"), IsRequired = (true))] + public Headers Headers + { + get; + set; + } + + /// + /// HTTP POST request data. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("postData"), IsRequired = (false))] + public string PostData + { + get; + set; + } + + /// + /// True when the request has POST data. Note that postData might still be omitted when this flag is true when the data is too long. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("hasPostData"), IsRequired = (false))] + public bool? HasPostData + { + get; + set; + } + + /// + /// Request body elements. This will be converted from base64 to binary + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("postDataEntries"), IsRequired = (false))] + public System.Collections.Generic.IList PostDataEntries + { + get; + set; + } + + /// + /// The mixed content type of the request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mixedContentType"), IsRequired = (false))] + public string MixedContentType + { + get; + set; + } + + /// + /// Priority of the resource request at the time request is sent. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("initialPriority"), IsRequired = (true))] + public string InitialPriority + { + get; + set; + } + + /// + /// The referrer policy of the request, as defined in https://www.w3.org/TR/referrer-policy/ + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("referrerPolicy"), IsRequired = (true))] + public string ReferrerPolicy + { + get; + set; + } + + /// + /// Whether is loaded via link preload. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("isLinkPreload"), IsRequired = (false))] + public bool? IsLinkPreload + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/RequestPattern.cs b/CefSharp/DevTools/Network/RequestPattern.cs new file mode 100644 index 0000000000..632ef82ec5 --- /dev/null +++ b/CefSharp/DevTools/Network/RequestPattern.cs @@ -0,0 +1,40 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Request pattern for interception. + /// + public class RequestPattern : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Wildcards ('*' -> zero or more, '?' -> exactly one) are allowed. Escape character is + [System.Runtime.Serialization.DataMemberAttribute(Name = ("urlPattern"), IsRequired = (false))] + public string UrlPattern + { + get; + set; + } + + /// + /// If set, only requests for matching resource types will be intercepted. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("resourceType"), IsRequired = (false))] + public string ResourceType + { + get; + set; + } + + /// + /// Stage at wich to begin intercepting requests. Default is Request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("interceptionStage"), IsRequired = (false))] + public string InterceptionStage + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/ResourceTiming.cs b/CefSharp/DevTools/Network/ResourceTiming.cs new file mode 100644 index 0000000000..d921af005d --- /dev/null +++ b/CefSharp/DevTools/Network/ResourceTiming.cs @@ -0,0 +1,190 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Timing information for the request. + /// + public class ResourceTiming : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Timing's requestTime is a baseline in seconds, while the other numbers are ticks in + [System.Runtime.Serialization.DataMemberAttribute(Name = ("requestTime"), IsRequired = (true))] + public long RequestTime + { + get; + set; + } + + /// + /// Started resolving proxy. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("proxyStart"), IsRequired = (true))] + public long ProxyStart + { + get; + set; + } + + /// + /// Finished resolving proxy. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("proxyEnd"), IsRequired = (true))] + public long ProxyEnd + { + get; + set; + } + + /// + /// Started DNS address resolve. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("dnsStart"), IsRequired = (true))] + public long DnsStart + { + get; + set; + } + + /// + /// Finished DNS address resolve. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("dnsEnd"), IsRequired = (true))] + public long DnsEnd + { + get; + set; + } + + /// + /// Started connecting to the remote host. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("connectStart"), IsRequired = (true))] + public long ConnectStart + { + get; + set; + } + + /// + /// Connected to the remote host. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("connectEnd"), IsRequired = (true))] + public long ConnectEnd + { + get; + set; + } + + /// + /// Started SSL handshake. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sslStart"), IsRequired = (true))] + public long SslStart + { + get; + set; + } + + /// + /// Finished SSL handshake. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sslEnd"), IsRequired = (true))] + public long SslEnd + { + get; + set; + } + + /// + /// Started running ServiceWorker. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("workerStart"), IsRequired = (true))] + public long WorkerStart + { + get; + set; + } + + /// + /// Finished Starting ServiceWorker. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("workerReady"), IsRequired = (true))] + public long WorkerReady + { + get; + set; + } + + /// + /// Started fetch event. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("workerFetchStart"), IsRequired = (true))] + public long WorkerFetchStart + { + get; + set; + } + + /// + /// Settled fetch event respondWith promise. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("workerRespondWithSettled"), IsRequired = (true))] + public long WorkerRespondWithSettled + { + get; + set; + } + + /// + /// Started sending request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sendStart"), IsRequired = (true))] + public long SendStart + { + get; + set; + } + + /// + /// Finished sending request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sendEnd"), IsRequired = (true))] + public long SendEnd + { + get; + set; + } + + /// + /// Time the server started pushing request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pushStart"), IsRequired = (true))] + public long PushStart + { + get; + set; + } + + /// + /// Time the server finished pushing request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pushEnd"), IsRequired = (true))] + public long PushEnd + { + get; + set; + } + + /// + /// Finished receiving response headers. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("receiveHeadersEnd"), IsRequired = (true))] + public long ReceiveHeadersEnd + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/Response.cs b/CefSharp/DevTools/Network/Response.cs new file mode 100644 index 0000000000..357abade2b --- /dev/null +++ b/CefSharp/DevTools/Network/Response.cs @@ -0,0 +1,241 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// HTTP response data. + /// + public class Response : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Response URL. This URL can be different from CachedResource.url in case of redirect. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// HTTP response status code. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("status"), IsRequired = (true))] + public int Status + { + get; + set; + } + + /// + /// HTTP response status text. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("statusText"), IsRequired = (true))] + public string StatusText + { + get; + set; + } + + /// + /// HTTP response headers. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("headers"), IsRequired = (true))] + public Headers Headers + { + get; + set; + } + + /// + /// HTTP response headers text. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("headersText"), IsRequired = (false))] + public string HeadersText + { + get; + set; + } + + /// + /// Resource mimeType as determined by the browser. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mimeType"), IsRequired = (true))] + public string MimeType + { + get; + set; + } + + /// + /// Refined HTTP request headers that were actually transmitted over the network. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("requestHeaders"), IsRequired = (false))] + public Headers RequestHeaders + { + get; + set; + } + + /// + /// HTTP request headers text. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("requestHeadersText"), IsRequired = (false))] + public string RequestHeadersText + { + get; + set; + } + + /// + /// Specifies whether physical connection was actually reused for this request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("connectionReused"), IsRequired = (true))] + public bool ConnectionReused + { + get; + set; + } + + /// + /// Physical connection id that was actually used for this request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("connectionId"), IsRequired = (true))] + public long ConnectionId + { + get; + set; + } + + /// + /// Remote IP address. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("remoteIPAddress"), IsRequired = (false))] + public string RemoteIPAddress + { + get; + set; + } + + /// + /// Remote port. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("remotePort"), IsRequired = (false))] + public int? RemotePort + { + get; + set; + } + + /// + /// Specifies that the request was served from the disk cache. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("fromDiskCache"), IsRequired = (false))] + public bool? FromDiskCache + { + get; + set; + } + + /// + /// Specifies that the request was served from the ServiceWorker. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("fromServiceWorker"), IsRequired = (false))] + public bool? FromServiceWorker + { + get; + set; + } + + /// + /// Specifies that the request was served from the prefetch cache. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("fromPrefetchCache"), IsRequired = (false))] + public bool? FromPrefetchCache + { + get; + set; + } + + /// + /// Total number of bytes received for this request so far. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("encodedDataLength"), IsRequired = (true))] + public long EncodedDataLength + { + get; + set; + } + + /// + /// Timing information for the given request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("timing"), IsRequired = (false))] + public ResourceTiming Timing + { + get; + set; + } + + /// + /// Response source of response from ServiceWorker. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("serviceWorkerResponseSource"), IsRequired = (false))] + public string ServiceWorkerResponseSource + { + get; + set; + } + + /// + /// The time at which the returned response was generated. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("responseTime"), IsRequired = (false))] + public long? ResponseTime + { + get; + set; + } + + /// + /// Cache Storage Cache Name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("cacheStorageCacheName"), IsRequired = (false))] + public string CacheStorageCacheName + { + get; + set; + } + + /// + /// Protocol used to fetch this request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("protocol"), IsRequired = (false))] + public string Protocol + { + get; + set; + } + + /// + /// Security state of the request resource. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("securityState"), IsRequired = (true))] + public string SecurityState + { + get; + set; + } + + /// + /// Security details for the request. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("securityDetails"), IsRequired = (false))] + public SecurityDetails SecurityDetails + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/SecurityDetails.cs b/CefSharp/DevTools/Network/SecurityDetails.cs new file mode 100644 index 0000000000..c6b2604dac --- /dev/null +++ b/CefSharp/DevTools/Network/SecurityDetails.cs @@ -0,0 +1,141 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Security details about a request. + /// + public class SecurityDetails : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Protocol name (e.g. "TLS 1.2" or "QUIC"). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("protocol"), IsRequired = (true))] + public string Protocol + { + get; + set; + } + + /// + /// Key Exchange used by the connection, or the empty string if not applicable. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("keyExchange"), IsRequired = (true))] + public string KeyExchange + { + get; + set; + } + + /// + /// (EC)DH group used by the connection, if applicable. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("keyExchangeGroup"), IsRequired = (false))] + public string KeyExchangeGroup + { + get; + set; + } + + /// + /// Cipher name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("cipher"), IsRequired = (true))] + public string Cipher + { + get; + set; + } + + /// + /// TLS MAC. Note that AEAD ciphers do not have separate MACs. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mac"), IsRequired = (false))] + public string Mac + { + get; + set; + } + + /// + /// Certificate ID value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificateId"), IsRequired = (true))] + public int CertificateId + { + get; + set; + } + + /// + /// Certificate subject name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("subjectName"), IsRequired = (true))] + public string SubjectName + { + get; + set; + } + + /// + /// Subject Alternative Name (SAN) DNS names and IP addresses. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sanList"), IsRequired = (true))] + public string SanList + { + get; + set; + } + + /// + /// Name of the issuing CA. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("issuer"), IsRequired = (true))] + public string Issuer + { + get; + set; + } + + /// + /// Certificate valid from date. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("validFrom"), IsRequired = (true))] + public long ValidFrom + { + get; + set; + } + + /// + /// Certificate valid to (expiration) date + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("validTo"), IsRequired = (true))] + public long ValidTo + { + get; + set; + } + + /// + /// List of signed certificate timestamps (SCTs). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("signedCertificateTimestampList"), IsRequired = (true))] + public System.Collections.Generic.IList SignedCertificateTimestampList + { + get; + set; + } + + /// + /// Whether the request complied with Certificate Transparency policy + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificateTransparencyCompliance"), IsRequired = (true))] + public string CertificateTransparencyCompliance + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/SecurityIsolationStatus.cs b/CefSharp/DevTools/Network/SecurityIsolationStatus.cs new file mode 100644 index 0000000000..06aa53566d --- /dev/null +++ b/CefSharp/DevTools/Network/SecurityIsolationStatus.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// SecurityIsolationStatus + /// + public class SecurityIsolationStatus : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("coop"), IsRequired = (true))] + public CrossOriginOpenerPolicyStatus Coop + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("coep"), IsRequired = (true))] + public CrossOriginEmbedderPolicyStatus Coep + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/SetCookieResponse.cs b/CefSharp/DevTools/Network/SetCookieResponse.cs new file mode 100644 index 0000000000..53bbad94f1 --- /dev/null +++ b/CefSharp/DevTools/Network/SetCookieResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// SetCookieResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class SetCookieResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal bool success + { + get; + set; + } + + /// + /// True if successfully set cookie. + /// + public bool Success + { + get + { + return success; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/SignedCertificateTimestamp.cs b/CefSharp/DevTools/Network/SignedCertificateTimestamp.cs new file mode 100644 index 0000000000..334da43f56 --- /dev/null +++ b/CefSharp/DevTools/Network/SignedCertificateTimestamp.cs @@ -0,0 +1,91 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Details of a signed certificate timestamp (SCT). + /// + public class SignedCertificateTimestamp : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Validation status. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("status"), IsRequired = (true))] + public string Status + { + get; + set; + } + + /// + /// Origin. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("origin"), IsRequired = (true))] + public string Origin + { + get; + set; + } + + /// + /// Log name / description. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("logDescription"), IsRequired = (true))] + public string LogDescription + { + get; + set; + } + + /// + /// Log ID. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("logId"), IsRequired = (true))] + public string LogId + { + get; + set; + } + + /// + /// Issuance date. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("timestamp"), IsRequired = (true))] + public long Timestamp + { + get; + set; + } + + /// + /// Hash algorithm. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("hashAlgorithm"), IsRequired = (true))] + public string HashAlgorithm + { + get; + set; + } + + /// + /// Signature algorithm. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("signatureAlgorithm"), IsRequired = (true))] + public string SignatureAlgorithm + { + get; + set; + } + + /// + /// Signature data. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("signatureData"), IsRequired = (true))] + public string SignatureData + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/SignedExchangeError.cs b/CefSharp/DevTools/Network/SignedExchangeError.cs new file mode 100644 index 0000000000..d7978203eb --- /dev/null +++ b/CefSharp/DevTools/Network/SignedExchangeError.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Information about a signed exchange response. + /// + public class SignedExchangeError : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Error message. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("message"), IsRequired = (true))] + public string Message + { + get; + set; + } + + /// + /// The index of the signature which caused the error. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("signatureIndex"), IsRequired = (false))] + public int? SignatureIndex + { + get; + set; + } + + /// + /// The field which caused the error. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("errorField"), IsRequired = (false))] + public string ErrorField + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/SignedExchangeHeader.cs b/CefSharp/DevTools/Network/SignedExchangeHeader.cs new file mode 100644 index 0000000000..ce2cbe671f --- /dev/null +++ b/CefSharp/DevTools/Network/SignedExchangeHeader.cs @@ -0,0 +1,60 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Information about a signed exchange header. + public class SignedExchangeHeader : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Signed exchange request URL. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("requestUrl"), IsRequired = (true))] + public string RequestUrl + { + get; + set; + } + + /// + /// Signed exchange response code. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("responseCode"), IsRequired = (true))] + public int ResponseCode + { + get; + set; + } + + /// + /// Signed exchange response headers. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("responseHeaders"), IsRequired = (true))] + public Headers ResponseHeaders + { + get; + set; + } + + /// + /// Signed exchange response signature. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("signatures"), IsRequired = (true))] + public System.Collections.Generic.IList Signatures + { + get; + set; + } + + /// + /// Signed exchange header integrity hash in the form of "sha256-". + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("headerIntegrity"), IsRequired = (true))] + public string HeaderIntegrity + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/SignedExchangeInfo.cs b/CefSharp/DevTools/Network/SignedExchangeInfo.cs new file mode 100644 index 0000000000..01c700555a --- /dev/null +++ b/CefSharp/DevTools/Network/SignedExchangeInfo.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Information about a signed exchange response. + /// + public class SignedExchangeInfo : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The outer response of signed HTTP exchange which was received from network. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("outerResponse"), IsRequired = (true))] + public Response OuterResponse + { + get; + set; + } + + /// + /// Information about the signed exchange header. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("header"), IsRequired = (false))] + public SignedExchangeHeader Header + { + get; + set; + } + + /// + /// Security details for the signed exchange header. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("securityDetails"), IsRequired = (false))] + public SecurityDetails SecurityDetails + { + get; + set; + } + + /// + /// Errors occurred while handling the signed exchagne. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("errors"), IsRequired = (false))] + public System.Collections.Generic.IList Errors + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/SignedExchangeSignature.cs b/CefSharp/DevTools/Network/SignedExchangeSignature.cs new file mode 100644 index 0000000000..38edd5cbc2 --- /dev/null +++ b/CefSharp/DevTools/Network/SignedExchangeSignature.cs @@ -0,0 +1,100 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// Information about a signed exchange signature. + public class SignedExchangeSignature : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Signed exchange signature label. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("label"), IsRequired = (true))] + public string Label + { + get; + set; + } + + /// + /// The hex string of signed exchange signature. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("signature"), IsRequired = (true))] + public string Signature + { + get; + set; + } + + /// + /// Signed exchange signature integrity. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("integrity"), IsRequired = (true))] + public string Integrity + { + get; + set; + } + + /// + /// Signed exchange signature cert Url. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certUrl"), IsRequired = (false))] + public string CertUrl + { + get; + set; + } + + /// + /// The hex string of signed exchange signature cert sha256. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certSha256"), IsRequired = (false))] + public string CertSha256 + { + get; + set; + } + + /// + /// Signed exchange signature validity Url. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("validityUrl"), IsRequired = (true))] + public string ValidityUrl + { + get; + set; + } + + /// + /// Signed exchange signature date. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("date"), IsRequired = (true))] + public int Date + { + get; + set; + } + + /// + /// Signed exchange signature expires. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("expires"), IsRequired = (true))] + public int Expires + { + get; + set; + } + + /// + /// The encoded certificates. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificates"), IsRequired = (false))] + public string Certificates + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/WebSocketFrame.cs b/CefSharp/DevTools/Network/WebSocketFrame.cs new file mode 100644 index 0000000000..bccc6a85e9 --- /dev/null +++ b/CefSharp/DevTools/Network/WebSocketFrame.cs @@ -0,0 +1,40 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// WebSocket message data. This represents an entire WebSocket message, not just a fragmented frame as the name suggests. + /// + public class WebSocketFrame : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// WebSocket message opcode. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("opcode"), IsRequired = (true))] + public long Opcode + { + get; + set; + } + + /// + /// WebSocket message mask. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mask"), IsRequired = (true))] + public bool Mask + { + get; + set; + } + + /// + /// WebSocket message payload data. + [System.Runtime.Serialization.DataMemberAttribute(Name = ("payloadData"), IsRequired = (true))] + public string PayloadData + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/WebSocketRequest.cs b/CefSharp/DevTools/Network/WebSocketRequest.cs new file mode 100644 index 0000000000..b01096cd3b --- /dev/null +++ b/CefSharp/DevTools/Network/WebSocketRequest.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// WebSocket request data. + /// + public class WebSocketRequest : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// HTTP request headers. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("headers"), IsRequired = (true))] + public Headers Headers + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Network/WebSocketResponse.cs b/CefSharp/DevTools/Network/WebSocketResponse.cs new file mode 100644 index 0000000000..d556730121 --- /dev/null +++ b/CefSharp/DevTools/Network/WebSocketResponse.cs @@ -0,0 +1,71 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Network +{ + /// + /// WebSocket response data. + /// + public class WebSocketResponse : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// HTTP response status code. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("status"), IsRequired = (true))] + public int Status + { + get; + set; + } + + /// + /// HTTP response status text. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("statusText"), IsRequired = (true))] + public string StatusText + { + get; + set; + } + + /// + /// HTTP response headers. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("headers"), IsRequired = (true))] + public Headers Headers + { + get; + set; + } + + /// + /// HTTP response headers text. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("headersText"), IsRequired = (false))] + public string HeadersText + { + get; + set; + } + + /// + /// HTTP request headers. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("requestHeaders"), IsRequired = (false))] + public Headers RequestHeaders + { + get; + set; + } + + /// + /// HTTP request headers text. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("requestHeadersText"), IsRequired = (false))] + public string RequestHeadersText + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/AddScriptToEvaluateOnNewDocumentResponse.cs b/CefSharp/DevTools/Page/AddScriptToEvaluateOnNewDocumentResponse.cs new file mode 100644 index 0000000000..20b558f92f --- /dev/null +++ b/CefSharp/DevTools/Page/AddScriptToEvaluateOnNewDocumentResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// AddScriptToEvaluateOnNewDocumentResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class AddScriptToEvaluateOnNewDocumentResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string identifier + { + get; + set; + } + + /// + /// Identifier of the added script. + /// + public string Identifier + { + get + { + return identifier; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/AppManifestError.cs b/CefSharp/DevTools/Page/AppManifestError.cs new file mode 100644 index 0000000000..7f47bc38c2 --- /dev/null +++ b/CefSharp/DevTools/Page/AppManifestError.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Error while paring app manifest. + /// + public class AppManifestError : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Error message. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("message"), IsRequired = (true))] + public string Message + { + get; + set; + } + + /// + /// If criticial, this is a non-recoverable parse error. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("critical"), IsRequired = (true))] + public int Critical + { + get; + set; + } + + /// + /// Error line. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("line"), IsRequired = (true))] + public int Line + { + get; + set; + } + + /// + /// Error column. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("column"), IsRequired = (true))] + public int Column + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/AppManifestParsedProperties.cs b/CefSharp/DevTools/Page/AppManifestParsedProperties.cs new file mode 100644 index 0000000000..4bcfd09f70 --- /dev/null +++ b/CefSharp/DevTools/Page/AppManifestParsedProperties.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Parsed app manifest properties. + /// + public class AppManifestParsedProperties : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Computed scope value + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scope"), IsRequired = (true))] + public string Scope + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/CaptureScreenshotResponse.cs b/CefSharp/DevTools/Page/CaptureScreenshotResponse.cs new file mode 100644 index 0000000000..caeede0018 --- /dev/null +++ b/CefSharp/DevTools/Page/CaptureScreenshotResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// CaptureScreenshotResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CaptureScreenshotResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string data + { + get; + set; + } + + /// + /// Base64-encoded image data. + /// + public string Data + { + get + { + return data; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/CreateIsolatedWorldResponse.cs b/CefSharp/DevTools/Page/CreateIsolatedWorldResponse.cs new file mode 100644 index 0000000000..0f77bd1409 --- /dev/null +++ b/CefSharp/DevTools/Page/CreateIsolatedWorldResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// CreateIsolatedWorldResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CreateIsolatedWorldResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal int executionContextId + { + get; + set; + } + + /// + /// Execution context of the isolated world. + /// + public int ExecutionContextId + { + get + { + return executionContextId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Enums/AdFrameType.cs b/CefSharp/DevTools/Page/Enums/AdFrameType.cs new file mode 100644 index 0000000000..f96382d48a --- /dev/null +++ b/CefSharp/DevTools/Page/Enums/AdFrameType.cs @@ -0,0 +1,27 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Indicates whether a frame has been identified as an ad. + /// + public enum AdFrameType + { + /// + /// none + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("none"))] + None, + /// + /// child + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("child"))] + Child, + /// + /// root + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("root"))] + Root + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Enums/ClientNavigationDisposition.cs b/CefSharp/DevTools/Page/Enums/ClientNavigationDisposition.cs new file mode 100644 index 0000000000..6c35917e7e --- /dev/null +++ b/CefSharp/DevTools/Page/Enums/ClientNavigationDisposition.cs @@ -0,0 +1,32 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// ClientNavigationDisposition + /// + public enum ClientNavigationDisposition + { + /// + /// currentTab + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("currentTab"))] + CurrentTab, + /// + /// newTab + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("newTab"))] + NewTab, + /// + /// newWindow + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("newWindow"))] + NewWindow, + /// + /// download + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("download"))] + Download + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Enums/ClientNavigationReason.cs b/CefSharp/DevTools/Page/Enums/ClientNavigationReason.cs new file mode 100644 index 0000000000..1115026ffe --- /dev/null +++ b/CefSharp/DevTools/Page/Enums/ClientNavigationReason.cs @@ -0,0 +1,52 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// ClientNavigationReason + /// + public enum ClientNavigationReason + { + /// + /// formSubmissionGet + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("formSubmissionGet"))] + FormSubmissionGet, + /// + /// formSubmissionPost + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("formSubmissionPost"))] + FormSubmissionPost, + /// + /// httpHeaderRefresh + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("httpHeaderRefresh"))] + HttpHeaderRefresh, + /// + /// scriptInitiated + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("scriptInitiated"))] + ScriptInitiated, + /// + /// metaTagRefresh + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("metaTagRefresh"))] + MetaTagRefresh, + /// + /// pageBlockInterstitial + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("pageBlockInterstitial"))] + PageBlockInterstitial, + /// + /// reload + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("reload"))] + Reload, + /// + /// anchorClick + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("anchorClick"))] + AnchorClick + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Enums/CrossOriginIsolatedContextType.cs b/CefSharp/DevTools/Page/Enums/CrossOriginIsolatedContextType.cs new file mode 100644 index 0000000000..f132e71a17 --- /dev/null +++ b/CefSharp/DevTools/Page/Enums/CrossOriginIsolatedContextType.cs @@ -0,0 +1,27 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Indicates whether the frame is cross-origin isolated and why it is the case. + /// + public enum CrossOriginIsolatedContextType + { + /// + /// Isolated + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Isolated"))] + Isolated, + /// + /// NotIsolated + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("NotIsolated"))] + NotIsolated, + /// + /// NotIsolatedFeatureDisabled + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("NotIsolatedFeatureDisabled"))] + NotIsolatedFeatureDisabled + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Enums/DialogType.cs b/CefSharp/DevTools/Page/Enums/DialogType.cs new file mode 100644 index 0000000000..f94cf4415d --- /dev/null +++ b/CefSharp/DevTools/Page/Enums/DialogType.cs @@ -0,0 +1,32 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Javascript dialog type. + /// + public enum DialogType + { + /// + /// alert + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("alert"))] + Alert, + /// + /// confirm + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("confirm"))] + Confirm, + /// + /// prompt + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("prompt"))] + Prompt, + /// + /// beforeunload + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("beforeunload"))] + Beforeunload + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Enums/ReferrerPolicy.cs b/CefSharp/DevTools/Page/Enums/ReferrerPolicy.cs new file mode 100644 index 0000000000..6a0850e67b --- /dev/null +++ b/CefSharp/DevTools/Page/Enums/ReferrerPolicy.cs @@ -0,0 +1,52 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// The referring-policy used for the navigation. + /// + public enum ReferrerPolicy + { + /// + /// noReferrer + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("noReferrer"))] + NoReferrer, + /// + /// noReferrerWhenDowngrade + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("noReferrerWhenDowngrade"))] + NoReferrerWhenDowngrade, + /// + /// origin + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("origin"))] + Origin, + /// + /// originWhenCrossOrigin + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("originWhenCrossOrigin"))] + OriginWhenCrossOrigin, + /// + /// sameOrigin + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("sameOrigin"))] + SameOrigin, + /// + /// strictOrigin + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("strictOrigin"))] + StrictOrigin, + /// + /// strictOriginWhenCrossOrigin + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("strictOriginWhenCrossOrigin"))] + StrictOriginWhenCrossOrigin, + /// + /// unsafeUrl + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("unsafeUrl"))] + UnsafeUrl + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Enums/SecureContextType.cs b/CefSharp/DevTools/Page/Enums/SecureContextType.cs new file mode 100644 index 0000000000..85be561584 --- /dev/null +++ b/CefSharp/DevTools/Page/Enums/SecureContextType.cs @@ -0,0 +1,32 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Indicates whether the frame is a secure context and why it is the case. + /// + public enum SecureContextType + { + /// + /// Secure + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("Secure"))] + Secure, + /// + /// SecureLocalhost + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("SecureLocalhost"))] + SecureLocalhost, + /// + /// InsecureScheme + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("InsecureScheme"))] + InsecureScheme, + /// + /// InsecureAncestor + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("InsecureAncestor"))] + InsecureAncestor + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Enums/TransitionType.cs b/CefSharp/DevTools/Page/Enums/TransitionType.cs new file mode 100644 index 0000000000..cef5af0fb2 --- /dev/null +++ b/CefSharp/DevTools/Page/Enums/TransitionType.cs @@ -0,0 +1,77 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Transition type. + /// + public enum TransitionType + { + /// + /// link + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("link"))] + Link, + /// + /// typed + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("typed"))] + Typed, + /// + /// address_bar + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("address_bar"))] + Address_bar, + /// + /// auto_bookmark + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("auto_bookmark"))] + Auto_bookmark, + /// + /// auto_subframe + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("auto_subframe"))] + Auto_subframe, + /// + /// manual_subframe + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("manual_subframe"))] + Manual_subframe, + /// + /// generated + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("generated"))] + Generated, + /// + /// auto_toplevel + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("auto_toplevel"))] + Auto_toplevel, + /// + /// form_submit + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("form_submit"))] + Form_submit, + /// + /// reload + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("reload"))] + Reload, + /// + /// keyword + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("keyword"))] + Keyword, + /// + /// keyword_generated + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("keyword_generated"))] + Keyword_generated, + /// + /// other + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("other"))] + Other + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/FontFamilies.cs b/CefSharp/DevTools/Page/FontFamilies.cs new file mode 100644 index 0000000000..94b47bc40c --- /dev/null +++ b/CefSharp/DevTools/Page/FontFamilies.cs @@ -0,0 +1,81 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Generic font families collection. + /// + public class FontFamilies : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The standard font-family. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("standard"), IsRequired = (false))] + public string Standard + { + get; + set; + } + + /// + /// The fixed font-family. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("fixed"), IsRequired = (false))] + public string Fixed + { + get; + set; + } + + /// + /// The serif font-family. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("serif"), IsRequired = (false))] + public string Serif + { + get; + set; + } + + /// + /// The sansSerif font-family. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("sansSerif"), IsRequired = (false))] + public string SansSerif + { + get; + set; + } + + /// + /// The cursive font-family. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("cursive"), IsRequired = (false))] + public string Cursive + { + get; + set; + } + + /// + /// The fantasy font-family. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("fantasy"), IsRequired = (false))] + public string Fantasy + { + get; + set; + } + + /// + /// The pictograph font-family. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pictograph"), IsRequired = (false))] + public string Pictograph + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/FontSizes.cs b/CefSharp/DevTools/Page/FontSizes.cs new file mode 100644 index 0000000000..9e63d63d6d --- /dev/null +++ b/CefSharp/DevTools/Page/FontSizes.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Default font sizes. + /// + public class FontSizes : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Default standard font size. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("standard"), IsRequired = (false))] + public int? Standard + { + get; + set; + } + + /// + /// Default fixed font size. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("fixed"), IsRequired = (false))] + public int? Fixed + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Frame.cs b/CefSharp/DevTools/Page/Frame.cs new file mode 100644 index 0000000000..05a7bb85ac --- /dev/null +++ b/CefSharp/DevTools/Page/Frame.cs @@ -0,0 +1,140 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Information about the Frame on the page. + /// + public class Frame : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Frame unique identifier. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("id"), IsRequired = (true))] + public string Id + { + get; + set; + } + + /// + /// Parent frame identifier. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("parentId"), IsRequired = (false))] + public string ParentId + { + get; + set; + } + + /// + /// Identifier of the loader associated with this frame. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("loaderId"), IsRequired = (true))] + public string LoaderId + { + get; + set; + } + + /// + /// Frame's name as specified in the tag. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (false))] + public string Name + { + get; + set; + } + + /// + /// Frame document's URL without fragment. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// Frame document's URL fragment including the '#'. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("urlFragment"), IsRequired = (false))] + public string UrlFragment + { + get; + set; + } + + /// + /// Frame document's registered domain, taking the public suffixes list into account. + [System.Runtime.Serialization.DataMemberAttribute(Name = ("domainAndRegistry"), IsRequired = (true))] + public string DomainAndRegistry + { + get; + set; + } + + /// + /// Frame document's security origin. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("securityOrigin"), IsRequired = (true))] + public string SecurityOrigin + { + get; + set; + } + + /// + /// Frame document's mimeType as determined by the browser. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mimeType"), IsRequired = (true))] + public string MimeType + { + get; + set; + } + + /// + /// If the frame failed to load, this contains the URL that could not be loaded. Note that unlike url above, this URL may contain a fragment. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("unreachableUrl"), IsRequired = (false))] + public string UnreachableUrl + { + get; + set; + } + + /// + /// Indicates whether this frame was tagged as an ad. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("adFrameType"), IsRequired = (false))] + public string AdFrameType + { + get; + set; + } + + /// + /// Indicates whether the main document is a secure context and explains why that is the case. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("secureContextType"), IsRequired = (true))] + public string SecureContextType + { + get; + set; + } + + /// + /// Indicates whether this is a cross origin isolated context. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("crossOriginIsolatedContextType"), IsRequired = (true))] + public string CrossOriginIsolatedContextType + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/FrameResource.cs b/CefSharp/DevTools/Page/FrameResource.cs new file mode 100644 index 0000000000..86647b310a --- /dev/null +++ b/CefSharp/DevTools/Page/FrameResource.cs @@ -0,0 +1,81 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Information about the Resource on the page. + /// + public class FrameResource : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Resource URL. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// Type of this resource. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// Resource mimeType as determined by the browser. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mimeType"), IsRequired = (true))] + public string MimeType + { + get; + set; + } + + /// + /// last-modified timestamp as reported by server. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lastModified"), IsRequired = (false))] + public long? LastModified + { + get; + set; + } + + /// + /// Resource content size. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("contentSize"), IsRequired = (false))] + public long? ContentSize + { + get; + set; + } + + /// + /// True if the resource failed to load. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("failed"), IsRequired = (false))] + public bool? Failed + { + get; + set; + } + + /// + /// True if the resource was canceled during loading. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("canceled"), IsRequired = (false))] + public bool? Canceled + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/FrameResourceTree.cs b/CefSharp/DevTools/Page/FrameResourceTree.cs new file mode 100644 index 0000000000..7e1454d68f --- /dev/null +++ b/CefSharp/DevTools/Page/FrameResourceTree.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Information about the Frame hierarchy along with their cached resources. + /// + public class FrameResourceTree : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Frame information for this tree item. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("frame"), IsRequired = (true))] + public Frame Frame + { + get; + set; + } + + /// + /// Child frames. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("childFrames"), IsRequired = (false))] + public System.Collections.Generic.IList ChildFrames + { + get; + set; + } + + /// + /// Information about frame resources. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("resources"), IsRequired = (true))] + public System.Collections.Generic.IList Resources + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/FrameTree.cs b/CefSharp/DevTools/Page/FrameTree.cs new file mode 100644 index 0000000000..bf4aaea4ba --- /dev/null +++ b/CefSharp/DevTools/Page/FrameTree.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Information about the Frame hierarchy. + /// + public class FrameTree : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Frame information for this tree item. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("frame"), IsRequired = (true))] + public Frame Frame + { + get; + set; + } + + /// + /// Child frames. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("childFrames"), IsRequired = (false))] + public System.Collections.Generic.IList ChildFrames + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/GetAppManifestResponse.cs b/CefSharp/DevTools/Page/GetAppManifestResponse.cs new file mode 100644 index 0000000000..807ee95965 --- /dev/null +++ b/CefSharp/DevTools/Page/GetAppManifestResponse.cs @@ -0,0 +1,84 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// GetAppManifestResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetAppManifestResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string url + { + get; + set; + } + + /// + /// Manifest location. + /// + public string Url + { + get + { + return url; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList errors + { + get; + set; + } + + /// + /// errors + /// + public System.Collections.Generic.IList Errors + { + get + { + return errors; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string data + { + get; + set; + } + + /// + /// Manifest content. + /// + public string Data + { + get + { + return data; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal AppManifestParsedProperties parsed + { + get; + set; + } + + /// + /// Parsed manifest properties + /// + public AppManifestParsedProperties Parsed + { + get + { + return parsed; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/GetFrameTreeResponse.cs b/CefSharp/DevTools/Page/GetFrameTreeResponse.cs new file mode 100644 index 0000000000..473d4cf6f8 --- /dev/null +++ b/CefSharp/DevTools/Page/GetFrameTreeResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// GetFrameTreeResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetFrameTreeResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal FrameTree frameTree + { + get; + set; + } + + /// + /// Present frame tree structure. + /// + public FrameTree FrameTree + { + get + { + return frameTree; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/GetLayoutMetricsResponse.cs b/CefSharp/DevTools/Page/GetLayoutMetricsResponse.cs new file mode 100644 index 0000000000..bcef16a329 --- /dev/null +++ b/CefSharp/DevTools/Page/GetLayoutMetricsResponse.cs @@ -0,0 +1,66 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// GetLayoutMetricsResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetLayoutMetricsResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal LayoutViewport layoutViewport + { + get; + set; + } + + /// + /// Metrics relating to the layout viewport. + /// + public LayoutViewport LayoutViewport + { + get + { + return layoutViewport; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal VisualViewport visualViewport + { + get; + set; + } + + /// + /// Metrics relating to the visual viewport. + /// + public VisualViewport VisualViewport + { + get + { + return visualViewport; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal DOM.Rect contentSize + { + get; + set; + } + + /// + /// Size of scrollable area. + /// + public DOM.Rect ContentSize + { + get + { + return contentSize; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/GetNavigationHistoryResponse.cs b/CefSharp/DevTools/Page/GetNavigationHistoryResponse.cs new file mode 100644 index 0000000000..0c14a098b5 --- /dev/null +++ b/CefSharp/DevTools/Page/GetNavigationHistoryResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// GetNavigationHistoryResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetNavigationHistoryResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal int currentIndex + { + get; + set; + } + + /// + /// Index of the current navigation history entry. + /// + public int CurrentIndex + { + get + { + return currentIndex; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList entries + { + get; + set; + } + + /// + /// Array of navigation history entries. + /// + public System.Collections.Generic.IList Entries + { + get + { + return entries; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/InstallabilityError.cs b/CefSharp/DevTools/Page/InstallabilityError.cs new file mode 100644 index 0000000000..2421542608 --- /dev/null +++ b/CefSharp/DevTools/Page/InstallabilityError.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// The installability error + /// + public class InstallabilityError : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The error id (e.g. 'manifest-missing-suitable-icon'). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("errorId"), IsRequired = (true))] + public string ErrorId + { + get; + set; + } + + /// + /// The list of error arguments (e.g. {name:'minimum-icon-size-in-pixels', value:'64'}). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("errorArguments"), IsRequired = (true))] + public System.Collections.Generic.IList ErrorArguments + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/InstallabilityErrorArgument.cs b/CefSharp/DevTools/Page/InstallabilityErrorArgument.cs new file mode 100644 index 0000000000..7e5199bc16 --- /dev/null +++ b/CefSharp/DevTools/Page/InstallabilityErrorArgument.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// InstallabilityErrorArgument + /// + public class InstallabilityErrorArgument : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Argument name (e.g. name:'minimum-icon-size-in-pixels'). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Argument value (e.g. value:'64'). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public string Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/LayoutViewport.cs b/CefSharp/DevTools/Page/LayoutViewport.cs new file mode 100644 index 0000000000..7a662ecf2b --- /dev/null +++ b/CefSharp/DevTools/Page/LayoutViewport.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Layout viewport position and dimensions. + /// + public class LayoutViewport : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Horizontal offset relative to the document (CSS pixels). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pageX"), IsRequired = (true))] + public int PageX + { + get; + set; + } + + /// + /// Vertical offset relative to the document (CSS pixels). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pageY"), IsRequired = (true))] + public int PageY + { + get; + set; + } + + /// + /// Width (CSS pixels), excludes scrollbar if present. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("clientWidth"), IsRequired = (true))] + public int ClientWidth + { + get; + set; + } + + /// + /// Height (CSS pixels), excludes scrollbar if present. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("clientHeight"), IsRequired = (true))] + public int ClientHeight + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/NavigateResponse.cs b/CefSharp/DevTools/Page/NavigateResponse.cs new file mode 100644 index 0000000000..65dba19480 --- /dev/null +++ b/CefSharp/DevTools/Page/NavigateResponse.cs @@ -0,0 +1,66 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// NavigateResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class NavigateResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string frameId + { + get; + set; + } + + /// + /// Frame id that has navigated (or failed to navigate) + /// + public string FrameId + { + get + { + return frameId; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string loaderId + { + get; + set; + } + + /// + /// Loader identifier. + /// + public string LoaderId + { + get + { + return loaderId; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string errorText + { + get; + set; + } + + /// + /// User friendly error message, present if and only if navigation has failed. + /// + public string ErrorText + { + get + { + return errorText; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/NavigationEntry.cs b/CefSharp/DevTools/Page/NavigationEntry.cs new file mode 100644 index 0000000000..b1cb10f17e --- /dev/null +++ b/CefSharp/DevTools/Page/NavigationEntry.cs @@ -0,0 +1,61 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Navigation history entry. + /// + public class NavigationEntry : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Unique id of the navigation history entry. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("id"), IsRequired = (true))] + public int Id + { + get; + set; + } + + /// + /// URL of the navigation history entry. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// URL that the user typed in the url bar. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("userTypedURL"), IsRequired = (true))] + public string UserTypedURL + { + get; + set; + } + + /// + /// Title of the navigation history entry. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("title"), IsRequired = (true))] + public string Title + { + get; + set; + } + + /// + /// Transition type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("transitionType"), IsRequired = (true))] + public string TransitionType + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Page.cs b/CefSharp/DevTools/Page/Page.cs new file mode 100644 index 0000000000..239f2647bf --- /dev/null +++ b/CefSharp/DevTools/Page/Page.cs @@ -0,0 +1,401 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + using System.Linq; + + /// + /// Actions and events related to the inspected page belong to the page domain. + /// + public partial class Page : DevToolsDomainBase + { + public Page(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Evaluates given script in every frame upon creation (before loading frame's scripts). + /// + public async System.Threading.Tasks.Task AddScriptToEvaluateOnNewDocumentAsync(string source, string worldName = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("source", source); + if (!(string.IsNullOrEmpty(worldName))) + { + dict.Add("worldName", worldName); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Page.addScriptToEvaluateOnNewDocument", dict); + return result.DeserializeJson(); + } + + /// + /// Brings page to front (activates tab). + /// + public async System.Threading.Tasks.Task BringToFrontAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.bringToFront", dict); + return result; + } + + /// + /// Capture page screenshot. + /// + public async System.Threading.Tasks.Task CaptureScreenshotAsync(string format = null, int? quality = null, Viewport clip = null, bool? fromSurface = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (!(string.IsNullOrEmpty(format))) + { + dict.Add("format", format); + } + + if (quality.HasValue) + { + dict.Add("quality", quality.Value); + } + + if ((clip) != (null)) + { + dict.Add("clip", clip.ToDictionary()); + } + + if (fromSurface.HasValue) + { + dict.Add("fromSurface", fromSurface.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Page.captureScreenshot", dict); + return result.DeserializeJson(); + } + + /// + /// Clears the overriden Geolocation Position and Error. + /// + public async System.Threading.Tasks.Task ClearGeolocationOverrideAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.clearGeolocationOverride", dict); + return result; + } + + /// + /// Creates an isolated world for the given frame. + /// + public async System.Threading.Tasks.Task CreateIsolatedWorldAsync(string frameId, string worldName = null, bool? grantUniveralAccess = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("frameId", frameId); + if (!(string.IsNullOrEmpty(worldName))) + { + dict.Add("worldName", worldName); + } + + if (grantUniveralAccess.HasValue) + { + dict.Add("grantUniveralAccess", grantUniveralAccess.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Page.createIsolatedWorld", dict); + return result.DeserializeJson(); + } + + /// + /// Disables page domain notifications. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.disable", dict); + return result; + } + + /// + /// Enables page domain notifications. + /// + public async System.Threading.Tasks.Task EnableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.enable", dict); + return result; + } + + /// + /// + /// + public async System.Threading.Tasks.Task GetAppManifestAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.getAppManifest", dict); + return result.DeserializeJson(); + } + + /// + /// Returns present frame tree structure. + /// + public async System.Threading.Tasks.Task GetFrameTreeAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.getFrameTree", dict); + return result.DeserializeJson(); + } + + /// + /// Returns metrics relating to the layouting of the page, such as viewport bounds/scale. + /// + public async System.Threading.Tasks.Task GetLayoutMetricsAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.getLayoutMetrics", dict); + return result.DeserializeJson(); + } + + /// + /// Returns navigation history for the current page. + /// + public async System.Threading.Tasks.Task GetNavigationHistoryAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.getNavigationHistory", dict); + return result.DeserializeJson(); + } + + /// + /// Resets navigation history for the current page. + /// + public async System.Threading.Tasks.Task ResetNavigationHistoryAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.resetNavigationHistory", dict); + return result; + } + + /// + /// Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload). + /// + public async System.Threading.Tasks.Task HandleJavaScriptDialogAsync(bool accept, string promptText = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("accept", accept); + if (!(string.IsNullOrEmpty(promptText))) + { + dict.Add("promptText", promptText); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Page.handleJavaScriptDialog", dict); + return result; + } + + /// + /// Navigates current page to the given URL. + /// + public async System.Threading.Tasks.Task NavigateAsync(string url, string referrer = null, string transitionType = null, string frameId = null, string referrerPolicy = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("url", url); + if (!(string.IsNullOrEmpty(referrer))) + { + dict.Add("referrer", referrer); + } + + if (!(string.IsNullOrEmpty(transitionType))) + { + dict.Add("transitionType", transitionType); + } + + if (!(string.IsNullOrEmpty(frameId))) + { + dict.Add("frameId", frameId); + } + + if (!(string.IsNullOrEmpty(referrerPolicy))) + { + dict.Add("referrerPolicy", referrerPolicy); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Page.navigate", dict); + return result.DeserializeJson(); + } + + /// + /// Navigates current page to the given history entry. + /// + public async System.Threading.Tasks.Task NavigateToHistoryEntryAsync(int entryId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("entryId", entryId); + var result = await _client.ExecuteDevToolsMethodAsync("Page.navigateToHistoryEntry", dict); + return result; + } + + /// + /// Print page as PDF. + /// + public async System.Threading.Tasks.Task PrintToPDFAsync(bool? landscape = null, bool? displayHeaderFooter = null, bool? printBackground = null, long? scale = null, long? paperWidth = null, long? paperHeight = null, long? marginTop = null, long? marginBottom = null, long? marginLeft = null, long? marginRight = null, string pageRanges = null, bool? ignoreInvalidPageRanges = null, string headerTemplate = null, string footerTemplate = null, bool? preferCSSPageSize = null, string transferMode = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (landscape.HasValue) + { + dict.Add("landscape", landscape.Value); + } + + if (displayHeaderFooter.HasValue) + { + dict.Add("displayHeaderFooter", displayHeaderFooter.Value); + } + + if (printBackground.HasValue) + { + dict.Add("printBackground", printBackground.Value); + } + + if (scale.HasValue) + { + dict.Add("scale", scale.Value); + } + + if (paperWidth.HasValue) + { + dict.Add("paperWidth", paperWidth.Value); + } + + if (paperHeight.HasValue) + { + dict.Add("paperHeight", paperHeight.Value); + } + + if (marginTop.HasValue) + { + dict.Add("marginTop", marginTop.Value); + } + + if (marginBottom.HasValue) + { + dict.Add("marginBottom", marginBottom.Value); + } + + if (marginLeft.HasValue) + { + dict.Add("marginLeft", marginLeft.Value); + } + + if (marginRight.HasValue) + { + dict.Add("marginRight", marginRight.Value); + } + + if (!(string.IsNullOrEmpty(pageRanges))) + { + dict.Add("pageRanges", pageRanges); + } + + if (ignoreInvalidPageRanges.HasValue) + { + dict.Add("ignoreInvalidPageRanges", ignoreInvalidPageRanges.Value); + } + + if (!(string.IsNullOrEmpty(headerTemplate))) + { + dict.Add("headerTemplate", headerTemplate); + } + + if (!(string.IsNullOrEmpty(footerTemplate))) + { + dict.Add("footerTemplate", footerTemplate); + } + + if (preferCSSPageSize.HasValue) + { + dict.Add("preferCSSPageSize", preferCSSPageSize.Value); + } + + if (!(string.IsNullOrEmpty(transferMode))) + { + dict.Add("transferMode", transferMode); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Page.printToPDF", dict); + return result.DeserializeJson(); + } + + /// + /// Reloads given page optionally ignoring the cache. + /// + public async System.Threading.Tasks.Task ReloadAsync(bool? ignoreCache = null, string scriptToEvaluateOnLoad = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (ignoreCache.HasValue) + { + dict.Add("ignoreCache", ignoreCache.Value); + } + + if (!(string.IsNullOrEmpty(scriptToEvaluateOnLoad))) + { + dict.Add("scriptToEvaluateOnLoad", scriptToEvaluateOnLoad); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Page.reload", dict); + return result; + } + + /// + /// Removes given script from the list. + /// + public async System.Threading.Tasks.Task RemoveScriptToEvaluateOnNewDocumentAsync(string identifier) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("identifier", identifier); + var result = await _client.ExecuteDevToolsMethodAsync("Page.removeScriptToEvaluateOnNewDocument", dict); + return result; + } + + /// + /// Sets given markup as the document's HTML. + /// + public async System.Threading.Tasks.Task SetDocumentContentAsync(string frameId, string html) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("frameId", frameId); + dict.Add("html", html); + var result = await _client.ExecuteDevToolsMethodAsync("Page.setDocumentContent", dict); + return result; + } + + /// + /// Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position + public async System.Threading.Tasks.Task SetGeolocationOverrideAsync(long? latitude = null, long? longitude = null, long? accuracy = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (latitude.HasValue) + { + dict.Add("latitude", latitude.Value); + } + + if (longitude.HasValue) + { + dict.Add("longitude", longitude.Value); + } + + if (accuracy.HasValue) + { + dict.Add("accuracy", accuracy.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Page.setGeolocationOverride", dict); + return result; + } + + /// + /// Force the page stop all navigations and pending resource fetches. + /// + public async System.Threading.Tasks.Task StopLoadingAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Page.stopLoading", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/PrintToPDFResponse.cs b/CefSharp/DevTools/Page/PrintToPDFResponse.cs new file mode 100644 index 0000000000..0212636c84 --- /dev/null +++ b/CefSharp/DevTools/Page/PrintToPDFResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// PrintToPDFResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class PrintToPDFResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string data + { + get; + set; + } + + /// + /// Base64-encoded pdf data. Empty if |returnAsStream| is specified. + /// + public string Data + { + get + { + return data; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal string stream + { + get; + set; + } + + /// + /// A handle of the stream that holds resulting PDF data. + /// + public string Stream + { + get + { + return stream; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/ScreencastFrameMetadata.cs b/CefSharp/DevTools/Page/ScreencastFrameMetadata.cs new file mode 100644 index 0000000000..eb99c036fe --- /dev/null +++ b/CefSharp/DevTools/Page/ScreencastFrameMetadata.cs @@ -0,0 +1,81 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Screencast frame metadata. + /// + public class ScreencastFrameMetadata : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Top offset in DIP. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("offsetTop"), IsRequired = (true))] + public long OffsetTop + { + get; + set; + } + + /// + /// Page scale factor. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pageScaleFactor"), IsRequired = (true))] + public long PageScaleFactor + { + get; + set; + } + + /// + /// Device screen width in DIP. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("deviceWidth"), IsRequired = (true))] + public long DeviceWidth + { + get; + set; + } + + /// + /// Device screen height in DIP. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("deviceHeight"), IsRequired = (true))] + public long DeviceHeight + { + get; + set; + } + + /// + /// Position of horizontal scroll in CSS pixels. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scrollOffsetX"), IsRequired = (true))] + public long ScrollOffsetX + { + get; + set; + } + + /// + /// Position of vertical scroll in CSS pixels. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scrollOffsetY"), IsRequired = (true))] + public long ScrollOffsetY + { + get; + set; + } + + /// + /// Frame swap timestamp. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("timestamp"), IsRequired = (false))] + public long? Timestamp + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/Viewport.cs b/CefSharp/DevTools/Page/Viewport.cs new file mode 100644 index 0000000000..ad666109e9 --- /dev/null +++ b/CefSharp/DevTools/Page/Viewport.cs @@ -0,0 +1,61 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Viewport for capturing screenshot. + /// + public class Viewport : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// X offset in device independent pixels (dip). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("x"), IsRequired = (true))] + public long X + { + get; + set; + } + + /// + /// Y offset in device independent pixels (dip). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("y"), IsRequired = (true))] + public long Y + { + get; + set; + } + + /// + /// Rectangle width in device independent pixels (dip). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("width"), IsRequired = (true))] + public long Width + { + get; + set; + } + + /// + /// Rectangle height in device independent pixels (dip). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("height"), IsRequired = (true))] + public long Height + { + get; + set; + } + + /// + /// Page scale factor. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scale"), IsRequired = (true))] + public long Scale + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Page/VisualViewport.cs b/CefSharp/DevTools/Page/VisualViewport.cs new file mode 100644 index 0000000000..0f2ce06bfd --- /dev/null +++ b/CefSharp/DevTools/Page/VisualViewport.cs @@ -0,0 +1,91 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Page +{ + /// + /// Visual viewport position, dimensions, and scale. + /// + public class VisualViewport : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Horizontal offset relative to the layout viewport (CSS pixels). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("offsetX"), IsRequired = (true))] + public long OffsetX + { + get; + set; + } + + /// + /// Vertical offset relative to the layout viewport (CSS pixels). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("offsetY"), IsRequired = (true))] + public long OffsetY + { + get; + set; + } + + /// + /// Horizontal offset relative to the document (CSS pixels). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pageX"), IsRequired = (true))] + public long PageX + { + get; + set; + } + + /// + /// Vertical offset relative to the document (CSS pixels). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("pageY"), IsRequired = (true))] + public long PageY + { + get; + set; + } + + /// + /// Width (CSS pixels), excludes scrollbar if present. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("clientWidth"), IsRequired = (true))] + public long ClientWidth + { + get; + set; + } + + /// + /// Height (CSS pixels), excludes scrollbar if present. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("clientHeight"), IsRequired = (true))] + public long ClientHeight + { + get; + set; + } + + /// + /// Scale relative to the ideal viewport (size at width=device-width). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scale"), IsRequired = (true))] + public long Scale + { + get; + set; + } + + /// + /// Page zoom factor (CSS to device independent pixels ratio). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("zoom"), IsRequired = (false))] + public long? Zoom + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Performance/GetMetricsResponse.cs b/CefSharp/DevTools/Performance/GetMetricsResponse.cs new file mode 100644 index 0000000000..febe675187 --- /dev/null +++ b/CefSharp/DevTools/Performance/GetMetricsResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Performance +{ + /// + /// GetMetricsResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetMetricsResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList metrics + { + get; + set; + } + + /// + /// Current values for run-time metrics. + /// + public System.Collections.Generic.IList Metrics + { + get + { + return metrics; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Performance/Metric.cs b/CefSharp/DevTools/Performance/Metric.cs new file mode 100644 index 0000000000..9cf97b0776 --- /dev/null +++ b/CefSharp/DevTools/Performance/Metric.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Performance +{ + /// + /// Run-time execution metric. + /// + public class Metric : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Metric name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Metric value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public long Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Performance/Performance.cs b/CefSharp/DevTools/Performance/Performance.cs new file mode 100644 index 0000000000..f2ab6cff9f --- /dev/null +++ b/CefSharp/DevTools/Performance/Performance.cs @@ -0,0 +1,54 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Performance +{ + using System.Linq; + + /// + /// Performance + /// + public partial class Performance : DevToolsDomainBase + { + public Performance(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Disable collecting and reporting metrics. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Performance.disable", dict); + return result; + } + + /// + /// Enable collecting and reporting metrics. + /// + public async System.Threading.Tasks.Task EnableAsync(string timeDomain = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (!(string.IsNullOrEmpty(timeDomain))) + { + dict.Add("timeDomain", timeDomain); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Performance.enable", dict); + return result; + } + + /// + /// Retrieve current values of run-time metrics. + /// + public async System.Threading.Tasks.Task GetMetricsAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Performance.getMetrics", dict); + return result.DeserializeJson(); + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/CounterInfo.cs b/CefSharp/DevTools/Profiler/CounterInfo.cs new file mode 100644 index 0000000000..71a5adf431 --- /dev/null +++ b/CefSharp/DevTools/Profiler/CounterInfo.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Collected counter information. + /// + public class CounterInfo : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Counter name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Counter value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public int Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/CoverageRange.cs b/CefSharp/DevTools/Profiler/CoverageRange.cs new file mode 100644 index 0000000000..31e3758938 --- /dev/null +++ b/CefSharp/DevTools/Profiler/CoverageRange.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Coverage data for a source range. + /// + public class CoverageRange : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// JavaScript script source offset for the range start. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("startOffset"), IsRequired = (true))] + public int StartOffset + { + get; + set; + } + + /// + /// JavaScript script source offset for the range end. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("endOffset"), IsRequired = (true))] + public int EndOffset + { + get; + set; + } + + /// + /// Collected execution count of the source range. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("count"), IsRequired = (true))] + public int Count + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/FunctionCoverage.cs b/CefSharp/DevTools/Profiler/FunctionCoverage.cs new file mode 100644 index 0000000000..b5c57b0af0 --- /dev/null +++ b/CefSharp/DevTools/Profiler/FunctionCoverage.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Coverage data for a JavaScript function. + /// + public class FunctionCoverage : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// JavaScript function name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("functionName"), IsRequired = (true))] + public string FunctionName + { + get; + set; + } + + /// + /// Source ranges inside the function with coverage data. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("ranges"), IsRequired = (true))] + public System.Collections.Generic.IList Ranges + { + get; + set; + } + + /// + /// Whether coverage data for this function has block granularity. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("isBlockCoverage"), IsRequired = (true))] + public bool IsBlockCoverage + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/GetBestEffortCoverageResponse.cs b/CefSharp/DevTools/Profiler/GetBestEffortCoverageResponse.cs new file mode 100644 index 0000000000..201b70e11b --- /dev/null +++ b/CefSharp/DevTools/Profiler/GetBestEffortCoverageResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// GetBestEffortCoverageResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetBestEffortCoverageResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList result + { + get; + set; + } + + /// + /// Coverage data for the current isolate. + /// + public System.Collections.Generic.IList Result + { + get + { + return result; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/PositionTickInfo.cs b/CefSharp/DevTools/Profiler/PositionTickInfo.cs new file mode 100644 index 0000000000..565f05af60 --- /dev/null +++ b/CefSharp/DevTools/Profiler/PositionTickInfo.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Specifies a number of samples attributed to a certain source position. + /// + public class PositionTickInfo : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Source line number (1-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("line"), IsRequired = (true))] + public int Line + { + get; + set; + } + + /// + /// Number of samples attributed to the source line. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("ticks"), IsRequired = (true))] + public int Ticks + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/Profile.cs b/CefSharp/DevTools/Profiler/Profile.cs new file mode 100644 index 0000000000..794ac3329e --- /dev/null +++ b/CefSharp/DevTools/Profiler/Profile.cs @@ -0,0 +1,60 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Profile. + /// + public class Profile : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The list of profile nodes. First item is the root node. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("nodes"), IsRequired = (true))] + public System.Collections.Generic.IList Nodes + { + get; + set; + } + + /// + /// Profiling start timestamp in microseconds. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("startTime"), IsRequired = (true))] + public long StartTime + { + get; + set; + } + + /// + /// Profiling end timestamp in microseconds. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("endTime"), IsRequired = (true))] + public long EndTime + { + get; + set; + } + + /// + /// Ids of samples top nodes. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("samples"), IsRequired = (false))] + public int? Samples + { + get; + set; + } + + /// + /// Time intervals between adjacent samples in microseconds. The first delta is relative to the + [System.Runtime.Serialization.DataMemberAttribute(Name = ("timeDeltas"), IsRequired = (false))] + public int? TimeDeltas + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/ProfileNode.cs b/CefSharp/DevTools/Profiler/ProfileNode.cs new file mode 100644 index 0000000000..aaa224b0cf --- /dev/null +++ b/CefSharp/DevTools/Profiler/ProfileNode.cs @@ -0,0 +1,70 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Profile node. Holds callsite information, execution statistics and child nodes. + /// + public class ProfileNode : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Unique id of the node. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("id"), IsRequired = (true))] + public int Id + { + get; + set; + } + + /// + /// Function location. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("callFrame"), IsRequired = (true))] + public Runtime.CallFrame CallFrame + { + get; + set; + } + + /// + /// Number of samples where this node was on top of the call stack. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("hitCount"), IsRequired = (false))] + public int? HitCount + { + get; + set; + } + + /// + /// Child node ids. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("children"), IsRequired = (false))] + public int? Children + { + get; + set; + } + + /// + /// The reason of being not optimized. The function may be deoptimized or marked as don't + [System.Runtime.Serialization.DataMemberAttribute(Name = ("deoptReason"), IsRequired = (false))] + public string DeoptReason + { + get; + set; + } + + /// + /// An array of source position ticks. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("positionTicks"), IsRequired = (false))] + public System.Collections.Generic.IList PositionTicks + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/Profiler.cs b/CefSharp/DevTools/Profiler/Profiler.cs new file mode 100644 index 0000000000..385ea30824 --- /dev/null +++ b/CefSharp/DevTools/Profiler/Profiler.cs @@ -0,0 +1,121 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + using System.Linq; + + /// + /// Profiler + /// + public partial class Profiler : DevToolsDomainBase + { + public Profiler(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.disable", dict); + return result; + } + + /// + /// + /// + public async System.Threading.Tasks.Task EnableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.enable", dict); + return result; + } + + /// + /// Collect coverage data for the current isolate. The coverage data may be incomplete due to + public async System.Threading.Tasks.Task GetBestEffortCoverageAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.getBestEffortCoverage", dict); + return result.DeserializeJson(); + } + + /// + /// Changes CPU profiler sampling interval. Must be called before CPU profiles recording started. + /// + public async System.Threading.Tasks.Task SetSamplingIntervalAsync(int interval) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("interval", interval); + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.setSamplingInterval", dict); + return result; + } + + /// + /// + /// + public async System.Threading.Tasks.Task StartAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.start", dict); + return result; + } + + /// + /// Enable precise code coverage. Coverage data for JavaScript executed before enabling precise code + public async System.Threading.Tasks.Task StartPreciseCoverageAsync(bool? callCount = null, bool? detailed = null, bool? allowTriggeredUpdates = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (callCount.HasValue) + { + dict.Add("callCount", callCount.Value); + } + + if (detailed.HasValue) + { + dict.Add("detailed", detailed.Value); + } + + if (allowTriggeredUpdates.HasValue) + { + dict.Add("allowTriggeredUpdates", allowTriggeredUpdates.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.startPreciseCoverage", dict); + return result.DeserializeJson(); + } + + /// + /// + /// + public async System.Threading.Tasks.Task StopAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.stop", dict); + return result.DeserializeJson(); + } + + /// + /// Disable precise code coverage. Disabling releases unnecessary execution count records and allows + public async System.Threading.Tasks.Task StopPreciseCoverageAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.stopPreciseCoverage", dict); + return result; + } + + /// + /// Collect coverage data for the current isolate, and resets execution counters. Precise code + public async System.Threading.Tasks.Task TakePreciseCoverageAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Profiler.takePreciseCoverage", dict); + return result.DeserializeJson(); + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/ScriptCoverage.cs b/CefSharp/DevTools/Profiler/ScriptCoverage.cs new file mode 100644 index 0000000000..a1eaa78856 --- /dev/null +++ b/CefSharp/DevTools/Profiler/ScriptCoverage.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Coverage data for a JavaScript script. + /// + public class ScriptCoverage : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// JavaScript script id. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scriptId"), IsRequired = (true))] + public string ScriptId + { + get; + set; + } + + /// + /// JavaScript script name or url. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// Functions contained in the script that has coverage data. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("functions"), IsRequired = (true))] + public System.Collections.Generic.IList Functions + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/ScriptTypeProfile.cs b/CefSharp/DevTools/Profiler/ScriptTypeProfile.cs new file mode 100644 index 0000000000..fa4d48dea0 --- /dev/null +++ b/CefSharp/DevTools/Profiler/ScriptTypeProfile.cs @@ -0,0 +1,41 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Type profile data collected during runtime for a JavaScript script. + /// + public class ScriptTypeProfile : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// JavaScript script id. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scriptId"), IsRequired = (true))] + public string ScriptId + { + get; + set; + } + + /// + /// JavaScript script name or url. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// Type profile entries for parameters and return values of the functions in the script. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("entries"), IsRequired = (true))] + public System.Collections.Generic.IList Entries + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/StartPreciseCoverageResponse.cs b/CefSharp/DevTools/Profiler/StartPreciseCoverageResponse.cs new file mode 100644 index 0000000000..a64b5be2c9 --- /dev/null +++ b/CefSharp/DevTools/Profiler/StartPreciseCoverageResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// StartPreciseCoverageResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class StartPreciseCoverageResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal long timestamp + { + get; + set; + } + + /// + /// Monotonically increasing time (in seconds) when the coverage update was taken in the backend. + /// + public long Timestamp + { + get + { + return timestamp; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/StopResponse.cs b/CefSharp/DevTools/Profiler/StopResponse.cs new file mode 100644 index 0000000000..ad7f2052f8 --- /dev/null +++ b/CefSharp/DevTools/Profiler/StopResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// StopResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class StopResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal Profile profile + { + get; + set; + } + + /// + /// Recorded profile. + /// + public Profile Profile + { + get + { + return profile; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/TakePreciseCoverageResponse.cs b/CefSharp/DevTools/Profiler/TakePreciseCoverageResponse.cs new file mode 100644 index 0000000000..e68d4ecd56 --- /dev/null +++ b/CefSharp/DevTools/Profiler/TakePreciseCoverageResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// TakePreciseCoverageResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class TakePreciseCoverageResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList result + { + get; + set; + } + + /// + /// Coverage data for the current isolate. + /// + public System.Collections.Generic.IList Result + { + get + { + return result; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal long timestamp + { + get; + set; + } + + /// + /// Monotonically increasing time (in seconds) when the coverage update was taken in the backend. + /// + public long Timestamp + { + get + { + return timestamp; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/TypeObject.cs b/CefSharp/DevTools/Profiler/TypeObject.cs new file mode 100644 index 0000000000..a36b63c808 --- /dev/null +++ b/CefSharp/DevTools/Profiler/TypeObject.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Describes a type collected during runtime. + /// + public class TypeObject : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Name of a type collected with type profiling. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Profiler/TypeProfileEntry.cs b/CefSharp/DevTools/Profiler/TypeProfileEntry.cs new file mode 100644 index 0000000000..5dc06c5fe4 --- /dev/null +++ b/CefSharp/DevTools/Profiler/TypeProfileEntry.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Profiler +{ + /// + /// Source offset and types for a parameter or return value. + /// + public class TypeProfileEntry : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Source offset of the parameter or end of function for return values. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("offset"), IsRequired = (true))] + public int Offset + { + get; + set; + } + + /// + /// The types for this parameter or return value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("types"), IsRequired = (true))] + public System.Collections.Generic.IList Types + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/AwaitPromiseResponse.cs b/CefSharp/DevTools/Runtime/AwaitPromiseResponse.cs new file mode 100644 index 0000000000..768392374d --- /dev/null +++ b/CefSharp/DevTools/Runtime/AwaitPromiseResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// AwaitPromiseResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class AwaitPromiseResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal RemoteObject result + { + get; + set; + } + + /// + /// Promise result. Will contain rejected value if promise was rejected. + /// + public RemoteObject Result + { + get + { + return result; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal ExceptionDetails exceptionDetails + { + get; + set; + } + + /// + /// Exception details if stack strace is available. + /// + public ExceptionDetails ExceptionDetails + { + get + { + return exceptionDetails; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/CallArgument.cs b/CefSharp/DevTools/Runtime/CallArgument.cs new file mode 100644 index 0000000000..95cb402cf6 --- /dev/null +++ b/CefSharp/DevTools/Runtime/CallArgument.cs @@ -0,0 +1,40 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Represents function call argument. Either remote object id `objectId`, primitive `value`, + public class CallArgument : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Primitive value or serializable javascript object. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (false))] + public object Value + { + get; + set; + } + + /// + /// Primitive value which can not be JSON-stringified. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("unserializableValue"), IsRequired = (false))] + public string UnserializableValue + { + get; + set; + } + + /// + /// Remote object handle. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("objectId"), IsRequired = (false))] + public string ObjectId + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/CallFrame.cs b/CefSharp/DevTools/Runtime/CallFrame.cs new file mode 100644 index 0000000000..0fde4d8c9c --- /dev/null +++ b/CefSharp/DevTools/Runtime/CallFrame.cs @@ -0,0 +1,61 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Stack entry for runtime errors and assertions. + /// + public class CallFrame : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// JavaScript function name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("functionName"), IsRequired = (true))] + public string FunctionName + { + get; + set; + } + + /// + /// JavaScript script id. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scriptId"), IsRequired = (true))] + public string ScriptId + { + get; + set; + } + + /// + /// JavaScript script name or url. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// JavaScript script line number (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (true))] + public int LineNumber + { + get; + set; + } + + /// + /// JavaScript script column number (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("columnNumber"), IsRequired = (true))] + public int ColumnNumber + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/CallFunctionOnResponse.cs b/CefSharp/DevTools/Runtime/CallFunctionOnResponse.cs new file mode 100644 index 0000000000..522c451437 --- /dev/null +++ b/CefSharp/DevTools/Runtime/CallFunctionOnResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// CallFunctionOnResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CallFunctionOnResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal RemoteObject result + { + get; + set; + } + + /// + /// Call result. + /// + public RemoteObject Result + { + get + { + return result; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal ExceptionDetails exceptionDetails + { + get; + set; + } + + /// + /// Exception details. + /// + public ExceptionDetails ExceptionDetails + { + get + { + return exceptionDetails; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/CompileScriptResponse.cs b/CefSharp/DevTools/Runtime/CompileScriptResponse.cs new file mode 100644 index 0000000000..679ceb4463 --- /dev/null +++ b/CefSharp/DevTools/Runtime/CompileScriptResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// CompileScriptResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CompileScriptResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string scriptId + { + get; + set; + } + + /// + /// Id of the script. + /// + public string ScriptId + { + get + { + return scriptId; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal ExceptionDetails exceptionDetails + { + get; + set; + } + + /// + /// Exception details. + /// + public ExceptionDetails ExceptionDetails + { + get + { + return exceptionDetails; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/CustomPreview.cs b/CefSharp/DevTools/Runtime/CustomPreview.cs new file mode 100644 index 0000000000..84e2a83ec1 --- /dev/null +++ b/CefSharp/DevTools/Runtime/CustomPreview.cs @@ -0,0 +1,29 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// CustomPreview + /// + public class CustomPreview : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The JSON-stringified result of formatter.header(object, config) call. + [System.Runtime.Serialization.DataMemberAttribute(Name = ("header"), IsRequired = (true))] + public string Header + { + get; + set; + } + + /// + /// If formatter returns true as a result of formatter.hasBody call then bodyGetterId will + [System.Runtime.Serialization.DataMemberAttribute(Name = ("bodyGetterId"), IsRequired = (false))] + public string BodyGetterId + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/EntryPreview.cs b/CefSharp/DevTools/Runtime/EntryPreview.cs new file mode 100644 index 0000000000..dbd6d78534 --- /dev/null +++ b/CefSharp/DevTools/Runtime/EntryPreview.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// EntryPreview + /// + public class EntryPreview : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Preview of the key. Specified for map-like collection entries. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("key"), IsRequired = (false))] + public ObjectPreview Key + { + get; + set; + } + + /// + /// Preview of the value. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (true))] + public ObjectPreview Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/EvaluateResponse.cs b/CefSharp/DevTools/Runtime/EvaluateResponse.cs new file mode 100644 index 0000000000..5dfb3723a9 --- /dev/null +++ b/CefSharp/DevTools/Runtime/EvaluateResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// EvaluateResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class EvaluateResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal RemoteObject result + { + get; + set; + } + + /// + /// Evaluation result. + /// + public RemoteObject Result + { + get + { + return result; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal ExceptionDetails exceptionDetails + { + get; + set; + } + + /// + /// Exception details. + /// + public ExceptionDetails ExceptionDetails + { + get + { + return exceptionDetails; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/ExceptionDetails.cs b/CefSharp/DevTools/Runtime/ExceptionDetails.cs new file mode 100644 index 0000000000..efb3229423 --- /dev/null +++ b/CefSharp/DevTools/Runtime/ExceptionDetails.cs @@ -0,0 +1,100 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Detailed information about exception (or error) that was thrown during script compilation or + public class ExceptionDetails : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Exception id. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("exceptionId"), IsRequired = (true))] + public int ExceptionId + { + get; + set; + } + + /// + /// Exception text, which should be used together with exception object when available. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("text"), IsRequired = (true))] + public string Text + { + get; + set; + } + + /// + /// Line number of the exception location (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("lineNumber"), IsRequired = (true))] + public int LineNumber + { + get; + set; + } + + /// + /// Column number of the exception location (0-based). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("columnNumber"), IsRequired = (true))] + public int ColumnNumber + { + get; + set; + } + + /// + /// Script ID of the exception location. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("scriptId"), IsRequired = (false))] + public string ScriptId + { + get; + set; + } + + /// + /// URL of the exception location, to be used when the script was not reported. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (false))] + public string Url + { + get; + set; + } + + /// + /// JavaScript stack trace if available. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("stackTrace"), IsRequired = (false))] + public StackTrace StackTrace + { + get; + set; + } + + /// + /// Exception object if available. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("exception"), IsRequired = (false))] + public RemoteObject Exception + { + get; + set; + } + + /// + /// Identifier of the context where exception happened. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("executionContextId"), IsRequired = (false))] + public int? ExecutionContextId + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/ExecutionContextDescription.cs b/CefSharp/DevTools/Runtime/ExecutionContextDescription.cs new file mode 100644 index 0000000000..984ef8fb35 --- /dev/null +++ b/CefSharp/DevTools/Runtime/ExecutionContextDescription.cs @@ -0,0 +1,50 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Description of an isolated world. + /// + public class ExecutionContextDescription : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Unique id of the execution context. It can be used to specify in which execution context + [System.Runtime.Serialization.DataMemberAttribute(Name = ("id"), IsRequired = (true))] + public int Id + { + get; + set; + } + + /// + /// Execution context origin. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("origin"), IsRequired = (true))] + public string Origin + { + get; + set; + } + + /// + /// Human readable name describing given context. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Embedder-specific auxiliary data. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("auxData"), IsRequired = (false))] + public object AuxData + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/GetPropertiesResponse.cs b/CefSharp/DevTools/Runtime/GetPropertiesResponse.cs new file mode 100644 index 0000000000..3bbc3e8894 --- /dev/null +++ b/CefSharp/DevTools/Runtime/GetPropertiesResponse.cs @@ -0,0 +1,84 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// GetPropertiesResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetPropertiesResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList result + { + get; + set; + } + + /// + /// Object properties. + /// + public System.Collections.Generic.IList Result + { + get + { + return result; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList internalProperties + { + get; + set; + } + + /// + /// Internal object properties (only of the element itself). + /// + public System.Collections.Generic.IList InternalProperties + { + get + { + return internalProperties; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList privateProperties + { + get; + set; + } + + /// + /// Object private properties. + /// + public System.Collections.Generic.IList PrivateProperties + { + get + { + return privateProperties; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal ExceptionDetails exceptionDetails + { + get; + set; + } + + /// + /// Exception details. + /// + public ExceptionDetails ExceptionDetails + { + get + { + return exceptionDetails; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/GlobalLexicalScopeNamesResponse.cs b/CefSharp/DevTools/Runtime/GlobalLexicalScopeNamesResponse.cs new file mode 100644 index 0000000000..94afddbb8e --- /dev/null +++ b/CefSharp/DevTools/Runtime/GlobalLexicalScopeNamesResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// GlobalLexicalScopeNamesResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GlobalLexicalScopeNamesResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string names + { + get; + set; + } + + /// + /// names + /// + public string Names + { + get + { + return names; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/InternalPropertyDescriptor.cs b/CefSharp/DevTools/Runtime/InternalPropertyDescriptor.cs new file mode 100644 index 0000000000..41fc7a455a --- /dev/null +++ b/CefSharp/DevTools/Runtime/InternalPropertyDescriptor.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Object internal property descriptor. This property isn't normally visible in JavaScript code. + /// + public class InternalPropertyDescriptor : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Conventional property name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// The value associated with the property. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (false))] + public RemoteObject Value + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/ObjectPreview.cs b/CefSharp/DevTools/Runtime/ObjectPreview.cs new file mode 100644 index 0000000000..d474541034 --- /dev/null +++ b/CefSharp/DevTools/Runtime/ObjectPreview.cs @@ -0,0 +1,71 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Object containing abbreviated remote object value. + /// + public class ObjectPreview : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Object type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// Object subtype hint. Specified for `object` type values only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("subtype"), IsRequired = (false))] + public string Subtype + { + get; + set; + } + + /// + /// String representation of the object. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("description"), IsRequired = (false))] + public string Description + { + get; + set; + } + + /// + /// True iff some of the properties or entries of the original object did not fit. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("overflow"), IsRequired = (true))] + public bool Overflow + { + get; + set; + } + + /// + /// List of the properties. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("properties"), IsRequired = (true))] + public System.Collections.Generic.IList Properties + { + get; + set; + } + + /// + /// List of the entries. Specified for `map` and `set` subtype values only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("entries"), IsRequired = (false))] + public System.Collections.Generic.IList Entries + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/PrivatePropertyDescriptor.cs b/CefSharp/DevTools/Runtime/PrivatePropertyDescriptor.cs new file mode 100644 index 0000000000..a18638efae --- /dev/null +++ b/CefSharp/DevTools/Runtime/PrivatePropertyDescriptor.cs @@ -0,0 +1,49 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Object private field descriptor. + /// + public class PrivatePropertyDescriptor : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Private property name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// The value associated with the private property. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (false))] + public RemoteObject Value + { + get; + set; + } + + /// + /// A function which serves as a getter for the private property, + [System.Runtime.Serialization.DataMemberAttribute(Name = ("get"), IsRequired = (false))] + public RemoteObject Get + { + get; + set; + } + + /// + /// A function which serves as a setter for the private property, + [System.Runtime.Serialization.DataMemberAttribute(Name = ("set"), IsRequired = (false))] + public RemoteObject Set + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/PropertyDescriptor.cs b/CefSharp/DevTools/Runtime/PropertyDescriptor.cs new file mode 100644 index 0000000000..2a4dfd2852 --- /dev/null +++ b/CefSharp/DevTools/Runtime/PropertyDescriptor.cs @@ -0,0 +1,107 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Object property descriptor. + /// + public class PropertyDescriptor : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Property name or symbol description. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// The value associated with the property. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (false))] + public RemoteObject Value + { + get; + set; + } + + /// + /// True if the value associated with the property may be changed (data descriptors only). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("writable"), IsRequired = (false))] + public bool? Writable + { + get; + set; + } + + /// + /// A function which serves as a getter for the property, or `undefined` if there is no getter + [System.Runtime.Serialization.DataMemberAttribute(Name = ("get"), IsRequired = (false))] + public RemoteObject Get + { + get; + set; + } + + /// + /// A function which serves as a setter for the property, or `undefined` if there is no setter + [System.Runtime.Serialization.DataMemberAttribute(Name = ("set"), IsRequired = (false))] + public RemoteObject Set + { + get; + set; + } + + /// + /// True if the type of this property descriptor may be changed and if the property may be + [System.Runtime.Serialization.DataMemberAttribute(Name = ("configurable"), IsRequired = (true))] + public bool Configurable + { + get; + set; + } + + /// + /// True if this property shows up during enumeration of the properties on the corresponding + [System.Runtime.Serialization.DataMemberAttribute(Name = ("enumerable"), IsRequired = (true))] + public bool Enumerable + { + get; + set; + } + + /// + /// True if the result was thrown during the evaluation. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("wasThrown"), IsRequired = (false))] + public bool? WasThrown + { + get; + set; + } + + /// + /// True if the property is owned for the object. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("isOwn"), IsRequired = (false))] + public bool? IsOwn + { + get; + set; + } + + /// + /// Property symbol object, if the property is of the `symbol` type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("symbol"), IsRequired = (false))] + public RemoteObject Symbol + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/PropertyPreview.cs b/CefSharp/DevTools/Runtime/PropertyPreview.cs new file mode 100644 index 0000000000..35a19a421b --- /dev/null +++ b/CefSharp/DevTools/Runtime/PropertyPreview.cs @@ -0,0 +1,61 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// PropertyPreview + /// + public class PropertyPreview : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Property name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Object type. Accessor means that the property itself is an accessor property. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// User-friendly property value string. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (false))] + public string Value + { + get; + set; + } + + /// + /// Nested value preview. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("valuePreview"), IsRequired = (false))] + public ObjectPreview ValuePreview + { + get; + set; + } + + /// + /// Object subtype hint. Specified for `object` type values only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("subtype"), IsRequired = (false))] + public string Subtype + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/QueryObjectsResponse.cs b/CefSharp/DevTools/Runtime/QueryObjectsResponse.cs new file mode 100644 index 0000000000..f1f15ff79a --- /dev/null +++ b/CefSharp/DevTools/Runtime/QueryObjectsResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// QueryObjectsResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class QueryObjectsResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal RemoteObject objects + { + get; + set; + } + + /// + /// Array with objects. + /// + public RemoteObject Objects + { + get + { + return objects; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/RemoteObject.cs b/CefSharp/DevTools/Runtime/RemoteObject.cs new file mode 100644 index 0000000000..a0bbb049a3 --- /dev/null +++ b/CefSharp/DevTools/Runtime/RemoteObject.cs @@ -0,0 +1,100 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Mirror object referencing original JavaScript object. + /// + public class RemoteObject : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Object type. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// Object subtype hint. Specified for `object` or `wasm` type values only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("subtype"), IsRequired = (false))] + public string Subtype + { + get; + set; + } + + /// + /// Object class (constructor) name. Specified for `object` type values only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("className"), IsRequired = (false))] + public string ClassName + { + get; + set; + } + + /// + /// Remote object value in case of primitive values or JSON values (if it was requested). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("value"), IsRequired = (false))] + public object Value + { + get; + set; + } + + /// + /// Primitive value which can not be JSON-stringified does not have `value`, but gets this + [System.Runtime.Serialization.DataMemberAttribute(Name = ("unserializableValue"), IsRequired = (false))] + public string UnserializableValue + { + get; + set; + } + + /// + /// String representation of the object. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("description"), IsRequired = (false))] + public string Description + { + get; + set; + } + + /// + /// Unique object identifier (for non-primitive values). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("objectId"), IsRequired = (false))] + public string ObjectId + { + get; + set; + } + + /// + /// Preview containing abbreviated property values. Specified for `object` type values only. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("preview"), IsRequired = (false))] + public ObjectPreview Preview + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("customPreview"), IsRequired = (false))] + public CustomPreview CustomPreview + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/RunScriptResponse.cs b/CefSharp/DevTools/Runtime/RunScriptResponse.cs new file mode 100644 index 0000000000..360a020979 --- /dev/null +++ b/CefSharp/DevTools/Runtime/RunScriptResponse.cs @@ -0,0 +1,48 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// RunScriptResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class RunScriptResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal RemoteObject result + { + get; + set; + } + + /// + /// Run result. + /// + public RemoteObject Result + { + get + { + return result; + } + } + + [System.Runtime.Serialization.DataMemberAttribute] + internal ExceptionDetails exceptionDetails + { + get; + set; + } + + /// + /// Exception details. + /// + public ExceptionDetails ExceptionDetails + { + get + { + return exceptionDetails; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/Runtime.cs b/CefSharp/DevTools/Runtime/Runtime.cs new file mode 100644 index 0000000000..ca6a3f6369 --- /dev/null +++ b/CefSharp/DevTools/Runtime/Runtime.cs @@ -0,0 +1,362 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + using System.Linq; + + /// + /// Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. + public partial class Runtime : DevToolsDomainBase + { + public Runtime(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Add handler to promise with given promise object id. + /// + public async System.Threading.Tasks.Task AwaitPromiseAsync(string promiseObjectId, bool? returnByValue = null, bool? generatePreview = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("promiseObjectId", promiseObjectId); + if (returnByValue.HasValue) + { + dict.Add("returnByValue", returnByValue.Value); + } + + if (generatePreview.HasValue) + { + dict.Add("generatePreview", generatePreview.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.awaitPromise", dict); + return result.DeserializeJson(); + } + + /// + /// Calls function with given declaration on the given object. Object group of the result is + public async System.Threading.Tasks.Task CallFunctionOnAsync(string functionDeclaration, string objectId = null, System.Collections.Generic.IList arguments = null, bool? silent = null, bool? returnByValue = null, bool? generatePreview = null, bool? userGesture = null, bool? awaitPromise = null, int? executionContextId = null, string objectGroup = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("functionDeclaration", functionDeclaration); + if (!(string.IsNullOrEmpty(objectId))) + { + dict.Add("objectId", objectId); + } + + if ((arguments) != (null)) + { + dict.Add("arguments", arguments.Select(x => x.ToDictionary())); + } + + if (silent.HasValue) + { + dict.Add("silent", silent.Value); + } + + if (returnByValue.HasValue) + { + dict.Add("returnByValue", returnByValue.Value); + } + + if (generatePreview.HasValue) + { + dict.Add("generatePreview", generatePreview.Value); + } + + if (userGesture.HasValue) + { + dict.Add("userGesture", userGesture.Value); + } + + if (awaitPromise.HasValue) + { + dict.Add("awaitPromise", awaitPromise.Value); + } + + if (executionContextId.HasValue) + { + dict.Add("executionContextId", executionContextId.Value); + } + + if (!(string.IsNullOrEmpty(objectGroup))) + { + dict.Add("objectGroup", objectGroup); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.callFunctionOn", dict); + return result.DeserializeJson(); + } + + /// + /// Compiles expression. + /// + public async System.Threading.Tasks.Task CompileScriptAsync(string expression, string sourceURL, bool persistScript, int? executionContextId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("expression", expression); + dict.Add("sourceURL", sourceURL); + dict.Add("persistScript", persistScript); + if (executionContextId.HasValue) + { + dict.Add("executionContextId", executionContextId.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.compileScript", dict); + return result.DeserializeJson(); + } + + /// + /// Disables reporting of execution contexts creation. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.disable", dict); + return result; + } + + /// + /// Discards collected exceptions and console API calls. + /// + public async System.Threading.Tasks.Task DiscardConsoleEntriesAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.discardConsoleEntries", dict); + return result; + } + + /// + /// Enables reporting of execution contexts creation by means of `executionContextCreated` event. + public async System.Threading.Tasks.Task EnableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.enable", dict); + return result; + } + + /// + /// Evaluates expression on global object. + /// + public async System.Threading.Tasks.Task EvaluateAsync(string expression, string objectGroup = null, bool? includeCommandLineAPI = null, bool? silent = null, int? contextId = null, bool? returnByValue = null, bool? generatePreview = null, bool? userGesture = null, bool? awaitPromise = null, bool? throwOnSideEffect = null, long? timeout = null, bool? disableBreaks = null, bool? replMode = null, bool? allowUnsafeEvalBlockedByCSP = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("expression", expression); + if (!(string.IsNullOrEmpty(objectGroup))) + { + dict.Add("objectGroup", objectGroup); + } + + if (includeCommandLineAPI.HasValue) + { + dict.Add("includeCommandLineAPI", includeCommandLineAPI.Value); + } + + if (silent.HasValue) + { + dict.Add("silent", silent.Value); + } + + if (contextId.HasValue) + { + dict.Add("contextId", contextId.Value); + } + + if (returnByValue.HasValue) + { + dict.Add("returnByValue", returnByValue.Value); + } + + if (generatePreview.HasValue) + { + dict.Add("generatePreview", generatePreview.Value); + } + + if (userGesture.HasValue) + { + dict.Add("userGesture", userGesture.Value); + } + + if (awaitPromise.HasValue) + { + dict.Add("awaitPromise", awaitPromise.Value); + } + + if (throwOnSideEffect.HasValue) + { + dict.Add("throwOnSideEffect", throwOnSideEffect.Value); + } + + if (timeout.HasValue) + { + dict.Add("timeout", timeout.Value); + } + + if (disableBreaks.HasValue) + { + dict.Add("disableBreaks", disableBreaks.Value); + } + + if (replMode.HasValue) + { + dict.Add("replMode", replMode.Value); + } + + if (allowUnsafeEvalBlockedByCSP.HasValue) + { + dict.Add("allowUnsafeEvalBlockedByCSP", allowUnsafeEvalBlockedByCSP.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.evaluate", dict); + return result.DeserializeJson(); + } + + /// + /// Returns properties of a given object. Object group of the result is inherited from the target + public async System.Threading.Tasks.Task GetPropertiesAsync(string objectId, bool? ownProperties = null, bool? accessorPropertiesOnly = null, bool? generatePreview = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("objectId", objectId); + if (ownProperties.HasValue) + { + dict.Add("ownProperties", ownProperties.Value); + } + + if (accessorPropertiesOnly.HasValue) + { + dict.Add("accessorPropertiesOnly", accessorPropertiesOnly.Value); + } + + if (generatePreview.HasValue) + { + dict.Add("generatePreview", generatePreview.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.getProperties", dict); + return result.DeserializeJson(); + } + + /// + /// Returns all let, const and class variables from global scope. + /// + public async System.Threading.Tasks.Task GlobalLexicalScopeNamesAsync(int? executionContextId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (executionContextId.HasValue) + { + dict.Add("executionContextId", executionContextId.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.globalLexicalScopeNames", dict); + return result.DeserializeJson(); + } + + /// + /// + /// + public async System.Threading.Tasks.Task QueryObjectsAsync(string prototypeObjectId, string objectGroup = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("prototypeObjectId", prototypeObjectId); + if (!(string.IsNullOrEmpty(objectGroup))) + { + dict.Add("objectGroup", objectGroup); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.queryObjects", dict); + return result.DeserializeJson(); + } + + /// + /// Releases remote object with given id. + /// + public async System.Threading.Tasks.Task ReleaseObjectAsync(string objectId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("objectId", objectId); + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.releaseObject", dict); + return result; + } + + /// + /// Releases all remote objects that belong to a given group. + /// + public async System.Threading.Tasks.Task ReleaseObjectGroupAsync(string objectGroup) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("objectGroup", objectGroup); + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.releaseObjectGroup", dict); + return result; + } + + /// + /// Tells inspected instance to run if it was waiting for debugger to attach. + /// + public async System.Threading.Tasks.Task RunIfWaitingForDebuggerAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.runIfWaitingForDebugger", dict); + return result; + } + + /// + /// Runs script with given id in a given context. + /// + public async System.Threading.Tasks.Task RunScriptAsync(string scriptId, int? executionContextId = null, string objectGroup = null, bool? silent = null, bool? includeCommandLineAPI = null, bool? returnByValue = null, bool? generatePreview = null, bool? awaitPromise = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("scriptId", scriptId); + if (executionContextId.HasValue) + { + dict.Add("executionContextId", executionContextId.Value); + } + + if (!(string.IsNullOrEmpty(objectGroup))) + { + dict.Add("objectGroup", objectGroup); + } + + if (silent.HasValue) + { + dict.Add("silent", silent.Value); + } + + if (includeCommandLineAPI.HasValue) + { + dict.Add("includeCommandLineAPI", includeCommandLineAPI.Value); + } + + if (returnByValue.HasValue) + { + dict.Add("returnByValue", returnByValue.Value); + } + + if (generatePreview.HasValue) + { + dict.Add("generatePreview", generatePreview.Value); + } + + if (awaitPromise.HasValue) + { + dict.Add("awaitPromise", awaitPromise.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.runScript", dict); + return result.DeserializeJson(); + } + + /// + /// Enables or disables async call stacks tracking. + /// + public async System.Threading.Tasks.Task SetAsyncCallStackDepthAsync(int maxDepth) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("maxDepth", maxDepth); + var result = await _client.ExecuteDevToolsMethodAsync("Runtime.setAsyncCallStackDepth", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/StackTrace.cs b/CefSharp/DevTools/Runtime/StackTrace.cs new file mode 100644 index 0000000000..7da88aa842 --- /dev/null +++ b/CefSharp/DevTools/Runtime/StackTrace.cs @@ -0,0 +1,50 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// Call frames for assertions or error messages. + /// + public class StackTrace : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// String label of this stack trace. For async traces this may be a name of the function that + [System.Runtime.Serialization.DataMemberAttribute(Name = ("description"), IsRequired = (false))] + public string Description + { + get; + set; + } + + /// + /// JavaScript function name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("callFrames"), IsRequired = (true))] + public System.Collections.Generic.IList CallFrames + { + get; + set; + } + + /// + /// Asynchronous JavaScript stack trace that preceded this stack, if available. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("parent"), IsRequired = (false))] + public StackTrace Parent + { + get; + set; + } + + /// + /// Asynchronous JavaScript stack trace that preceded this stack, if available. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("parentId"), IsRequired = (false))] + public StackTraceId ParentId + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Runtime/StackTraceId.cs b/CefSharp/DevTools/Runtime/StackTraceId.cs new file mode 100644 index 0000000000..3eb58e1e9d --- /dev/null +++ b/CefSharp/DevTools/Runtime/StackTraceId.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Runtime +{ + /// + /// If `debuggerId` is set stack trace comes from another debugger and can be resolved there. This + public class StackTraceId : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("id"), IsRequired = (true))] + public string Id + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("debuggerId"), IsRequired = (false))] + public string DebuggerId + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Schema/Domain.cs b/CefSharp/DevTools/Schema/Domain.cs new file mode 100644 index 0000000000..2af8129163 --- /dev/null +++ b/CefSharp/DevTools/Schema/Domain.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Schema +{ + /// + /// Description of the protocol domain. + /// + public class Domain : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Domain name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("name"), IsRequired = (true))] + public string Name + { + get; + set; + } + + /// + /// Domain version. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("version"), IsRequired = (true))] + public string Version + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Schema/GetDomainsResponse.cs b/CefSharp/DevTools/Schema/GetDomainsResponse.cs new file mode 100644 index 0000000000..2ec2643b8f --- /dev/null +++ b/CefSharp/DevTools/Schema/GetDomainsResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Schema +{ + /// + /// GetDomainsResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetDomainsResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList domains + { + get; + set; + } + + /// + /// List of supported domains. + /// + public System.Collections.Generic.IList Domains + { + get + { + return domains; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Schema/Schema.cs b/CefSharp/DevTools/Schema/Schema.cs new file mode 100644 index 0000000000..2acb05050b --- /dev/null +++ b/CefSharp/DevTools/Schema/Schema.cs @@ -0,0 +1,29 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Schema +{ + using System.Linq; + + /// + /// This domain is deprecated. + /// + public partial class Schema : DevToolsDomainBase + { + public Schema(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Returns supported domains. + /// + public async System.Threading.Tasks.Task GetDomainsAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Schema.getDomains", dict); + return result.DeserializeJson(); + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/CertificateSecurityState.cs b/CefSharp/DevTools/Security/CertificateSecurityState.cs new file mode 100644 index 0000000000..4ff5467433 --- /dev/null +++ b/CefSharp/DevTools/Security/CertificateSecurityState.cs @@ -0,0 +1,191 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// Details about the security state of the page certificate. + /// + public class CertificateSecurityState : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Protocol name (e.g. "TLS 1.2" or "QUIC"). + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("protocol"), IsRequired = (true))] + public string Protocol + { + get; + set; + } + + /// + /// Key Exchange used by the connection, or the empty string if not applicable. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("keyExchange"), IsRequired = (true))] + public string KeyExchange + { + get; + set; + } + + /// + /// (EC)DH group used by the connection, if applicable. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("keyExchangeGroup"), IsRequired = (false))] + public string KeyExchangeGroup + { + get; + set; + } + + /// + /// Cipher name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("cipher"), IsRequired = (true))] + public string Cipher + { + get; + set; + } + + /// + /// TLS MAC. Note that AEAD ciphers do not have separate MACs. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mac"), IsRequired = (false))] + public string Mac + { + get; + set; + } + + /// + /// Page certificate. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificate"), IsRequired = (true))] + public string Certificate + { + get; + set; + } + + /// + /// Certificate subject name. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("subjectName"), IsRequired = (true))] + public string SubjectName + { + get; + set; + } + + /// + /// Name of the issuing CA. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("issuer"), IsRequired = (true))] + public string Issuer + { + get; + set; + } + + /// + /// Certificate valid from date. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("validFrom"), IsRequired = (true))] + public long ValidFrom + { + get; + set; + } + + /// + /// Certificate valid to (expiration) date + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("validTo"), IsRequired = (true))] + public long ValidTo + { + get; + set; + } + + /// + /// The highest priority network error code, if the certificate has an error. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificateNetworkError"), IsRequired = (false))] + public string CertificateNetworkError + { + get; + set; + } + + /// + /// True if the certificate uses a weak signature aglorithm. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificateHasWeakSignature"), IsRequired = (true))] + public bool CertificateHasWeakSignature + { + get; + set; + } + + /// + /// True if the certificate has a SHA1 signature in the chain. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificateHasSha1Signature"), IsRequired = (true))] + public bool CertificateHasSha1Signature + { + get; + set; + } + + /// + /// True if modern SSL + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("modernSSL"), IsRequired = (true))] + public bool ModernSSL + { + get; + set; + } + + /// + /// True if the connection is using an obsolete SSL protocol. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("obsoleteSslProtocol"), IsRequired = (true))] + public bool ObsoleteSslProtocol + { + get; + set; + } + + /// + /// True if the connection is using an obsolete SSL key exchange. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("obsoleteSslKeyExchange"), IsRequired = (true))] + public bool ObsoleteSslKeyExchange + { + get; + set; + } + + /// + /// True if the connection is using an obsolete SSL cipher. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("obsoleteSslCipher"), IsRequired = (true))] + public bool ObsoleteSslCipher + { + get; + set; + } + + /// + /// True if the connection is using an obsolete SSL signature. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("obsoleteSslSignature"), IsRequired = (true))] + public bool ObsoleteSslSignature + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/Enums/CertificateErrorAction.cs b/CefSharp/DevTools/Security/Enums/CertificateErrorAction.cs new file mode 100644 index 0000000000..e803022dbe --- /dev/null +++ b/CefSharp/DevTools/Security/Enums/CertificateErrorAction.cs @@ -0,0 +1,21 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// The action to take when a certificate error occurs. continue will continue processing the + public enum CertificateErrorAction + { + /// + /// continue + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("continue"))] + Continue, + /// + /// cancel + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("cancel"))] + Cancel + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/Enums/MixedContentType.cs b/CefSharp/DevTools/Security/Enums/MixedContentType.cs new file mode 100644 index 0000000000..845688be7c --- /dev/null +++ b/CefSharp/DevTools/Security/Enums/MixedContentType.cs @@ -0,0 +1,26 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// A description of mixed content (HTTP resources on HTTPS pages), as defined by + public enum MixedContentType + { + /// + /// blockable + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("blockable"))] + Blockable, + /// + /// optionally-blockable + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("optionally-blockable"))] + OptionallyBlockable, + /// + /// none + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("none"))] + None + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/Enums/SafetyTipStatus.cs b/CefSharp/DevTools/Security/Enums/SafetyTipStatus.cs new file mode 100644 index 0000000000..168734575a --- /dev/null +++ b/CefSharp/DevTools/Security/Enums/SafetyTipStatus.cs @@ -0,0 +1,22 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// SafetyTipStatus + /// + public enum SafetyTipStatus + { + /// + /// badReputation + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("badReputation"))] + BadReputation, + /// + /// lookalike + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("lookalike"))] + Lookalike + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/Enums/SecurityState.cs b/CefSharp/DevTools/Security/Enums/SecurityState.cs new file mode 100644 index 0000000000..fb907dd8af --- /dev/null +++ b/CefSharp/DevTools/Security/Enums/SecurityState.cs @@ -0,0 +1,42 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// The security level of a page or resource. + /// + public enum SecurityState + { + /// + /// unknown + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("unknown"))] + Unknown, + /// + /// neutral + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("neutral"))] + Neutral, + /// + /// insecure + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("insecure"))] + Insecure, + /// + /// secure + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("secure"))] + Secure, + /// + /// info + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("info"))] + Info, + /// + /// insecure-broken + /// + [System.Runtime.Serialization.EnumMemberAttribute(Value = ("insecure-broken"))] + InsecureBroken + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/InsecureContentStatus.cs b/CefSharp/DevTools/Security/InsecureContentStatus.cs new file mode 100644 index 0000000000..a87196ea1b --- /dev/null +++ b/CefSharp/DevTools/Security/InsecureContentStatus.cs @@ -0,0 +1,81 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// Information about insecure content on the page. + /// + public class InsecureContentStatus : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Always false. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("ranMixedContent"), IsRequired = (true))] + public bool RanMixedContent + { + get; + set; + } + + /// + /// Always false. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("displayedMixedContent"), IsRequired = (true))] + public bool DisplayedMixedContent + { + get; + set; + } + + /// + /// Always false. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("containedMixedForm"), IsRequired = (true))] + public bool ContainedMixedForm + { + get; + set; + } + + /// + /// Always false. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("ranContentWithCertErrors"), IsRequired = (true))] + public bool RanContentWithCertErrors + { + get; + set; + } + + /// + /// Always false. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("displayedContentWithCertErrors"), IsRequired = (true))] + public bool DisplayedContentWithCertErrors + { + get; + set; + } + + /// + /// Always set to unknown. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("ranInsecureContentStyle"), IsRequired = (true))] + public string RanInsecureContentStyle + { + get; + set; + } + + /// + /// Always set to unknown. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("displayedInsecureContentStyle"), IsRequired = (true))] + public string DisplayedInsecureContentStyle + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/SafetyTipInfo.cs b/CefSharp/DevTools/Security/SafetyTipInfo.cs new file mode 100644 index 0000000000..ad14b1b826 --- /dev/null +++ b/CefSharp/DevTools/Security/SafetyTipInfo.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// SafetyTipInfo + /// + public class SafetyTipInfo : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Describes whether the page triggers any safety tips or reputation warnings. Default is unknown. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("safetyTipStatus"), IsRequired = (true))] + public string SafetyTipStatus + { + get; + set; + } + + /// + /// The URL the safety tip suggested ("Did you mean?"). Only filled in for lookalike matches. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("safeUrl"), IsRequired = (false))] + public string SafeUrl + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/Security.cs b/CefSharp/DevTools/Security/Security.cs new file mode 100644 index 0000000000..b7699488cc --- /dev/null +++ b/CefSharp/DevTools/Security/Security.cs @@ -0,0 +1,61 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + using System.Linq; + + /// + /// Security + /// + public partial class Security : DevToolsDomainBase + { + public Security(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Disables tracking security state changes. + /// + public async System.Threading.Tasks.Task DisableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Security.disable", dict); + return result; + } + + /// + /// Enables tracking security state changes. + /// + public async System.Threading.Tasks.Task EnableAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Security.enable", dict); + return result; + } + + /// + /// Handles a certificate error that fired a certificateError event. + /// + public async System.Threading.Tasks.Task HandleCertificateErrorAsync(int eventId, string action) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("eventId", eventId); + dict.Add("action", action); + var result = await _client.ExecuteDevToolsMethodAsync("Security.handleCertificateError", dict); + return result; + } + + /// + /// Enable/disable overriding certificate errors. If enabled, all certificate error events need to + public async System.Threading.Tasks.Task SetOverrideCertificateErrorsAsync(bool @override) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("@override", @override); + var result = await _client.ExecuteDevToolsMethodAsync("Security.setOverrideCertificateErrors", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/SecurityStateExplanation.cs b/CefSharp/DevTools/Security/SecurityStateExplanation.cs new file mode 100644 index 0000000000..623f244b8a --- /dev/null +++ b/CefSharp/DevTools/Security/SecurityStateExplanation.cs @@ -0,0 +1,81 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// An explanation of an factor contributing to the security state. + /// + public class SecurityStateExplanation : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// Security state representing the severity of the factor being explained. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("securityState"), IsRequired = (true))] + public string SecurityState + { + get; + set; + } + + /// + /// Title describing the type of factor. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("title"), IsRequired = (true))] + public string Title + { + get; + set; + } + + /// + /// Short phrase describing the type of factor. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("summary"), IsRequired = (true))] + public string Summary + { + get; + set; + } + + /// + /// Full text explanation of the factor. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("description"), IsRequired = (true))] + public string Description + { + get; + set; + } + + /// + /// The type of mixed content described by the explanation. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("mixedContentType"), IsRequired = (true))] + public string MixedContentType + { + get; + set; + } + + /// + /// Page certificate. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificate"), IsRequired = (true))] + public string Certificate + { + get; + set; + } + + /// + /// Recommendations to fix any issues. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("recommendations"), IsRequired = (false))] + public string Recommendations + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Security/VisibleSecurityState.cs b/CefSharp/DevTools/Security/VisibleSecurityState.cs new file mode 100644 index 0000000000..8cdb22e2a7 --- /dev/null +++ b/CefSharp/DevTools/Security/VisibleSecurityState.cs @@ -0,0 +1,51 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Security +{ + /// + /// Security state information about the page. + /// + public class VisibleSecurityState : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// The security level of the page. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("securityState"), IsRequired = (true))] + public string SecurityState + { + get; + set; + } + + /// + /// Security state details about the page certificate. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("certificateSecurityState"), IsRequired = (false))] + public CertificateSecurityState CertificateSecurityState + { + get; + set; + } + + /// + /// The type of Safety Tip triggered on the page. Note that this field will be set even if the Safety Tip UI was not actually shown. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("safetyTipInfo"), IsRequired = (false))] + public SafetyTipInfo SafetyTipInfo + { + get; + set; + } + + /// + /// Array of security state issues ids. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("securityStateIssueIds"), IsRequired = (true))] + public string SecurityStateIssueIds + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Target/AttachToTargetResponse.cs b/CefSharp/DevTools/Target/AttachToTargetResponse.cs new file mode 100644 index 0000000000..5e0db9d1af --- /dev/null +++ b/CefSharp/DevTools/Target/AttachToTargetResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Target +{ + /// + /// AttachToTargetResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class AttachToTargetResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string sessionId + { + get; + set; + } + + /// + /// Id assigned to the session. + /// + public string SessionId + { + get + { + return sessionId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Target/CloseTargetResponse.cs b/CefSharp/DevTools/Target/CloseTargetResponse.cs new file mode 100644 index 0000000000..746521b49c --- /dev/null +++ b/CefSharp/DevTools/Target/CloseTargetResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Target +{ + /// + /// CloseTargetResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CloseTargetResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal bool success + { + get; + set; + } + + /// + /// success + /// + public bool Success + { + get + { + return success; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Target/CreateTargetResponse.cs b/CefSharp/DevTools/Target/CreateTargetResponse.cs new file mode 100644 index 0000000000..a63862300e --- /dev/null +++ b/CefSharp/DevTools/Target/CreateTargetResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Target +{ + /// + /// CreateTargetResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class CreateTargetResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal string targetId + { + get; + set; + } + + /// + /// The id of the page opened. + /// + public string TargetId + { + get + { + return targetId; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Target/GetTargetsResponse.cs b/CefSharp/DevTools/Target/GetTargetsResponse.cs new file mode 100644 index 0000000000..3d30ba6ae1 --- /dev/null +++ b/CefSharp/DevTools/Target/GetTargetsResponse.cs @@ -0,0 +1,30 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Target +{ + /// + /// GetTargetsResponse + /// + [System.Runtime.Serialization.DataContractAttribute] + public class GetTargetsResponse + { + [System.Runtime.Serialization.DataMemberAttribute] + internal System.Collections.Generic.IList targetInfos + { + get; + set; + } + + /// + /// The list of targets. + /// + public System.Collections.Generic.IList TargetInfos + { + get + { + return targetInfos; + } + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Target/RemoteLocation.cs b/CefSharp/DevTools/Target/RemoteLocation.cs new file mode 100644 index 0000000000..88c5b50c72 --- /dev/null +++ b/CefSharp/DevTools/Target/RemoteLocation.cs @@ -0,0 +1,31 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Target +{ + /// + /// RemoteLocation + /// + public class RemoteLocation : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("host"), IsRequired = (true))] + public string Host + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("port"), IsRequired = (true))] + public int Port + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Target/Target.cs b/CefSharp/DevTools/Target/Target.cs new file mode 100644 index 0000000000..ecb3a240af --- /dev/null +++ b/CefSharp/DevTools/Target/Target.cs @@ -0,0 +1,158 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Target +{ + using System.Linq; + + /// + /// Supports additional targets discovery and allows to attach to them. + /// + public partial class Target : DevToolsDomainBase + { + public Target(CefSharp.DevTools.DevToolsClient client) + { + _client = (client); + } + + private CefSharp.DevTools.DevToolsClient _client; + /// + /// Activates (focuses) the target. + /// + public async System.Threading.Tasks.Task ActivateTargetAsync(string targetId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("targetId", targetId); + var result = await _client.ExecuteDevToolsMethodAsync("Target.activateTarget", dict); + return result; + } + + /// + /// Attaches to the target with given id. + /// + public async System.Threading.Tasks.Task AttachToTargetAsync(string targetId, bool? flatten = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("targetId", targetId); + if (flatten.HasValue) + { + dict.Add("flatten", flatten.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Target.attachToTarget", dict); + return result.DeserializeJson(); + } + + /// + /// Closes the target. If the target is a page that gets closed too. + /// + public async System.Threading.Tasks.Task CloseTargetAsync(string targetId) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("targetId", targetId); + var result = await _client.ExecuteDevToolsMethodAsync("Target.closeTarget", dict); + return result.DeserializeJson(); + } + + /// + /// Creates a new page. + /// + public async System.Threading.Tasks.Task CreateTargetAsync(string url, int? width = null, int? height = null, string browserContextId = null, bool? enableBeginFrameControl = null, bool? newWindow = null, bool? background = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("url", url); + if (width.HasValue) + { + dict.Add("width", width.Value); + } + + if (height.HasValue) + { + dict.Add("height", height.Value); + } + + if (!(string.IsNullOrEmpty(browserContextId))) + { + dict.Add("browserContextId", browserContextId); + } + + if (enableBeginFrameControl.HasValue) + { + dict.Add("enableBeginFrameControl", enableBeginFrameControl.Value); + } + + if (newWindow.HasValue) + { + dict.Add("newWindow", newWindow.Value); + } + + if (background.HasValue) + { + dict.Add("background", background.Value); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Target.createTarget", dict); + return result.DeserializeJson(); + } + + /// + /// Detaches session with given id. + /// + public async System.Threading.Tasks.Task DetachFromTargetAsync(string sessionId = null, string targetId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + if (!(string.IsNullOrEmpty(sessionId))) + { + dict.Add("sessionId", sessionId); + } + + if (!(string.IsNullOrEmpty(targetId))) + { + dict.Add("targetId", targetId); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Target.detachFromTarget", dict); + return result; + } + + /// + /// Retrieves a list of available targets. + /// + public async System.Threading.Tasks.Task GetTargetsAsync() + { + System.Collections.Generic.Dictionary dict = null; + var result = await _client.ExecuteDevToolsMethodAsync("Target.getTargets", dict); + return result.DeserializeJson(); + } + + /// + /// Sends protocol message over session with given id. + public async System.Threading.Tasks.Task SendMessageToTargetAsync(string message, string sessionId = null, string targetId = null) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("message", message); + if (!(string.IsNullOrEmpty(sessionId))) + { + dict.Add("sessionId", sessionId); + } + + if (!(string.IsNullOrEmpty(targetId))) + { + dict.Add("targetId", targetId); + } + + var result = await _client.ExecuteDevToolsMethodAsync("Target.sendMessageToTarget", dict); + return result; + } + + /// + /// Controls whether to discover available targets and notify via + public async System.Threading.Tasks.Task SetDiscoverTargetsAsync(bool discover) + { + var dict = new System.Collections.Generic.Dictionary(); + dict.Add("discover", discover); + var result = await _client.ExecuteDevToolsMethodAsync("Target.setDiscoverTargets", dict); + return result; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevTools/Target/TargetInfo.cs b/CefSharp/DevTools/Target/TargetInfo.cs new file mode 100644 index 0000000000..2ea0842ddd --- /dev/null +++ b/CefSharp/DevTools/Target/TargetInfo.cs @@ -0,0 +1,91 @@ +// Copyright © 2020 The CefSharp Authors. All rights reserved. +// +// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file. +namespace CefSharp.DevTools.Target +{ + /// + /// TargetInfo + /// + public class TargetInfo : CefSharp.DevTools.DevToolsDomainEntityBase + { + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("targetId"), IsRequired = (true))] + public string TargetId + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("type"), IsRequired = (true))] + public string Type + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("title"), IsRequired = (true))] + public string Title + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("url"), IsRequired = (true))] + public string Url + { + get; + set; + } + + /// + /// Whether the target has an attached client. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("attached"), IsRequired = (true))] + public bool Attached + { + get; + set; + } + + /// + /// Opener target Id + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("openerId"), IsRequired = (false))] + public string OpenerId + { + get; + set; + } + + /// + /// Whether the opened window has access to the originating window. + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("canAccessOpener"), IsRequired = (true))] + public bool CanAccessOpener + { + get; + set; + } + + /// + /// + /// + [System.Runtime.Serialization.DataMemberAttribute(Name = ("browserContextId"), IsRequired = (false))] + public string BrowserContextId + { + get; + set; + } + } +} \ No newline at end of file diff --git a/CefSharp/DevToolsExtensions.cs b/CefSharp/DevToolsExtensions.cs index 7402009024..e8ede61dfb 100644 --- a/CefSharp/DevToolsExtensions.cs +++ b/CefSharp/DevToolsExtensions.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Threading.Tasks; +using CefSharp.DevTools; using CefSharp.Internals; using CefSharp.Web; @@ -103,5 +104,41 @@ public static Task ExecuteDevToolsMethodAsync(this IWebBrowser chromiumWebB return browser.ExecuteDevToolsMethodAsync(messageId, method, parameters); } + + /// + /// Gets a new Instance of the DevTools client for the chromiumWebBrowser + /// instance. + /// + /// the chromiumWebBrowser instance + /// DevToolsClient + public static DevToolsClient GetDevToolsClient(this IWebBrowser chromiumWebBrowser) + { + ((IWebBrowserInternal)chromiumWebBrowser).ThrowExceptionIfDisposed(); + ((IWebBrowserInternal)chromiumWebBrowser).ThrowExceptionIfBrowserNotInitialized(); + + var browser = chromiumWebBrowser.GetBrowser(); + + return browser.GetDevToolsClient(); + } + + /// + /// Gets a new Instance of the DevTools client + /// + /// the IBrowser instance + /// DevToolsClient + public static DevToolsClient GetDevToolsClient(this IBrowser browser) + { + var browserHost = browser.GetHost(); + + WebBrowserExtensions.ThrowExceptionIfBrowserHostNull(browserHost); + + var devToolsClient = new DevToolsClient(browser); + + var observerRegistration = browserHost.AddDevToolsMessageObserver(devToolsClient); + + devToolsClient.SetDevToolsObserverRegistration(observerRegistration); + + return devToolsClient; + } } }