// 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 interface IRequestHandler
{
///
/// Called before browser navigation.
/// If the navigation is allowed and
/// will be called. If the navigation is canceled will be called with an ErrorCode
/// value of .
///
/// the browser object
/// the request object - cannot be modified in this callback
/// has the request been redirected
/// The frame the request is coming from
/// Return true to cancel the navigation or false to allow the navigation to proceed.
bool OnBeforeBrowse(IWebBrowser browser, IRequest request, bool isRedirect, IFrame frame);
///
/// Called to handle requests for URLs with an invalid SSL certificate.
/// Return true and call either
/// in this method or at a later time to continue or cancel the request.
/// If is set all invalid certificates
/// will be accepted without calling this method.
///
/// the browser object
/// the error code for this invalid certificate
/// the url of the request for the invalid certificate
/// Callback interface used for asynchronous continuation of url requests.
/// If empty the error cannot be recovered from and the request will be canceled automatically.
/// Return false to cancel the request immediately. Return true and use to
/// execute in an async fashion.
bool OnCertificateError(IWebBrowser browser, CefErrorCode errorCode, string requestUrl, IRequestCallback callback);
///
/// Called when a plugin has crashed
///
/// the browser object
/// path of the plugin that crashed
void OnPluginCrashed(IWebBrowser browser, string pluginPath);
///
/// Called before a resource request is loaded. For async processing return
/// and execute or
///
/// the browser object
/// the request object - can be modified in this callback.
/// The frame object
/// Callback interface used for asynchronous continuation of url requests.
/// To cancel loading of the resource return
/// or to allow the resource to load normally. For async
/// return
CefReturnValue OnBeforeResourceLoad(IWebBrowser browser, IRequest request, IFrame frame, IRequestCallback callback);
///
/// Called when the browser needs credentials from the user.
///
/// the browser object
/// The frame object that needs credentials (This will contain the URL that is being requested.)
/// indicates whether the host is a proxy server
/// hostname
/// port number
/// realm
/// scheme
/// requested username
/// requested password
/// Return true to continue the request and call CefAuthCallback::Continue() when the authentication information is available. Return false to cancel the request.
bool GetAuthCredentials(IWebBrowser browser, IFrame frame, bool isProxy, string host, int port, string realm, string scheme, ref string username, ref string password);
///
/// Called on the browser process IO thread before a plugin is loaded.
///
/// the browser object
/// URL
/// policy URL
/// plugin information
/// Return true to block loading of the plugin.
bool OnBeforePluginLoad(IWebBrowser browser, string url, string policyUrl, WebPluginInfo info);
///
/// Called when the render process terminates unexpectedly.
///
/// the browser object
/// indicates how the process terminated.
void OnRenderProcessTerminated(IWebBrowser browser, CefTerminationStatus status);
///
/// Called when JavaScript requests a specific storage quota size via the webkitStorageInfo.requestQuota function.
/// For async processing return true and execute at a later time to
/// grant or deny the request or to cancel.
///
/// the browser object
/// the origin of the page making the request
/// is the requested quota size in bytes
/// Callback interface used for asynchronous continuation of url requests.
/// Return false to cancel the request immediately. Return true to continue the request
/// and call either in this method or at a later time to
/// grant or deny the request.
bool OnQuotaRequest(IWebBrowser browser, string originUrl, Int64 newSize, IRequestCallback callback);
///
/// Called on the IO thread when a resource load is redirected. The |old_url| parameter will contain . .
///
/// the browser object
/// The frame that is being redirected.
/// the new URL and can be changed if desired
void OnResourceRedirect(IWebBrowser browser, IFrame frame, ref string newUrl);
///
/// Called on the UI thread to handle requests for URLs with an unknown protocol component.
/// SECURITY WARNING: YOU SHOULD USE THIS METHOD TO ENFORCE RESTRICTIONS BASED ON SCHEME, HOST OR OTHER URL ANALYSIS BEFORE ALLOWING OS EXECUTION.
///
/// the browser object
/// the request url
/// return to true to attempt execution via the registered OS protocol handler, if any. Otherwise return false.
bool OnProtocolExecution(IWebBrowser browser, string url);
///
/// Called when the page icon changes.
///
/// the browser object
/// list of urls where the favicons can be downloaded
void OnFaviconUrlChange(IWebBrowser browser, IList urls);
}
}