// Copyright © 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.
namespace CefSharp
{
///
/// Implement this interface to provide handler implementations. The handler
/// instance will not be released until all objects related to the context have
/// been destroyed. Implement this interface to cancel loading of specific plugins
///
public interface IRequestContextHandler
{
///
/// Called immediately after the request context has been initialized.
/// It's important to note this event is fired on a CEF UI thread, which by default is not the same as your application UI
/// thread.
///
/// the request context
void OnRequestContextInitialized(IRequestContext requestContext);
///
/// Called on the CEF IO thread before a plugin instance is loaded.
/// The default plugin policy can be set at runtime using the `--plugin-policy=[allow|detect|block]` command-line flag.
///
/// is the mime type of the plugin that will be loaded
/// is the content URL that the plugin will load and may be empty
/// will be true if the plugin is being loaded in the main (top-level) frame
/// is the URL for the top-level frame that contains the plugin
/// includes additional information about the plugin that will be loaded
/// Modify and return true to change the policy.
/// Return false to use the recommended policy. Modify and return true to change the policy.
bool OnBeforePluginLoad(string mimeType, string url, bool isMainFrame, string topOriginUrl, WebPluginInfo pluginInfo, ref PluginPolicy pluginPolicy);
///
/// Called on the CEF IO thread before a resource request is initiated.
/// This method will not be called if the client associated with returns a non-NULL value
/// from for the same request (identified by ).
///
/// represent the source browser of the request, and may be null for requests originating from service workers.
/// represent the source frame of the request, and may be null for requests originating from service workers.
/// represents the request contents and cannot be modified in this callback
/// will be true if the resource request is a navigation
/// will be true if the resource request is a download
/// is the origin (scheme + domain) of the page that initiated the request
/// Set to true to disable default handling of the request, in which case it will need to be handled via or it will be canceled
/// To allow the resource load to proceed with default handling return null. To specify a handler for the resource return a object.
IResourceRequestHandler GetResourceRequestHandler(IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling);
}
}