mirror of
https://github.com/cefsharp/CefSharp.git
synced 2026-12-04 19:25:01 +00:00
7128e40fd1
Throw in a couple of tab containing files for good measure. Evil tabs, evil I say.
42 lines
1.2 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|