Skip to content
Open
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: 6 additions & 3 deletions NativeMessaging/Host.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace NativeMessaging
public abstract class Host
{
private readonly bool SendConfirmationReceipt;
private readonly bool CheckIsRegistered;
private readonly string ManifestPath;

/// <summary>
Expand All @@ -25,11 +26,13 @@ public abstract class Host
/// Creates the Host object
/// </summary>
/// <param name="sendConfirmationReceipt"><see langword="true" /> for the host to automatically send message confirmation receipt.</param>
public Host(bool sendConfirmationReceipt = true)
/// /// <param name="checkIsRegistered"><see langword="true" /> for the host to check if it is registered before listening.</param>
public Host(bool sendConfirmationReceipt = true, bool checkIsRegistered = true)
{
SupportedBrowsers = new List<ChromiumBrowser>(2);

SendConfirmationReceipt = sendConfirmationReceipt;
CheckIsRegistered = checkIsRegistered;

ManifestPath
= Path.Combine(
Expand All @@ -42,7 +45,7 @@ public Host(bool sendConfirmationReceipt = true)
/// </summary>
public void Listen()
{
if (!IsRegistered())
if (CheckIsRegistered && !IsRegistered())
{
throw new NotRegisteredWithBrowserException(Hostname);
}
Expand Down Expand Up @@ -155,7 +158,7 @@ public void RemoveManifest()

#region Browser Registration
/// <summary>
/// Checks if the host is registered with all required browsers.
/// Checks if the host is registered with any of the supported browsers.
/// </summary>
/// <returns><see langword="true"/> if the required information is present in the registry.</returns>
public bool IsRegistered()
Expand Down
3 changes: 2 additions & 1 deletion NativeMessagingTest/MyHost.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ namespace NativeMessagingTest
public class MyHost : Host
{
private const bool SendConfirmationReceipt = true;
private const bool CheckIsRegistered = true;

public override string Hostname
{
get { return "com.google.chrome.example.echo"; }
}

public MyHost() : base(SendConfirmationReceipt)
public MyHost() : base(SendConfirmationReceipt, CheckIsRegistered)
{

}
Expand Down