1 /* Cydia - iPhone UIKit Front-End for Debian APT
2 * Copyright (C) 2008-2011 Jay Freeman (saurik)
5 /* Modified BSD License {{{ */
7 * Redistribution and use in source and binary
8 * forms, with or without modification, are permitted
9 * provided that the following conditions are met:
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
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.
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.
40 #ifndef CyteKit_CydiaBrowserController_H
41 #define CyteKit_CydiaBrowserController_H
43 #include "CyteKit/CyteViewController.h"
45 #include <UIKit/UIKit.h>
47 #include <WebKit/DOMNodeList.h>
48 #include <WebKit/WebFrame.h>
49 #include <WebKit/WebScriptObject.h>
50 #include <WebKit/WebView.h>
52 #include <JavaScriptCore/JavaScriptCore.h>
54 #include "substrate.h"
56 @
class NSMutableArray
;
62 @
class UIDocumentWebView
;
67 @
class IndirectDelegate
;
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
;
87 @interface CYWebView
: UIWebView
88 - (id
<CYWebViewDelegate
>) delegate
;
91 @interface
WebScriptObject (UICaboodle
)
93 - (id
) objectAtIndex
:(unsigned)index
;
96 @protocol BrowserControllerDelegate
97 - (void) retainNetworkActivityIndicator
;
98 - (void) releaseNetworkActivityIndicator
;
99 - (CYViewController
*) pageForURL
:(NSURL
*)url forExternal
:(BOOL
)external
;
103 @interface BrowserController
: CYViewController
<
107 _transient CYWebView
*webview_
;
108 _transient UIScrollView
*scroller_
;
110 UIActivityIndicatorView
*indicator_
;
111 IndirectDelegate
*indirect_
;
112 NSURLAuthenticationChallenge
*challenge_
;
115 _H
<NSURLRequest
> request_
;
117 _transient NSNumber
*sensitive_
;
120 NSMutableSet
*loading_
;
122 // XXX: NSString * or UIImage *
123 _H
<NSObject
> custom_
;
126 _H
<WebScriptObject
> function_
;
131 UIBarButtonItem
*reloaditem_
;
132 UIBarButtonItem
*loadingitem_
;
135 bool hidesNavigationBar_
;
136 bool allowsNavigationAction_
;
139 + (void) _initialize
;
141 - (void) setURL
:(NSURL
*)url
;
143 - (void) loadURL
:(NSURL
*)url cachePolicy
:(NSURLRequestCachePolicy
)policy
;
144 - (void) loadURL
:(NSURL
*)url
;
146 - (void) loadRequest
:(NSURLRequest
*)request
;
149 - (void) reloadURLWithCache
:(BOOL
)cache
;
153 - (id
) initWithURL
:(NSURL
*)url
;
154 - (id
) initWithWidth
:(float)width
;
155 - (id
) initWithWidth
:(float)width ofClass
:(Class
)_class
;
157 - (void) callFunction
:(WebScriptObject
*)function
;
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
;
162 + (float) defaultWidth
;
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
;
168 - (void) alertView
:(UIAlertView
*)alert clickedButtonAtIndex
:(NSInteger
)button
;
169 - (void) customButtonClicked
;
170 - (void) applyRightButton
;
172 - (void) _didStartLoading
;
173 - (void) _didFinishLoading
;
177 - (void) dispatchEvent
:(NSString
*)event
;
179 - (void) setViewportWidthOnMainThread
:(float)value
;
183 #endif//CyteKit_CydiaBrowserController_H