Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion ElectronNET.API/Entities/LoadURLOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace ElectronNET.API.Entities
using System.Collections.Generic;

namespace ElectronNET.API.Entities
{
/// <summary>
///
Expand All @@ -21,5 +23,10 @@ public class LoadURLOptions
/// files.
/// </summary>
public string BaseURLForDataURL { get; set; }

/// <summary>
/// Extra headers for the request.
/// </summary>
public string ExtraHeaders { get; set; }
}
}
16 changes: 16 additions & 0 deletions ElectronNET.API/WebContents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ public Task<bool> PrintToPDFAsync(string path, PrintToPDFOptions options = null)
return taskCompletionSource.Task;
}

public Task<string> GetUrl()
{
var taskCompletionSource = new TaskCompletionSource<string>();

var eventString = "webContents-getUrl" + Id;
BridgeConnector.Socket.On(eventString, (url) =>
{
BridgeConnector.Socket.Off(eventString);
taskCompletionSource.SetResult((string)url);
});

BridgeConnector.Socket.Emit("webContents-getUrl", Id);

return taskCompletionSource.Task;
}

private JsonSerializer _jsonSerializer = new JsonSerializer()
{
ContractResolver = new CamelCasePropertyNamesContractResolver(),
Expand Down
4 changes: 4 additions & 0 deletions ElectronNET.Host/api/webContents.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ElectronNET.Host/api/webContents.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions ElectronNET.Host/api/webContents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ module.exports = (socket: SocketIO.Server) => {
});
});

socket.on('webContents-getUrl', function (id) {
var browserWindow = getWindowById(id);
socket.emit('webContents-getUrl' + id, browserWindow.webContents.getURL());
});

function getWindowById(id: number): Electron.BrowserWindow {
return BrowserWindow.fromId(id);
}
Expand Down