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 <WebKit2/WKBase.h>
28
29@class WKBrowsingContextControllerData;
30@protocol WKBrowsingContextLoadDelegate;
31
32WK_EXPORT
33@interface WKBrowsingContextController : NSObject {
34@private
35    WKBrowsingContextControllerData *_data;
36}
37
38#pragma mark Delegates
39
40@property(assign) id<WKBrowsingContextLoadDelegate> loadDelegate;
41
42
43#pragma mark Loading
44
45+ (void)registerSchemeForCustomProtocol:(NSString *)scheme;
46+ (void)unregisterSchemeForCustomProtocol:(NSString *)scheme;
47
48/* Load a request. This is only valid for requests of non-file: URLs. Passing a
49   file: URL will throw an exception. */
50- (void)loadRequest:(NSURLRequest *)request;
51- (void)loadRequest:(NSURLRequest *)request userData:(id)userData;
52
53/* Load a file: URL. Opens the sandbox only for files within allowedDirectory.
54    - Passing a non-file: URL to either parameter will yield an exception.
55    - Passing nil as the allowedDirectory will open the entire file-system for
56      reading.
57*/
58- (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory;
59- (void)loadFileURL:(NSURL *)URL restrictToFilesWithin:(NSURL *)allowedDirectory userData:(id)userData;
60
61/* Load a page using the passed in string as its contents. */
62- (void)loadHTMLString:(NSString *)HTMLString baseURL:(NSURL *)baseURL;
63- (void)loadHTMLString:(NSString *)HTMLString baseURL:(NSURL *)baseURL userData:(id)userData;
64
65/* Load a page using the passed in data as its contents. */
66- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL;
67- (void)loadData:(NSData *)data MIMEType:(NSString *)MIMEType textEncodingName:(NSString *)encodingName baseURL:(NSURL *)baseURL userData:(id)userData;
68
69/* Stops the load associated with the active URL. */
70- (void)stopLoading;
71
72/* Reload the currently active URL. */
73- (void)reload;
74
75/* Reload the currently active URL, bypassing caches. */
76- (void)reloadFromOrigin;
77
78
79#pragma mark Back/Forward
80
81/* Go to the next page in the back/forward list. */
82- (void)goForward;
83
84/* Whether there is a next page in the back/forward list. */
85@property(readonly) BOOL canGoForward;
86
87/* Go to the previous page in the back/forward list. */
88- (void)goBack;
89
90/* Whether there is a previous page in the back/forward list. */
91@property(readonly) BOOL canGoBack;
92
93
94#pragma mark Active Load Introspection
95
96/* URL for the active load. This is the URL that should be shown in user interface. */
97@property(readonly) NSURL *activeURL;
98
99/* URL for a request that has been sent, but no response has been recieved yet. */
100@property(readonly) NSURL *provisionalURL;
101
102/* URL for a request that has been recieved, and is now being used. */
103@property(readonly) NSURL *committedURL;
104
105
106#pragma mark Active Document Introspection
107
108/* Title of the document associated with the active load. */
109@property(readonly) NSString *title;
110
111
112#pragma mark Zoom
113
114/* Sets the text zoom for the active URL. */
115@property CGFloat textZoom;
116
117/* Sets the text zoom for the active URL. */
118@property CGFloat pageZoom;
119
120@end
121