diff --git a/CefSharp/CefSharp.csproj b/CefSharp/CefSharp.csproj
index fa74a1ea9..ac8afc60c 100644
--- a/CefSharp/CefSharp.csproj
+++ b/CefSharp/CefSharp.csproj
@@ -199,7 +199,7 @@
-
+
diff --git a/CefSharp/DefaultResourceHandlerFactory.cs b/CefSharp/DefaultResourceHandlerFactory.cs
index 4bec6d51a..4e65dfa37 100644
--- a/CefSharp/DefaultResourceHandlerFactory.cs
+++ b/CefSharp/DefaultResourceHandlerFactory.cs
@@ -18,7 +18,7 @@ namespace CefSharp
///
/// Resource handler thread safe dictionary
///
- public ConcurrentDictionary Handlers { get; private set; }
+ public ConcurrentDictionary Handlers { get; private set; }
///
/// Create a new instance of DefaultResourceHandlerFactory
@@ -26,7 +26,7 @@ namespace CefSharp
/// string equality comparer
public DefaultResourceHandlerFactory(IEqualityComparer comparer = null)
{
- Handlers = new ConcurrentDictionary(comparer ?? StringComparer.OrdinalIgnoreCase);
+ Handlers = new ConcurrentDictionary(comparer ?? StringComparer.OrdinalIgnoreCase);
}
///
@@ -34,14 +34,14 @@ namespace CefSharp
///
/// url
/// handler
- /// Whether or not the handler should be used once (false) or until manually unregistered (true)
+ /// Whether or not the handler should be used once (true) or until manually unregistered (false)
/// returns true if the Url was successfully parsed into a Uri otherwise false
- public virtual bool RegisterHandler(string url, IResourceHandler handler, bool persist)
+ public virtual bool RegisterHandler(string url, IResourceHandler handler, bool oneTimeUse = false)
{
Uri uri;
if (Uri.TryCreate(url, UriKind.Absolute, out uri))
{
- ResourceFactoryItem entry = new ResourceFactoryItem(handler, persist);
+ var entry = new DefaultResourceHandlerFactoryItem(handler, oneTimeUse);
Handlers.AddOrUpdate(uri.AbsoluteUri, entry, (k, v) => entry);
return true;
@@ -49,17 +49,6 @@ namespace CefSharp
return false;
}
- ///
- /// Register a persistant handler for the specified Url
- ///
- /// url
- /// handler
- /// returns true if the Url was successfully parsed into a Uri otherwise false
- public virtual bool RegisterHandler(string url, IResourceHandler handler)
- {
- return RegisterHandler(url, handler, true);
- }
-
///
/// Unregister a handler for the specified Url
///
@@ -67,7 +56,7 @@ namespace CefSharp
/// returns true if successfully removed
public virtual bool UnregisterHandler(string url)
{
- ResourceFactoryItem entry;
+ DefaultResourceHandlerFactoryItem entry;
return Handlers.TryRemove(url, out entry);
}
@@ -91,11 +80,11 @@ namespace CefSharp
{
try
{
- ResourceFactoryItem entry;
+ DefaultResourceHandlerFactoryItem entry;
if (Handlers.TryGetValue(request.Url, out entry))
{
- if (!entry.Persist)
+ if (entry.OneTimeUse)
{
Handlers.TryRemove(request.Url, out entry);
}
diff --git a/CefSharp/ResourceFactoryItem.cs b/CefSharp/DefaultResourceHandlerFactoryItem.cs
similarity index 52%
rename from CefSharp/ResourceFactoryItem.cs
rename to CefSharp/DefaultResourceHandlerFactoryItem.cs
index b8f3f2b9d..9ed8551cc 100644
--- a/CefSharp/ResourceFactoryItem.cs
+++ b/CefSharp/DefaultResourceHandlerFactoryItem.cs
@@ -4,7 +4,7 @@
namespace CefSharp
{
- public class ResourceFactoryItem
+ public class DefaultResourceHandlerFactoryItem
{
///
/// The handler for a specific Url
@@ -12,16 +12,16 @@ namespace CefSharp
public IResourceHandler Handler { get; private set; }
///
- /// Whether or not the handler should be used once (false) or until manually unregistered (true)
+ /// Whether or not the handler should be used once (true) or until manually unregistered (false)
///
- public bool Persist { get; private set; }
+ public bool OneTimeUse { get; private set; }
/// The handler for a specific Url
- /// Whether or not the handler should be used once (false) or until manually unregistered (true)
- public ResourceFactoryItem(IResourceHandler handler, bool persist)
+ /// Whether or not the handler should be used once (true) or until manually unregistered (false)
+ public DefaultResourceHandlerFactoryItem(IResourceHandler handler, bool oneTimeUse)
{
Handler = handler;
- Persist = persist;
+ OneTimeUse = oneTimeUse;
}
}
}
diff --git a/CefSharp/WebBrowserExtensions.cs b/CefSharp/WebBrowserExtensions.cs
index b87f26823..fb13d044a 100644
--- a/CefSharp/WebBrowserExtensions.cs
+++ b/CefSharp/WebBrowserExtensions.cs
@@ -293,8 +293,9 @@ namespace CefSharp
/// The HTML content.
/// The URL that will be treated as the address of the content.
/// Character Encoding
+ /// Whether or not the handler should be used once (true) or until manually unregistered (false)
/// returns false if the Url was not successfully parsed into a Uri
- public static bool LoadHtml(this IWebBrowser browser, string html, string url, Encoding encoding)
+ public static bool LoadHtml(this IWebBrowser browser, string html, string url, Encoding encoding, bool oneTimeUse = false)
{
var handler = browser.ResourceHandlerFactory;
if (handler == null)
@@ -309,7 +310,7 @@ namespace CefSharp
throw new Exception("LoadHtml can only be used with the default IResourceHandlerFactory(DefaultResourceHandlerFactory) implementation");
}
- if (resourceHandler.RegisterHandler(url, ResourceHandler.FromString(html, encoding, true), false))
+ if (resourceHandler.RegisterHandler(url, ResourceHandler.FromString(html, encoding, true), oneTimeUse))
{
browser.Load(url);
return true;