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