INavigationInterceptor InterfaceAwesomium.NET 1.7.6Awesomium.NET
Represents a service on a IWebView instance, that allows you to cancel frame navigations or add/remove navigation filtering rules to the view.

Namespace: Awesomium.Core
Assembly: Awesomium.Core (in Awesomium.Core.dll) Version: 1.7.6.0
Syntax

public interface INavigationInterceptor : INotifyCollectionChanged, 
	INotifyPropertyChanged, IEnumerable<NavigationFilterRule>, IEnumerable

The INavigationInterceptor type exposes the following members.

Methods

  NameDescription
Public methodCode exampleAddRule(NavigationFilterRule)
Adds a navigation filtering rule for navigations to resources that match the specified Filter.
Public methodCode exampleAddRule(String, NavigationRule)
Adds a navigation filtering rule for navigations to resources that match the specified pattern.
Public methodAddRules
Adds one or more navigation filtering rules.
Public methodClear
Clears all filtering rules applied.
Public methodContains
Gets if a specified filter pattern, matches any of the filtering rules currently applied.
Public methodGetRule
Gets the navigation filtering rule for the specified url string.
Public methodCode exampleRemoveRules(String)
Remove any of the currently applied filtering rules, that match a given filter pattern.
Public methodRemoveRules(String, NavigationRule)
Remove any of the currently applied filtering rules, that match a given filter pattern and navigation rule.
Top
Properties

  NameDescription
Public propertyBlacklist
Gets a list of navigation filter patterns that have been explicitly assigned the Deny rule.
Public propertyImplicitRule
Gets or sets the rule that will be applied to any navigation attempt that does not match a rule explicitly applied through AddRule(String, NavigationRule). The default is Allow.
Public propertyWhitelist
Gets a list of navigation filter patterns that have been explicitly assigned the Allow rule.
Top
Events

  NameDescription
Public eventBeginLoadingFrame
Occurs when a frame is about to begin loading in the view. This event allows you to cancel loading the frame, potentially preventing navigations as well.
Public eventBeginNavigation
Occurs when a view begins navigating to a new URL. This event allows you to cancel the navigation.
Top
Remarks

You can acquire this service by calling GetService(Type) on a IWebView instance.

Events on this service are called after the OnFilterNavigation(NavigationRequest) of a global IResourceInterceptor assigned to ResourceInterceptor, has been called. A global IResourceInterceptor always precedes individual INavigationInterceptor services. Returning true at OnFilterNavigation(NavigationRequest) will prevent the events of this service from being called. Rules applied to this service will also be ignored.

Caution note Caution
The events on this service are called on the I/O Thread. Therefore, you should not make any calls to instances and members that are not thread-safe.
Examples

This example demonstrates adding navigation rules to a INavigationInterceptor.
private void webView_NativeViewInitialized( object sender, WebViewEventArgs e )
{
    INavigationInterceptor navigationInterceptor = webView.GetService( typeof( INavigationInterceptor ) ) as INavigationInterceptor;

     if ( navigationInterceptor == null )
         return;

    CollectionChangeAction res;

    // 1.
    // This call will successfully add a Deny rule for the specified URL pattern.
    res = navigationInterceptor.AddRule( @"http?://*.somedomain.info/*", NavigationRule.Deny );
    Debug.Print( res.ToString() );

    // 2.
    // This call will be ignored, as it attempts to narrow an already wider rule (1).
    res = navigationInterceptor.AddRule( @"http?://*admin.somedomain.info/*", NavigationRule.Deny );
    Debug.Print( res.ToString() );

    // 3.
    // This call will replace the first (1) rule.
    res = navigationInterceptor.AddRule( @"http?://*domain.info/*", NavigationRule.Deny );
    Debug.Print( res.ToString() );

    // 4.
    // This call will successfully add an Allow rule for the specified URL pattern.
    // Although the pattern narrows the one specified in the third (3) call, this call is not 
    // ignored as it specifies an Allow (Whitelist) rule.
    res = navigationInterceptor.AddRule( @"http?://*.somedomain.info/*", NavigationRule.Allow );
    Debug.Print( res.ToString() );

    // 5.
    // This call will replace everything added so far, including the third (3) rule.
    // Patterns must be unique irrespective of the rule applied. An Allow and Deny rule
    // cannot be applied to the same pattern. The last rule added, replaces an existing
    // rule with the same pattern.
    res = navigationInterceptor.AddRule( @"http?://*domain.info/*", NavigationRule.Allow );
    Debug.Print( res.ToString() );
}
Output:
            Add
            Remove
            Refresh
            Add
            Refresh
            
See Also

Reference