Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

Platforms to show: All Mac Windows Linux Cross-Platform

WebPolicyDelegateMBS class

Type Topic Plugin Version macOS Windows Linux Console & Web iOS
class HTMLViewer Mac MBS MacControls Plugin 7.2 Yes No No Yes, macOS only No
Function: A class to decide policies for webkit.
While loading a URL, WebKit asks the WebPolicyDelegate for policies that determine the action of what to do with the URL or the data that the URL represents. Typically, the policy handler methods are called in this order:

decidePolicyForNewWindowAction (at most once)
decidePolicyForNavigationAction (zero or more times)
decidePolicyForMIMEType:request (zero or more times)<BR>

New window policy is always checked. Navigation policy is checked for the initial load and every redirect unless blocked by an earlier policy. Content policy is checked once the content type is known, unless an earlier policy prevented it.

In rare cases, content policy might be checked more than once. This occurs when loading a "multipart/x-mixed-replace" document, also known as "server push". In this case, multiple documents come in one navigation, with each replacing the last. In this case, conent policy will be checked for each one.

All methods in this class will catch exceptions from Cocoa and raise a NSExceptionMBS instead. Using the message, name and reason properties you can see what was the reason for this exception. Please report if you find a method which does not handle exceptions correct.

Please use one delegate class per HTMLViewer (or WebViewMBS) and make sure they live about the same time. Our class keeps a reference on the WebView, so we can remove our delegate when the delegate is destroyed.

Feedback, Comments & Corrections

This class has no sub classes.

Some useful global functions for this class:

Some methods using this class:

Some examples which use this class:

The items on this page are in the following plugins: MBS MacControls Plugin.

WebPolicyDecisionListenerMBS   -   WebPreferencesMBS

MBS Xojo blog