2017-03-05 23:44:37 +01:00
|
|
|
// Copyright © 2010-2017 The CefSharp Authors. All rights reserved.
|
2016-09-25 20:35:04 +10:00
|
|
|
//
|
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
namespace CefSharp.Wpf.Example.Handlers
|
|
|
|
|
{
|
|
|
|
|
public class RequestContextHandler : IRequestContextHandler
|
|
|
|
|
{
|
2017-12-20 09:52:01 +10:00
|
|
|
private ICookieManager customCookieManager;
|
|
|
|
|
|
2017-02-01 13:53:43 +10:00
|
|
|
bool IRequestContextHandler.OnBeforePluginLoad(string mimeType, string url, bool isMainFrame, string topOriginUrl, WebPluginInfo pluginInfo, ref PluginPolicy pluginPolicy)
|
2016-09-25 20:35:04 +10:00
|
|
|
{
|
|
|
|
|
//pluginPolicy = PluginPolicy.Disable;
|
|
|
|
|
//return true;
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ICookieManager IRequestContextHandler.GetCookieManager()
|
|
|
|
|
{
|
2017-12-20 09:52:01 +10:00
|
|
|
if(customCookieManager == null)
|
|
|
|
|
{
|
|
|
|
|
//In memory cookie manager
|
|
|
|
|
//customCookieManager = new CookieManager(null, persistSessionCookies: false, callback: null);
|
|
|
|
|
|
|
|
|
|
//Store cookies in cookies directory (user must have write permission to this folder)
|
|
|
|
|
customCookieManager = new CookieManager("cookies", persistSessionCookies: false, callback: null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return customCookieManager;
|
|
|
|
|
|
|
|
|
|
//NOTE: DO NOT RETURN A NEW COOKIE MANAGER EVERY TIME
|
|
|
|
|
//This method will be called many times, you should return the same cookie manager within the scope
|
|
|
|
|
//of the RequestContext (unless you REALLY know what your doing)
|
|
|
|
|
//return new CookieManager("cookies", persistSessionCookies: false, callback: null);
|
|
|
|
|
|
|
|
|
|
//Default to using the Global cookieManager (default)
|
|
|
|
|
//return null;
|
2016-09-25 20:35:04 +10:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|