Transition "WebKit Library Version" checks to SDK version checks.
[WebKit-https.git] / Source / WebKit2 / UIProcess / API / Cocoa / WKWebViewConfiguration.mm
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 "config.h"
27 #import "WKWebViewConfigurationInternal.h"
28
29 #if WK_API_ENABLED
30
31 #import "APIPageConfiguration.h"
32 #import "VersionChecks.h"
33 #import "WKPreferences.h"
34 #import "WKProcessPool.h"
35 #import "WKUserContentController.h"
36 #import "WKWebViewContentProviderRegistry.h"
37 #import "WeakObjCPtr.h"
38 #import "_WKVisitedLinkStore.h"
39 #import "_WKWebsiteDataStoreInternal.h"
40 #import <WebCore/RuntimeApplicationChecks.h>
41 #import <wtf/RetainPtr.h>
42
43 #if PLATFORM(IOS)
44 #import "UIKitSPI.h"
45 #import <WebCore/Device.h>
46 #endif
47
48 using namespace WebCore;
49
50 template<typename T> class LazyInitialized {
51 public:
52     typedef typename WTF::GetPtrHelper<T>::PtrType PtrType;
53
54     template<typename F>
55     PtrType get(F&& f)
56     {
57         if (!m_isInitialized) {
58             m_value = f();
59             m_isInitialized = true;
60         }
61
62         return m_value.get();
63     }
64
65     void set(PtrType t)
66     {
67         m_value = t;
68         m_isInitialized = true;
69     }
70
71     void set(T&& t)
72     {
73         m_value = WTFMove(t);
74         m_isInitialized = true;
75     }
76
77     PtrType peek()
78     {
79         return m_value.get();
80     }
81
82 private:
83     bool m_isInitialized = false;
84     T m_value;
85 };
86
87 @implementation WKWebViewConfiguration {
88     LazyInitialized<RetainPtr<WKProcessPool>> _processPool;
89     LazyInitialized<RetainPtr<WKPreferences>> _preferences;
90     LazyInitialized<RetainPtr<WKUserContentController>> _userContentController;
91     LazyInitialized<RetainPtr<_WKVisitedLinkStore>> _visitedLinkStore;
92     LazyInitialized<RetainPtr<WKWebsiteDataStore>> _websiteDataStore;
93     WebKit::WeakObjCPtr<WKWebView> _relatedWebView;
94     WebKit::WeakObjCPtr<WKWebView> _alternateWebViewForNavigationGestures;
95     RetainPtr<NSString> _groupIdentifier;
96     LazyInitialized<RetainPtr<NSString>> _applicationNameForUserAgent;
97     NSTimeInterval _incrementalRenderingSuppressionTimeout;
98     BOOL _treatsSHA1SignedCertificatesAsInsecure;
99     BOOL _respectsImageOrientation;
100     BOOL _printsBackgrounds;
101     BOOL _allowsJavaScriptMarkup;
102     BOOL _convertsPositionStyleOnCopy;
103     BOOL _allowsMetaRefresh;
104     BOOL _allowUniversalAccessFromFileURLs;
105
106 #if PLATFORM(IOS)
107     LazyInitialized<RetainPtr<WKWebViewContentProviderRegistry>> _contentProviderRegistry;
108     BOOL _alwaysRunsAtForegroundPriority;
109     BOOL _allowsInlineMediaPlayback;
110     BOOL _inlineMediaPlaybackRequiresPlaysInlineAttribute;
111     BOOL _allowsInlineMediaPlaybackAfterFullscreen;
112 #endif
113
114     BOOL _invisibleAutoplayNotPermitted;
115     BOOL _mediaDataLoadsAutomatically;
116     BOOL _attachmentElementEnabled;
117     BOOL _mainContentUserGestureOverrideEnabled;
118
119 #if PLATFORM(MAC)
120     BOOL _showsURLsInToolTips;
121     BOOL _serviceControlsEnabled;
122     BOOL _imageControlsEnabled;
123     BOOL _requiresUserActionForEditingControlsManager;
124 #endif
125     BOOL _initialCapitalizationEnabled;
126     BOOL _waitsForPaintAfterViewDidMoveToWindow;
127     BOOL _controlledByAutomation;
128
129 #if ENABLE(APPLE_PAY)
130     BOOL _applePayEnabled;
131 #endif
132     BOOL _needsStorageAccessFromFileURLsQuirk;
133
134     NSString *_overrideContentSecurityPolicy;
135 }
136
137 - (instancetype)init
138 {
139     if (!(self = [super init]))
140         return nil;
141     
142 #if PLATFORM(IOS)
143     _allowsPictureInPictureMediaPlayback = YES;
144     _allowsInlineMediaPlayback = WebCore::deviceClass() == MGDeviceClassiPad;
145     _inlineMediaPlaybackRequiresPlaysInlineAttribute = !_allowsInlineMediaPlayback;
146     _allowsInlineMediaPlaybackAfterFullscreen = !_allowsInlineMediaPlayback;
147     _mediaDataLoadsAutomatically = NO;
148     if (linkedOnOrAfter(WebKit::SDKVersion::FirstWithMediaTypesRequiringUserActionForPlayback))
149         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAudio;
150     else
151         _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeAll;
152     _ignoresViewportScaleLimits = NO;
153 #else
154     _mediaTypesRequiringUserActionForPlayback = WKAudiovisualMediaTypeNone;
155     _mediaDataLoadsAutomatically = YES;
156     _userInterfaceDirectionPolicy = WKUserInterfaceDirectionPolicyContent;
157 #endif
158     _mainContentUserGestureOverrideEnabled = NO;
159     _invisibleAutoplayNotPermitted = NO;
160
161 // FIXME: <rdar://problem/25135244> Should default to NO once clients have adopted the setting.
162 #if PLATFORM(IOS)
163     _attachmentElementEnabled = IOSApplication::isMobileMail();
164 #else
165     _attachmentElementEnabled = MacApplication::isAppleMail();
166 #endif
167
168 #if PLATFORM(IOS)
169     _respectsImageOrientation = YES;
170     _printsBackgrounds = YES;
171 #endif
172
173 #if PLATFORM(MAC)
174     _printsBackgrounds = NO;
175     _respectsImageOrientation = NO;
176     _showsURLsInToolTips = NO;
177     _serviceControlsEnabled = NO;
178     _imageControlsEnabled = NO;
179     _requiresUserActionForEditingControlsManager = NO;
180 #endif
181     _initialCapitalizationEnabled = YES;
182     _waitsForPaintAfterViewDidMoveToWindow = YES;
183
184 #if ENABLE(WIRELESS_PLAYBACK_TARGET)
185     _allowsAirPlayForMediaPlayback = YES;
186 #endif
187
188     _incrementalRenderingSuppressionTimeout = 5;
189     _allowsJavaScriptMarkup = YES;
190     _convertsPositionStyleOnCopy = NO;
191     _allowsMetaRefresh = YES;
192     _allowUniversalAccessFromFileURLs = NO;
193     _treatsSHA1SignedCertificatesAsInsecure = YES;
194     _needsStorageAccessFromFileURLsQuirk = YES;
195
196     return self;
197 }
198
199 - (NSString *)description
200 {
201     return [NSString stringWithFormat:@"<%@: %p; processPool = %@; preferences = %@>", NSStringFromClass(self.class), self, self.processPool, self.preferences];
202 }
203
204 // FIXME: Encode the process pool, user content controller and website data store.
205
206 - (void)encodeWithCoder:(NSCoder *)coder
207 {
208     [coder encodeObject:self.processPool forKey:@"processPool"];
209     [coder encodeObject:self.preferences forKey:@"preferences"];
210     [coder encodeObject:self.userContentController forKey:@"userContentController"];
211     [coder encodeObject:self.websiteDataStore forKey:@"websiteDataStore"];
212
213     [coder encodeBool:self.suppressesIncrementalRendering forKey:@"suppressesIncrementalRendering"];
214     [coder encodeObject:self.applicationNameForUserAgent forKey:@"applicationNameForUserAgent"];
215     [coder encodeBool:self.allowsAirPlayForMediaPlayback forKey:@"allowsAirPlayForMediaPlayback"];
216
217 #if PLATFORM(IOS)
218     [coder encodeInteger:self.dataDetectorTypes forKey:@"dataDetectorTypes"];
219     [coder encodeBool:self.allowsInlineMediaPlayback forKey:@"allowsInlineMediaPlayback"];
220     [coder encodeBool:self._allowsInlineMediaPlaybackAfterFullscreen forKey:@"allowsInlineMediaPlaybackAfterFullscreen"];
221     [coder encodeBool:self.mediaTypesRequiringUserActionForPlayback forKey:@"mediaTypesRequiringUserActionForPlayback"];
222     [coder encodeInteger:self.selectionGranularity forKey:@"selectionGranularity"];
223     [coder encodeBool:self.allowsPictureInPictureMediaPlayback forKey:@"allowsPictureInPictureMediaPlayback"];
224     [coder encodeBool:self.ignoresViewportScaleLimits forKey:@"ignoresViewportScaleLimits"];
225 #else
226     [coder encodeInteger:self.userInterfaceDirectionPolicy forKey:@"userInterfaceDirectionPolicy"];
227 #endif
228 }
229
230 - (instancetype)initWithCoder:(NSCoder *)coder
231 {
232     if (!(self = [self init]))
233         return nil;
234
235     self.processPool = [coder decodeObjectForKey:@"processPool"];
236     self.preferences = [coder decodeObjectForKey:@"preferences"];
237     self.userContentController = [coder decodeObjectForKey:@"userContentController"];
238     self.websiteDataStore = [coder decodeObjectForKey:@"websiteDataStore"];
239
240     self.suppressesIncrementalRendering = [coder decodeBoolForKey:@"suppressesIncrementalRendering"];
241     self.applicationNameForUserAgent = [coder decodeObjectForKey:@"applicationNameForUserAgent"];
242     self.allowsAirPlayForMediaPlayback = [coder decodeBoolForKey:@"allowsAirPlayForMediaPlayback"];
243
244 #if PLATFORM(IOS)
245     self.dataDetectorTypes = [coder decodeIntegerForKey:@"dataDetectorTypes"];
246     self.allowsInlineMediaPlayback = [coder decodeBoolForKey:@"allowsInlineMediaPlayback"];
247     self._allowsInlineMediaPlaybackAfterFullscreen = [coder decodeBoolForKey:@"allowsInlineMediaPlaybackAfterFullscreen"];
248     self.mediaTypesRequiringUserActionForPlayback = [coder decodeBoolForKey:@"mediaTypesRequiringUserActionForPlayback"];
249     self.selectionGranularity = static_cast<WKSelectionGranularity>([coder decodeIntegerForKey:@"selectionGranularity"]);
250     self.allowsPictureInPictureMediaPlayback = [coder decodeBoolForKey:@"allowsPictureInPictureMediaPlayback"];
251     self.ignoresViewportScaleLimits = [coder decodeBoolForKey:@"ignoresViewportScaleLimits"];
252 #else
253     auto userInterfaceDirectionPolicyCandidate = static_cast<WKUserInterfaceDirectionPolicy>([coder decodeIntegerForKey:@"userInterfaceDirectionPolicy"]);
254     if (userInterfaceDirectionPolicyCandidate == WKUserInterfaceDirectionPolicyContent || userInterfaceDirectionPolicyCandidate == WKUserInterfaceDirectionPolicySystem)
255         self.userInterfaceDirectionPolicy = userInterfaceDirectionPolicyCandidate;
256 #endif
257
258     return self;
259 }
260
261 - (id)copyWithZone:(NSZone *)zone
262 {
263     WKWebViewConfiguration *configuration = [(WKWebViewConfiguration *)[[self class] allocWithZone:zone] init];
264
265     configuration.processPool = self.processPool;
266     configuration.preferences = self.preferences;
267     configuration.userContentController = self.userContentController;
268     configuration.websiteDataStore = self.websiteDataStore;
269     configuration._visitedLinkStore = self._visitedLinkStore;
270     configuration._relatedWebView = _relatedWebView.get().get();
271     configuration._alternateWebViewForNavigationGestures = _alternateWebViewForNavigationGestures.get().get();
272     configuration->_treatsSHA1SignedCertificatesAsInsecure = _treatsSHA1SignedCertificatesAsInsecure;
273 #if PLATFORM(IOS)
274     configuration._contentProviderRegistry = self._contentProviderRegistry;
275 #endif
276
277     configuration->_suppressesIncrementalRendering = self->_suppressesIncrementalRendering;
278     configuration.applicationNameForUserAgent = self.applicationNameForUserAgent;
279
280     configuration->_respectsImageOrientation = self->_respectsImageOrientation;
281     configuration->_printsBackgrounds = self->_printsBackgrounds;
282     configuration->_incrementalRenderingSuppressionTimeout = self->_incrementalRenderingSuppressionTimeout;
283     configuration->_allowsJavaScriptMarkup = self->_allowsJavaScriptMarkup;
284     configuration->_convertsPositionStyleOnCopy = self->_convertsPositionStyleOnCopy;
285     configuration->_allowsMetaRefresh = self->_allowsMetaRefresh;
286     configuration->_allowUniversalAccessFromFileURLs = self->_allowUniversalAccessFromFileURLs;
287
288     configuration->_invisibleAutoplayNotPermitted = self->_invisibleAutoplayNotPermitted;
289     configuration->_mediaDataLoadsAutomatically = self->_mediaDataLoadsAutomatically;
290     configuration->_attachmentElementEnabled = self->_attachmentElementEnabled;
291     configuration->_mediaTypesRequiringUserActionForPlayback = self->_mediaTypesRequiringUserActionForPlayback;
292     configuration->_mainContentUserGestureOverrideEnabled = self->_mainContentUserGestureOverrideEnabled;
293     configuration->_initialCapitalizationEnabled = self->_initialCapitalizationEnabled;
294     configuration->_waitsForPaintAfterViewDidMoveToWindow = self->_waitsForPaintAfterViewDidMoveToWindow;
295     configuration->_controlledByAutomation = self->_controlledByAutomation;
296
297 #if PLATFORM(IOS)
298     configuration->_allowsInlineMediaPlayback = self->_allowsInlineMediaPlayback;
299     configuration->_allowsInlineMediaPlaybackAfterFullscreen = self->_allowsInlineMediaPlaybackAfterFullscreen;
300     configuration->_inlineMediaPlaybackRequiresPlaysInlineAttribute = self->_inlineMediaPlaybackRequiresPlaysInlineAttribute;
301     configuration->_allowsPictureInPictureMediaPlayback = self->_allowsPictureInPictureMediaPlayback;
302     configuration->_alwaysRunsAtForegroundPriority = _alwaysRunsAtForegroundPriority;
303     configuration->_selectionGranularity = self->_selectionGranularity;
304     configuration->_ignoresViewportScaleLimits = self->_ignoresViewportScaleLimits;
305 #endif
306 #if PLATFORM(MAC)
307     configuration->_userInterfaceDirectionPolicy = self->_userInterfaceDirectionPolicy;
308     configuration->_showsURLsInToolTips = self->_showsURLsInToolTips;
309     configuration->_serviceControlsEnabled = self->_serviceControlsEnabled;
310     configuration->_imageControlsEnabled = self->_imageControlsEnabled;
311     configuration->_requiresUserActionForEditingControlsManager = self->_requiresUserActionForEditingControlsManager;
312 #endif
313 #if ENABLE(DATA_DETECTION) && PLATFORM(IOS)
314     configuration->_dataDetectorTypes = self->_dataDetectorTypes;
315 #endif
316 #if ENABLE(WIRELESS_TARGET_PLAYBACK)
317     configuration->_allowsAirPlayForMediaPlayback = self->_allowsAirPlayForMediaPlayback;
318 #endif
319 #if ENABLE(APPLE_PAY)
320     configuration->_applePayEnabled = self->_applePayEnabled;
321 #endif
322     configuration->_needsStorageAccessFromFileURLsQuirk = self->_needsStorageAccessFromFileURLsQuirk;
323     configuration->_overrideContentSecurityPolicy = self->_overrideContentSecurityPolicy;
324
325     return configuration;
326 }
327
328 - (WKProcessPool *)processPool
329 {
330     return _processPool.get([] { return adoptNS([[WKProcessPool alloc] init]); });
331 }
332
333 - (void)setProcessPool:(WKProcessPool *)processPool
334 {
335     _processPool.set(processPool);
336 }
337
338 - (WKPreferences *)preferences
339 {
340     return _preferences.get([] { return adoptNS([[WKPreferences alloc] init]); });
341 }
342
343 - (void)setPreferences:(WKPreferences *)preferences
344 {
345     _preferences.set(preferences);
346 }
347
348 - (WKUserContentController *)userContentController
349 {
350     return _userContentController.get([] { return adoptNS([[WKUserContentController alloc] init]); });
351 }
352
353 - (void)setUserContentController:(WKUserContentController *)userContentController
354 {
355     _userContentController.set(userContentController);
356 }
357
358 - (WKWebsiteDataStore *)websiteDataStore
359 {
360     return _websiteDataStore.get([] { return [WKWebsiteDataStore defaultDataStore]; });
361 }
362
363 - (void)setWebsiteDataStore:(WKWebsiteDataStore *)websiteDataStore
364 {
365     _websiteDataStore.set(websiteDataStore);
366 }
367
368 static NSString *defaultApplicationNameForUserAgent()
369 {
370 #if PLATFORM(IOS)
371     return [@"Mobile/" stringByAppendingString:[UIDevice currentDevice].buildVersion];
372 #else
373     return nil;
374 #endif
375 }
376
377 - (NSString *)applicationNameForUserAgent
378 {
379     return _applicationNameForUserAgent.get([] { return defaultApplicationNameForUserAgent(); });
380 }
381
382 - (void)setApplicationNameForUserAgent:(NSString *)applicationNameForUserAgent
383 {
384     _applicationNameForUserAgent.set(adoptNS([applicationNameForUserAgent copy]));
385 }
386
387 - (_WKVisitedLinkStore *)_visitedLinkStore
388 {
389     return _visitedLinkStore.get([] { return adoptNS([[_WKVisitedLinkStore alloc] init]); });
390 }
391
392 - (void)_setVisitedLinkStore:(_WKVisitedLinkStore *)visitedLinkStore
393 {
394     _visitedLinkStore.set(visitedLinkStore);
395 }
396
397 #pragma clang diagnostic push
398 #pragma clang diagnostic ignored "-Wdeprecated-declarations"
399
400 - (_WKWebsiteDataStore *)_websiteDataStore
401 {
402     return self.websiteDataStore ? adoptNS([[_WKWebsiteDataStore alloc] initWithDataStore:self.websiteDataStore]).autorelease() : nullptr;
403 }
404
405 - (void)_setWebsiteDataStore:(_WKWebsiteDataStore *)websiteDataStore
406 {
407     self.websiteDataStore = websiteDataStore ? websiteDataStore->_dataStore.get() : nullptr;
408 }
409
410 #pragma clang diagnostic pop
411
412 #if PLATFORM(IOS)
413 - (WKWebViewContentProviderRegistry *)_contentProviderRegistry
414 {
415     return _contentProviderRegistry.get([] { return adoptNS([[WKWebViewContentProviderRegistry alloc] init]); });
416 }
417
418 - (void)_setContentProviderRegistry:(WKWebViewContentProviderRegistry *)registry
419 {
420     _contentProviderRegistry.set(registry);
421 }
422 #endif
423
424 - (void)_validate
425 {
426     if (!self.processPool)
427         [NSException raise:NSInvalidArgumentException format:@"configuration.processPool is nil"];
428
429     if (!self.preferences)
430         [NSException raise:NSInvalidArgumentException format:@"configuration.preferences is nil"];
431
432     if (!self.userContentController)
433         [NSException raise:NSInvalidArgumentException format:@"configuration.userContentController is nil"];
434
435     if (!self.websiteDataStore)
436         [NSException raise:NSInvalidArgumentException format:@"configuration.websiteDataStore is nil"];
437
438     if (!self._visitedLinkStore)
439         [NSException raise:NSInvalidArgumentException format:@"configuration._visitedLinkStore is nil"];
440
441 #if PLATFORM(IOS)
442     if (!self._contentProviderRegistry)
443         [NSException raise:NSInvalidArgumentException format:@"configuration._contentProviderRegistry is nil"];
444 #endif
445 }
446
447 @end
448
449 @implementation WKWebViewConfiguration (WKPrivate)
450
451 - (WKWebView *)_relatedWebView
452 {
453     return _relatedWebView.getAutoreleased();
454 }
455
456 - (void)_setRelatedWebView:(WKWebView *)relatedWebView
457 {
458     _relatedWebView = relatedWebView;
459 }
460
461 - (WKWebView *)_alternateWebViewForNavigationGestures
462 {
463     return _alternateWebViewForNavigationGestures.getAutoreleased();
464 }
465
466 - (void)_setAlternateWebViewForNavigationGestures:(WKWebView *)alternateView
467 {
468     _alternateWebViewForNavigationGestures = alternateView;
469 }
470
471 - (NSString *)_groupIdentifier
472 {
473     return _groupIdentifier.get();
474 }
475
476 - (void)_setGroupIdentifier:(NSString *)groupIdentifier
477 {
478     _groupIdentifier = groupIdentifier;
479 }
480
481 - (BOOL)_treatsSHA1SignedCertificatesAsInsecure
482 {
483     return _treatsSHA1SignedCertificatesAsInsecure;
484 }
485
486 - (void)_setTreatsSHA1SignedCertificatesAsInsecure:(BOOL)insecure
487 {
488     _treatsSHA1SignedCertificatesAsInsecure = insecure;
489 }
490
491 - (BOOL)_respectsImageOrientation
492 {
493     return _respectsImageOrientation;
494 }
495
496 - (void)_setRespectsImageOrientation:(BOOL)respectsImageOrientation
497 {
498     _respectsImageOrientation = respectsImageOrientation;
499 }
500
501 - (BOOL)_printsBackgrounds
502 {
503     return _printsBackgrounds;
504 }
505
506 - (void)_setPrintsBackgrounds:(BOOL)printsBackgrounds
507 {
508     _printsBackgrounds = printsBackgrounds;
509 }
510
511 - (NSTimeInterval)_incrementalRenderingSuppressionTimeout
512 {
513     return _incrementalRenderingSuppressionTimeout;
514 }
515
516 - (void)_setIncrementalRenderingSuppressionTimeout:(NSTimeInterval)incrementalRenderingSuppressionTimeout
517 {
518     _incrementalRenderingSuppressionTimeout = incrementalRenderingSuppressionTimeout;
519 }
520
521 - (BOOL)_allowsJavaScriptMarkup
522 {
523     return _allowsJavaScriptMarkup;
524 }
525
526 - (void)_setAllowsJavaScriptMarkup:(BOOL)allowsJavaScriptMarkup
527 {
528     _allowsJavaScriptMarkup = allowsJavaScriptMarkup;
529 }
530
531 - (BOOL)_allowUniversalAccessFromFileURLs
532 {
533     return _allowUniversalAccessFromFileURLs;
534 }
535
536 - (void)_setAllowUniversalAccessFromFileURLs:(BOOL)allowUniversalAccessFromFileURLs
537 {
538     _allowUniversalAccessFromFileURLs = allowUniversalAccessFromFileURLs;
539 }
540
541 - (BOOL)_convertsPositionStyleOnCopy
542 {
543     return _convertsPositionStyleOnCopy;
544 }
545
546 - (void)_setConvertsPositionStyleOnCopy:(BOOL)convertsPositionStyleOnCopy
547 {
548     _convertsPositionStyleOnCopy = convertsPositionStyleOnCopy;
549 }
550
551 - (BOOL)_allowsMetaRefresh
552 {
553     return _allowsMetaRefresh;
554 }
555
556 - (void)_setAllowsMetaRefresh:(BOOL)allowsMetaRefresh
557 {
558     _allowsMetaRefresh = allowsMetaRefresh;
559 }
560
561 #if PLATFORM(IOS)
562 - (BOOL)_alwaysRunsAtForegroundPriority
563 {
564     return _alwaysRunsAtForegroundPriority;
565 }
566
567 - (void)_setAlwaysRunsAtForegroundPriority:(BOOL)alwaysRunsAtForegroundPriority
568 {
569     _alwaysRunsAtForegroundPriority = alwaysRunsAtForegroundPriority;
570 }
571
572 - (BOOL)_inlineMediaPlaybackRequiresPlaysInlineAttribute
573 {
574     return _inlineMediaPlaybackRequiresPlaysInlineAttribute;
575 }
576
577 - (void)_setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)requires
578 {
579     _inlineMediaPlaybackRequiresPlaysInlineAttribute = requires;
580 }
581
582 - (BOOL)_allowsInlineMediaPlaybackAfterFullscreen
583 {
584     return _allowsInlineMediaPlaybackAfterFullscreen;
585 }
586
587 - (void)_setAllowsInlineMediaPlaybackAfterFullscreen:(BOOL)allows
588 {
589     _allowsInlineMediaPlaybackAfterFullscreen = allows;
590 }
591 #endif // PLATFORM(IOS)
592
593 - (BOOL)_invisibleAutoplayNotPermitted
594 {
595     return _invisibleAutoplayNotPermitted;
596 }
597
598 - (void)_setInvisibleAutoplayNotPermitted:(BOOL)notPermitted
599 {
600     _invisibleAutoplayNotPermitted = notPermitted;
601 }
602
603 - (BOOL)_mediaDataLoadsAutomatically
604 {
605     return _mediaDataLoadsAutomatically;
606 }
607
608 - (void)_setMediaDataLoadsAutomatically:(BOOL)mediaDataLoadsAutomatically
609 {
610     _mediaDataLoadsAutomatically = mediaDataLoadsAutomatically;
611 }
612
613 - (BOOL)_attachmentElementEnabled
614 {
615     return _attachmentElementEnabled;
616 }
617
618 - (void)_setAttachmentElementEnabled:(BOOL)attachmentElementEnabled
619 {
620     _attachmentElementEnabled = attachmentElementEnabled;
621 }
622
623 - (BOOL)_requiresUserActionForVideoPlayback
624 {
625     return self.mediaTypesRequiringUserActionForPlayback & WKAudiovisualMediaTypeVideo;
626 }
627
628 - (void)_setRequiresUserActionForVideoPlayback:(BOOL)requiresUserActionForVideoPlayback
629 {
630     if (requiresUserActionForVideoPlayback)
631         self.mediaTypesRequiringUserActionForPlayback |= WKAudiovisualMediaTypeVideo;
632     else
633         self.mediaTypesRequiringUserActionForPlayback &= ~WKAudiovisualMediaTypeVideo;
634 }
635
636 - (BOOL)_requiresUserActionForAudioPlayback
637 {
638     return self.mediaTypesRequiringUserActionForPlayback & WKAudiovisualMediaTypeAudio;
639 }
640
641 - (void)_setRequiresUserActionForAudioPlayback:(BOOL)requiresUserActionForAudioPlayback
642 {
643     if (requiresUserActionForAudioPlayback)
644         self.mediaTypesRequiringUserActionForPlayback |= WKAudiovisualMediaTypeAudio;
645     else
646         self.mediaTypesRequiringUserActionForPlayback &= ~WKAudiovisualMediaTypeAudio;
647 }
648
649 - (BOOL)_mainContentUserGestureOverrideEnabled
650 {
651     return _mainContentUserGestureOverrideEnabled;
652 }
653
654 - (void)_setMainContentUserGestureOverrideEnabled:(BOOL)mainContentUserGestureOverrideEnabled
655 {
656     _mainContentUserGestureOverrideEnabled = mainContentUserGestureOverrideEnabled;
657 }
658
659 - (BOOL)_initialCapitalizationEnabled
660 {
661     return _initialCapitalizationEnabled;
662 }
663
664 - (void)_setInitialCapitalizationEnabled:(BOOL)initialCapitalizationEnabled
665 {
666     _initialCapitalizationEnabled = initialCapitalizationEnabled;
667 }
668
669 - (BOOL)_waitsForPaintAfterViewDidMoveToWindow
670 {
671     return _waitsForPaintAfterViewDidMoveToWindow;
672 }
673
674 - (void)_setWaitsForPaintAfterViewDidMoveToWindow:(BOOL)shouldSynchronize
675 {
676     _waitsForPaintAfterViewDidMoveToWindow = shouldSynchronize;
677 }
678
679 - (BOOL)_isControlledByAutomation
680 {
681     return _controlledByAutomation;
682 }
683
684 - (void)_setControlledByAutomation:(BOOL)controlledByAutomation
685 {
686     _controlledByAutomation = controlledByAutomation;
687 }
688
689 #if PLATFORM(MAC)
690 - (BOOL)_showsURLsInToolTips
691 {
692     return _showsURLsInToolTips;
693 }
694
695 - (void)_setShowsURLsInToolTips:(BOOL)showsURLsInToolTips
696 {
697     _showsURLsInToolTips = showsURLsInToolTips;
698 }
699
700 - (BOOL)_serviceControlsEnabled
701 {
702     return _serviceControlsEnabled;
703 }
704
705 - (void)_setServiceControlsEnabled:(BOOL)serviceControlsEnabled
706 {
707     _serviceControlsEnabled = serviceControlsEnabled;
708 }
709
710 - (BOOL)_imageControlsEnabled
711 {
712     return _imageControlsEnabled;
713 }
714
715 - (void)_setImageControlsEnabled:(BOOL)imageControlsEnabled
716 {
717     _imageControlsEnabled = imageControlsEnabled;
718 }
719
720 - (BOOL)_requiresUserActionForEditingControlsManager
721 {
722     return _requiresUserActionForEditingControlsManager;
723 }
724
725 - (void)_setRequiresUserActionForEditingControlsManager:(BOOL)requiresUserAction
726 {
727     _requiresUserActionForEditingControlsManager = requiresUserAction;
728 }
729
730 #endif // PLATFORM(MAC)
731
732 - (BOOL)_applePayEnabled
733 {
734 #if ENABLE(APPLE_PAY)
735     return _applePayEnabled;
736 #else
737     return NO;
738 #endif
739 }
740
741 - (void)_setApplePayEnabled:(BOOL)applePayEnabled
742 {
743 #if ENABLE(APPLE_PAY)
744     _applePayEnabled = applePayEnabled;
745 #endif
746 }
747
748 - (BOOL)_needsStorageAccessFromFileURLsQuirk
749 {
750     return _needsStorageAccessFromFileURLsQuirk;
751 }
752
753 - (void)_setNeedsStorageAccessFromFileURLsQuirk:(BOOL)needsLocalStorageQuirk
754 {
755     _needsStorageAccessFromFileURLsQuirk = needsLocalStorageQuirk;
756 }
757
758 - (NSString *)_overrideContentSecurityPolicy
759 {
760     return _overrideContentSecurityPolicy;
761 }
762
763 - (void)_setOverrideContentSecurityPolicy:(NSString *)overrideContentSecurityPolicy
764 {
765     _overrideContentSecurityPolicy = overrideContentSecurityPolicy;
766 }
767
768 @end
769
770 @implementation WKWebViewConfiguration (WKDeprecated)
771
772 #if PLATFORM(IOS)
773 - (BOOL)mediaPlaybackAllowsAirPlay
774 {
775     return self.allowsAirPlayForMediaPlayback;
776 }
777
778 - (void)setMediaPlaybackAllowsAirPlay:(BOOL)allowed
779 {
780     self.allowsAirPlayForMediaPlayback = allowed;
781 }
782
783 - (BOOL)mediaPlaybackRequiresUserAction
784 {
785     return self.requiresUserActionForMediaPlayback;
786 }
787
788 - (void)setMediaPlaybackRequiresUserAction:(BOOL)required
789 {
790     self.requiresUserActionForMediaPlayback = required;
791 }
792
793 - (BOOL)requiresUserActionForMediaPlayback
794 {
795     return self.mediaTypesRequiringUserActionForPlayback == WKAudiovisualMediaTypeAll;
796 }
797
798 - (void)setRequiresUserActionForMediaPlayback:(BOOL)requiresUserActionForMediaPlayback
799 {
800     self.mediaTypesRequiringUserActionForPlayback = requiresUserActionForMediaPlayback ? WKAudiovisualMediaTypeAll : WKAudiovisualMediaTypeNone;
801 }
802
803 #endif // PLATFORM(IOS)
804
805 @end
806
807 @implementation WKWebViewConfiguration (WKBinaryCompatibilityWithIOS10)
808
809 -(_WKVisitedLinkStore *)_visitedLinkProvider
810 {
811     return self._visitedLinkStore;
812 }
813
814 - (void)_setVisitedLinkProvider:(_WKVisitedLinkStore *)visitedLinkProvider
815 {
816     self._visitedLinkStore = visitedLinkProvider;
817 }
818
819 @end
820
821 #endif // WK_API_ENABLED