[iOS] Implement safe browsing in WebKit
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / WKWebViewInternal.h
1 /*
2  * Copyright (C) 2014-2016 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 "WKWebViewPrivate.h"
27
28 #if WK_API_ENABLED
29
30 #import "SameDocumentNavigationType.h"
31 #import "WKShareSheet.h"
32 #import "WKWebViewConfiguration.h"
33 #import "_WKAttachmentInternal.h"
34 #import "_WKWebViewPrintFormatterInternal.h"
35 #import <wtf/CompletionHandler.h>
36 #import <wtf/RefPtr.h>
37 #import <wtf/RetainPtr.h>
38 #import <wtf/Variant.h>
39
40 #if PLATFORM(IOS_FAMILY)
41 #import "UIKitSPI.h"
42 #import "WKContentView.h"
43 #import "WKContentViewInteraction.h"
44 #import "WKFullScreenWindowControllerIOS.h"
45 #import <WebCore/FloatRect.h>
46 #import <WebCore/LengthBox.h>
47 #endif
48
49 #if PLATFORM(IOS_FAMILY)
50 #define WK_WEB_VIEW_PROTOCOLS <UIScrollViewDelegate>
51 #endif
52
53 #if PLATFORM(MAC)
54 #define WK_WEB_VIEW_PROTOCOLS <WKShareSheetDelegate>
55 #endif
56
57 #if !defined(WK_WEB_VIEW_PROTOCOLS)
58 #define WK_WEB_VIEW_PROTOCOLS
59 #endif
60
61 typedef const struct OpaqueWKPage* WKPageRef;
62
63 namespace API {
64 class Attachment;
65 }
66
67 namespace WebKit {
68 enum class ContinueUnsafeLoad : bool;
69 class SafeBrowsingResult;
70 class ViewSnapshot;
71 class WebPageProxy;
72 struct PrintInfo;
73 }
74
75 namespace WebCore {
76 class URL;
77 }
78
79 @class WKWebViewContentProviderRegistry;
80 @class WKPasswordView;
81 @class _WKFrameHandle;
82
83 @interface WKWebView () WK_WEB_VIEW_PROTOCOLS {
84
85 @package
86     RetainPtr<WKWebViewConfiguration> _configuration;
87
88     RefPtr<WebKit::WebPageProxy> _page;
89 }
90
91 #if PLATFORM(IOS_FAMILY)
92 - (void)_processDidExit;
93 - (void)_processWillSwap;
94 - (void)_didRelaunchProcess;
95
96 - (void)_didCommitLoadForMainFrame;
97 - (void)_didCommitLayerTree:(const WebKit::RemoteLayerTreeTransaction&)layerTreeTransaction;
98 - (void)_layerTreeCommitComplete;
99
100 - (void)_couldNotRestorePageState;
101 - (void)_restorePageScrollPosition:(std::optional<WebCore::FloatPoint>)scrollPosition scrollOrigin:(WebCore::FloatPoint)scrollOrigin previousObscuredInset:(WebCore::FloatBoxExtent)insets scale:(double)scale;
102 - (void)_restorePageStateToUnobscuredCenter:(std::optional<WebCore::FloatPoint>)center scale:(double)scale; // FIXME: needs scroll origin?
103
104 - (RefPtr<WebKit::ViewSnapshot>)_takeViewSnapshot;
105
106 - (void)_scrollToContentScrollPosition:(WebCore::FloatPoint)scrollPosition scrollOrigin:(WebCore::IntPoint)scrollOrigin;
107 - (BOOL)_scrollToRect:(WebCore::FloatRect)targetRect origin:(WebCore::FloatPoint)origin minimumScrollDistance:(float)minimumScrollDistance;
108 - (void)_zoomToFocusRect:(WebCore::FloatRect)focusedElementRect selectionRect:(WebCore::FloatRect)selectionRectInDocumentCoordinates insideFixed:(BOOL)insideFixed fontSize:(float)fontSize minimumScale:(double)minimumScale maximumScale:(double)maximumScale allowScaling:(BOOL)allowScaling forceScroll:(BOOL)forceScroll;
109 - (BOOL)_zoomToRect:(WebCore::FloatRect)targetRect withOrigin:(WebCore::FloatPoint)origin fitEntireRect:(BOOL)fitEntireRect minimumScale:(double)minimumScale maximumScale:(double)maximumScale minimumScrollDistance:(float)minimumScrollDistance;
110 - (void)_zoomOutWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
111 - (void)_zoomToInitialScaleWithOrigin:(WebCore::FloatPoint)origin animated:(BOOL)animated;
112 - (void)_didFinishScrolling;
113
114 - (void)_setHasCustomContentView:(BOOL)hasCustomContentView loadedMIMEType:(const WTF::String&)mimeType;
115 - (void)_didFinishLoadingDataForCustomContentProviderWithSuggestedFilename:(const WTF::String&)suggestedFilename data:(NSData *)data;
116
117 - (void)_willInvokeUIScrollViewDelegateCallback;
118 - (void)_didInvokeUIScrollViewDelegateCallback;
119
120 - (void)_scheduleVisibleContentRectUpdate;
121
122 - (void)_didCompleteAnimatedResize;
123
124 - (void)_didStartProvisionalLoadForMainFrame;
125 - (void)_didFinishLoadForMainFrame;
126 - (void)_didFailLoadForMainFrame;
127 - (void)_didSameDocumentNavigationForMainFrame:(WebKit::SameDocumentNavigationType)navigationType;
128
129 - (BOOL)_isShowingVideoPictureInPicture;
130 - (BOOL)_mayAutomaticallyShowVideoPictureInPicture;
131
132 - (void)_updateScrollViewBackground;
133
134 - (void)_videoControlsManagerDidChange;
135
136 - (void)_navigationGestureDidBegin;
137 - (void)_navigationGestureDidEnd;
138 - (BOOL)_isNavigationSwipeGestureRecognizer:(UIGestureRecognizer *)recognizer;
139
140 - (void)_showPasswordViewWithDocumentName:(NSString *)documentName passwordHandler:(void (^)(NSString *))passwordHandler;
141 - (void)_hidePasswordView;
142
143 - (void)_didChangeEditorState;
144
145 - (void)_addShortcut:(id)sender;
146 - (void)_define:(id)sender;
147 - (void)_lookup:(id)sender;
148 - (void)_share:(id)sender;
149 - (void)_showTextStyleOptions:(id)sender;
150 - (void)_promptForReplace:(id)sender;
151 - (void)_transliterateChinese:(id)sender;
152 - (void)replace:(id)sender;
153
154 - (void)_incrementFocusPreservationCount;
155 - (void)_decrementFocusPreservationCount;
156 - (void)_resetFocusPreservationCount;
157
158 @property (nonatomic, readonly) WKPasswordView *_passwordView;
159
160 @property (nonatomic, readonly) BOOL _isBackground;
161
162 @property (nonatomic, readonly) WKWebViewContentProviderRegistry *_contentProviderRegistry;
163
164 @property (nonatomic, readonly) WKSelectionGranularity _selectionGranularity;
165
166 @property (nonatomic, readonly) BOOL _allowsDoubleTapGestures;
167 @property (nonatomic, readonly) BOOL _haveSetObscuredInsets;
168 @property (nonatomic, readonly) UIEdgeInsets _computedObscuredInset;
169 @property (nonatomic, readonly) UIEdgeInsets _computedUnobscuredSafeAreaInset;
170 @property (nonatomic, readonly, getter=_isRetainingActiveFocusedState) BOOL _retainingActiveFocusedState;
171 #endif
172
173 #if ENABLE(ACCESSIBILITY_EVENTS)
174 - (void)_updateAccessibilityEventsEnabled;
175 #endif
176
177 #if ENABLE(ATTACHMENT_ELEMENT)
178 - (void)_didRemoveAttachment:(API::Attachment&)attachment;
179 - (void)_didInsertAttachment:(API::Attachment&)attachment withSource:(NSString *)source;
180 #endif
181
182 - (void)_showSafeBrowsingWarning:(const WebKit::SafeBrowsingResult&)result completionHandler:(CompletionHandler<void(Variant<WebKit::ContinueUnsafeLoad, WebCore::URL>&&)>&&)completionHandler;
183 - (void)_clearSafeBrowsingWarning;
184
185 - (std::optional<BOOL>)_resolutionForShareSheetImmediateCompletionForTesting;
186
187 - (WKPageRef)_pageForTesting;
188 - (WebKit::WebPageProxy*)_page;
189
190 @end
191
192 WKWebView* fromWebPageProxy(WebKit::WebPageProxy&);
193
194 #if ENABLE(FULLSCREEN_API) && PLATFORM(IOS_FAMILY)
195 @interface WKWebView (FullScreenAPI)
196 -(BOOL)hasFullScreenWindowController;
197 -(WKFullScreenWindowController *)fullScreenWindowController;
198 -(void)closeFullScreenWindowController;
199 @end
200 #endif // ENABLE(FULLSCREEN_API) && PLATFORM(IOS_FAMILY)
201
202 #if PLATFORM(IOS_FAMILY) && !PLATFORM(IOSMAC)
203 @interface WKWebView (_WKWebViewPrintFormatter)
204 @property (nonatomic, readonly) id <_WKWebViewPrintProvider> _printProvider;
205 @end
206 #endif
207
208 #endif