1/* 2 * Copyright (C) 2011 Apple Inc. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. 9 * 2. Redistributions in binary form must reproduce the above copyright 10 * notice, this list of conditions and the following disclaimer in the 11 * documentation and/or other materials provided with the distribution. 12 * 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 23 * THE POSSIBILITY OF SUCH DAMAGE. 24 */ 25 26#import <Foundation/Foundation.h> 27#import <WebKit/WKBrowsingContextGroup.h> 28#import <WebKit/WKFoundation.h> 29#import <WebKit/WKProcessGroup.h> 30#import <WebKit/WKRenderingProgressEvents.h> 31 32#if WK_API_ENABLED 33 34@class WKBackForwardList; 35@class WKBackForwardListItem; 36@protocol WKBrowsingContextHistoryDelegate; 37@protocol WKBrowsingContextLoadDelegate; 38@protocol WKBrowsingContextPolicyDelegate; 39 40WK_CLASS_AVAILABLE(10_10, 8_0) 41@interface WKBrowsingContextController : NSObject 42 43#pragma mark Delegates 44 45@property (weak) id <WKBrowsingContextLoadDelegate> loadDelegate; 46@property (weak) id <WKBrowsingContextPolicyDelegate> policyDelegate; 47@property (weak) id <WKBrowsingContextHistoryDelegate> historyDelegate; 48 49#pragma mark Loading 50 51+ (void)registerSchemeForCustomProtocol:(NSString *)scheme; 52+ (void)unregisterSchemeForCustomProtocol:(NSString *)scheme; 53 54/* Load a request. This is only valid for requests of non-file: URLs. Passing a 55 file: URL will throw an exception. */ 56- (void)loadRequest:(NSURLRequest *)request; 57- (void)loadRequest:(NSURLRequest *)request userData:(id)userData; 58 59/* Load a file: URL. Opens the sandbox only for files within allowedDirectory. 60 - Passing a non-file: URL to either parameter will yield an exception. 61 - Passing nil as the allowedDirectory will open the entire file-system for 62 reading. 63*/ 64- (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory; 65- (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory userData:(id)userData; 66 67/* Load a webpage using the passed in string as its contents. */ 68- (void)loadHTMLString:(NSString *)HTMLString baseURL:(NSURL *)baseURL; 69- (void)loadHTMLString:(NSString *)HTMLString baseURL:(NSURL *)baseURL userData:(id)userData; 70 71- (void)loadAlternateHTMLString:(NSString *)string baseURL:(NSURL *)baseURL forUnreachableURL:(NSURL *)unreachableURL; 72 73/* Load a webpage using the passed in data as its contents. */ 74- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL; 75- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL userData:(id)userData; 76 77/* Stops the load associated with the active URL. */ 78- (void)stopLoading; 79 80/* Reload the currently active URL. */ 81- (void)reload; 82 83/* Reload the currently active URL, bypassing caches. */ 84- (void)reloadFromOrigin; 85 86@property (copy) NSString *applicationNameForUserAgent; 87@property (copy) NSString *customUserAgent; 88 89#pragma mark Back/Forward 90 91/* Go to the next webpage in the back/forward list. */ 92- (void)goForward; 93 94/* Whether there is a next webpage in the back/forward list. */ 95@property(readonly) BOOL canGoForward; 96 97/* Go to the previous webpage in the back/forward list. */ 98- (void)goBack; 99 100/* Whether there is a previous webpage in the back/forward list. */ 101@property(readonly) BOOL canGoBack; 102 103- (void)goToBackForwardListItem:(WKBackForwardListItem *)item; 104 105@property(readonly) WKBackForwardList *backForwardList; 106 107#pragma mark Active Load Introspection 108 109@property (readonly, getter=isLoading) BOOL loading; 110 111/* URL for the active load. This is the URL that should be shown in user interface. */ 112@property(readonly) NSURL *activeURL; 113 114/* URL for a request that has been sent, but no response has been received yet. */ 115@property(readonly) NSURL *provisionalURL; 116 117/* URL for a request that has been received, and is now being used. */ 118@property(readonly) NSURL *committedURL; 119 120@property(readonly) NSURL *unreachableURL; 121 122@property(readonly) double estimatedProgress; 123 124@property (nonatomic) WKRenderingProgressEvents observedRenderingProgressEvents; 125 126#pragma mark Active Document Introspection 127 128/* Title of the document associated with the active load. */ 129@property(readonly) NSString *title; 130 131@property (readonly) NSArray *certificateChain; 132 133#pragma mark Zoom 134 135/* Sets the text zoom for the active URL. */ 136@property CGFloat textZoom; 137 138/* Sets the text zoom for the active URL. */ 139@property CGFloat pageZoom; 140 141@end 142 143#endif // WK_API_ENABLED 144