]> git.saurik.com Git - cydia.git/blob - CyteKit/CyteWebViewController.h
f4ba3e3fe360f75026b96311d49aff87a90657a4
[cydia.git] / CyteKit / CyteWebViewController.h
1 /* Cydia - iPhone UIKit Front-End for Debian APT
2 * Copyright (C) 2008-2011 Jay Freeman (saurik)
3 */
4
5 /* Modified BSD License {{{ */
6 /*
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
10 *
11 * 1. Redistributions of source code must retain the
12 * above copyright notice, this list of conditions
13 * and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the
15 * above copyright notice, this list of conditions
16 * and the following disclaimer in the documentation
17 * and/or other materials provided with the
18 * distribution.
19 * 3. The name of the author may not be used to endorse
20 * or promote products derived from this software
21 * without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS''
24 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING,
25 * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
26 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE
28 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
29 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
30 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
33 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
36 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37 */
38 /* }}} */
39
40 #ifndef CyteKit_CydiaBrowserController_H
41 #define CyteKit_CydiaBrowserController_H
42
43 #include "CyteKit/CyteViewController.h"
44
45 #include <UIKit/UIKit.h>
46
47 #include <WebKit/DOMNodeList.h>
48 #include <WebKit/WebFrame.h>
49 #include <WebKit/WebScriptObject.h>
50 #include <WebKit/WebView.h>
51
52 #include <JavaScriptCore/JavaScriptCore.h>
53
54 #include "substrate.h"
55
56 @class NSMutableArray;
57 @class NSString;
58 @class NSURL;
59 @class NSURLRequest;
60
61 @class UIScroller;
62 @class UIDocumentWebView;
63
64 @class WebView;
65
66 @class Database;
67 @class IndirectDelegate;
68
69 @protocol CYWebViewDelegate <UIWebViewDelegate>
70 - (void) webView:(WebView *)view addMessageToConsole:(NSDictionary *)message;
71 - (void) webView:(WebView *)view decidePolicyForNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame decisionListener:(id<WebPolicyDecisionListener>)listener;
72 - (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)name decisionListener:(id<WebPolicyDecisionListener>)listener;
73 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
74 - (void) webView:(WebView *)view didFailLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
75 - (void) webView:(WebView *)view didFailProvisionalLoadWithError:(NSError *)error forFrame:(WebFrame *)frame;
76 - (void) webView:(WebView *)view didFinishLoadForFrame:(WebFrame *)frame;
77 - (void) webView:(WebView *)view didReceiveTitle:(NSString *)title forFrame:(WebFrame *)frame;
78 - (void) webView:(WebView *)view didStartProvisionalLoadForFrame:(WebFrame *)frame;
79 - (NSURLRequest *) webView:(WebView *)view resource:(id)resource willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source;
80 - (void) webViewClose:(WebView *)view;
81 - (bool) webView:(WebView *)view shouldRunJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
82 - (bool) webView:(WebView *)view shouldRunJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame;
83 - (bool) webView:(WebView *)view shouldRunJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)text initiatedByFrame:(WebFrame *)frame;
84 - (void) webViewUpdateViewSettings:(UIWebView *)view;
85 @end
86
87 @interface CYWebView : UIWebView
88 - (id<CYWebViewDelegate>) delegate;
89 @end
90
91 @interface WebScriptObject (UICaboodle)
92 - (NSUInteger) count;
93 - (id) objectAtIndex:(unsigned)index;
94 @end
95
96 @protocol BrowserControllerDelegate
97 - (void) retainNetworkActivityIndicator;
98 - (void) releaseNetworkActivityIndicator;
99 - (CYViewController *) pageForURL:(NSURL *)url forExternal:(BOOL)external;
100 - (void) unloadData;
101 @end
102
103 @interface BrowserController : CYViewController <
104 CYWebViewDelegate,
105 UIWebViewDelegate
106 > {
107 _transient CYWebView *webview_;
108 _transient UIScrollView *scroller_;
109
110 UIActivityIndicatorView *indicator_;
111 IndirectDelegate *indirect_;
112 NSURLAuthenticationChallenge *challenge_;
113
114 bool error_;
115 _H<NSURLRequest> request_;
116
117 _transient NSNumber *sensitive_;
118
119 NSString *title_;
120 NSMutableSet *loading_;
121
122 // XXX: NSString * or UIImage *
123 _H<NSObject> custom_;
124 _H<NSString> style_;
125
126 _H<WebScriptObject> function_;
127
128 float width_;
129 Class class_;
130
131 UIBarButtonItem *reloaditem_;
132 UIBarButtonItem *loadingitem_;
133
134 bool visible_;
135 bool hidesNavigationBar_;
136 bool allowsNavigationAction_;
137 }
138
139 + (void) _initialize;
140
141 - (void) setURL:(NSURL *)url;
142
143 - (void) loadURL:(NSURL *)url cachePolicy:(NSURLRequestCachePolicy)policy;
144 - (void) loadURL:(NSURL *)url;
145
146 - (void) loadRequest:(NSURLRequest *)request;
147 - (bool) isLoading;
148
149 - (void) reloadURLWithCache:(BOOL)cache;
150 - (void) reloadURL;
151
152 - (id) init;
153 - (id) initWithURL:(NSURL *)url;
154 - (id) initWithWidth:(float)width;
155 - (id) initWithWidth:(float)width ofClass:(Class)_class;
156
157 - (void) callFunction:(WebScriptObject *)function;
158
159 - (void) webView:(WebView *)view didClearWindowObject:(WebScriptObject *)window forFrame:(WebFrame *)frame;
160 - (NSURLRequest *) webView:(WebView *)view resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)response fromDataSource:(WebDataSource *)source;
161
162 + (float) defaultWidth;
163
164 - (void) setButtonImage:(NSString *)button withStyle:(NSString *)style toFunction:(id)function;
165 - (void) setButtonTitle:(NSString *)button withStyle:(NSString *)style toFunction:(id)function;
166 - (void) setHidesNavigationBar:(bool)value;
167
168 - (void) alertView:(UIAlertView *)alert clickedButtonAtIndex:(NSInteger)button;
169 - (void) customButtonClicked;
170 - (void) applyRightButton;
171
172 - (void) _didStartLoading;
173 - (void) _didFinishLoading;
174
175 - (void) close;
176
177 - (void) dispatchEvent:(NSString *)event;
178
179 - (void) setViewportWidthOnMainThread:(float)value;
180
181 @end
182
183 #endif//CyteKit_CydiaBrowserController_H