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