Files
cefsharp/CefSharp/DefaultResourceHandlerFactory.cs
T
rassilon 7128e40fd1 It's time for copyright updates again. Yay!
Throw in a couple of tab containing files for good measure.
Evil tabs, evil I say.
2015-04-25 02:45:21 -04:00

42 lines
1.2 KiB
C#

// Copyright © 2010-2015 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;
namespace CefSharp
{
public class DefaultResourceHandlerFactory : IResourceHandlerFactory
{
public Dictionary<string, ResourceHandler> Handlers { get; private set; }
public DefaultResourceHandlerFactory(IEqualityComparer<string> comparer = null)
{
Handlers = new Dictionary<string, ResourceHandler>(comparer ?? StringComparer.OrdinalIgnoreCase);
}
public virtual void RegisterHandler(string url, ResourceHandler handler)
{
Handlers[url] = handler;
}
public virtual void UnregisterHandler(string url)
{
Handlers.Remove(url);
}
public bool HasHandlers
{
get { return Handlers.Count > 0; }
}
public virtual ResourceHandler GetResourceHandler(IWebBrowser browser, IRequest request)
{
ResourceHandler handler;
return Handlers.TryGetValue(request.Url, out handler) ? handler : null;
}
}
}