Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 98 lines (87 sloc) 4.013 kb
efdd79f1 » peterdn
2009-07-27
1 /*
2 * Copyright (c) 2009, Peter Nelson (charn.opcode@gmail.com)
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24 * POSSIBILITY OF SUCH DAMAGE.
25 */
26
c342ecbf » peterdn
2009-09-04 General tidy up.
27 // Handles events that can be used to modify the policy decisions that the WebView
28 // makes when handling various data types. More information can be found at:
efdd79f1 » peterdn
2009-07-27
29 // http://developer.apple.com/documentation/Cocoa/Reference/WebKit/Protocols/WebPolicyDelegate_Protocol
30
31 using System;
32 using System.Collections.Generic;
33 using System.Text;
34 using WebKit.Interop;
35 using System.Windows.Forms;
36 using System.Diagnostics;
37
38 namespace WebKit
39 {
40 internal class WebPolicyDelegate : IWebPolicyDelegate
41 {
02f716d3 » peterdn
2009-09-08 0.3 codebase
42 public bool AllowDownloads;
43 public bool AllowNewWindows;
44 public bool AllowNavigation;
c342ecbf » peterdn
2009-09-04 General tidy up.
45
02f716d3 » peterdn
2009-09-08 0.3 codebase
46 // so that we can load and display the first page
47 public bool AllowInitialNavigation;
48
49 public WebPolicyDelegate(bool AllowNavigation, bool AllowDownloads, bool AllowNewWindows)
c342ecbf » peterdn
2009-09-04 General tidy up.
50 {
02f716d3 » peterdn
2009-09-08 0.3 codebase
51 this.AllowDownloads = AllowDownloads;
52 this.AllowNavigation = AllowNavigation;
53 this.AllowNewWindows = AllowNewWindows;
54 AllowInitialNavigation = true;
c342ecbf » peterdn
2009-09-04 General tidy up.
55 }
56
efdd79f1 » peterdn
2009-07-27
57 #region IWebPolicyDelegate Members
58
70375d77 » peterdn
2010-07-19 Added the start of printing functionality - WebKitBrowser.ShowPrintDi…
59 public void decidePolicyForMIMEType(WebView WebView, string type, IWebURLRequest request, webFrame frame, IWebPolicyDecisionListener listener)
efdd79f1 » peterdn
2009-07-27
60 {
61 // todo: add support for showing custom MIME type documents
62 // and for changing which MIME types are handled here
63 if (WebView.canShowMIMEType(type) == 0)
c342ecbf » peterdn
2009-09-04 General tidy up.
64 {
02f716d3 » peterdn
2009-09-08 0.3 codebase
65 if (AllowDownloads)
c342ecbf » peterdn
2009-09-04 General tidy up.
66 listener.download();
67 else
68 listener.ignore();
69 }
efdd79f1 » peterdn
2009-07-27
70 else
c342ecbf » peterdn
2009-09-04 General tidy up.
71 {
efdd79f1 » peterdn
2009-07-27
72 listener.use();
c342ecbf » peterdn
2009-09-04 General tidy up.
73 }
efdd79f1 » peterdn
2009-07-27
74 }
75
70375d77 » peterdn
2010-07-19 Added the start of printing functionality - WebKitBrowser.ShowPrintDi…
76 public void decidePolicyForNavigationAction(WebView WebView, CFDictionaryPropertyBag actionInformation, IWebURLRequest request, webFrame frame, IWebPolicyDecisionListener listener)
efdd79f1 » peterdn
2009-07-27
77 {
02f716d3 » peterdn
2009-09-08 0.3 codebase
78 if (AllowNavigation || AllowInitialNavigation)
c342ecbf » peterdn
2009-09-04 General tidy up.
79 listener.use();
80 else
81 listener.ignore();
efdd79f1 » peterdn
2009-07-27
82 }
83
84 public void decidePolicyForNewWindowAction(WebView WebView, CFDictionaryPropertyBag actionInformation, IWebURLRequest request, string frameName, IWebPolicyDecisionListener listener)
85 {
02f716d3 » peterdn
2009-09-08 0.3 codebase
86 if (AllowNewWindows)
c342ecbf » peterdn
2009-09-04 General tidy up.
87 listener.use();
88 else
89 listener.ignore();
efdd79f1 » peterdn
2009-07-27
90 }
91
70375d77 » peterdn
2010-07-19 Added the start of printing functionality - WebKitBrowser.ShowPrintDi…
92 public void unableToImplementPolicyWithError(WebView WebView, WebError error, webFrame frame)
efdd79f1 » peterdn
2009-07-27
93 {
94 }
95
96 #endregion
97 }
98 }
Something went wrong with that request. Please try again.