AX: WKWebView should have API to prevent pinch-to-zoom always being allowed
[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 "_WKVisitedLinkProvider.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 -(_WKVisitedLinkProvider *)_visitedLinkProvider
400 {
401     return (_WKVisitedLinkProvider *)self._visitedLinkStore;
402 }
403
404 - (void)_setVisitedLinkProvider:(_WKVisitedLinkProvider *)_visitedLinkProvider
405 {
406     self._visitedLinkStore = _visitedLinkProvider;
407 }
408
409 #pragma clang diagnostic pop
410
411 #if PLATFORM(IOS)
412 - (WKWebViewContentProviderRegistry *)_contentProviderRegistry
413 {
414     return _contentProviderRegistry.get([] { return adoptNS([[WKWebViewContentProviderRegistry alloc] init]); });
415 }
416
417 - (void)_setContentProviderRegistry:(WKWebViewContentProviderRegistry *)registry
418 {
419     _contentProviderRegistry.set(registry);
420 }
421 #endif
422
423 - (void)_validate
424 {
425     if (!self.processPool)
426         [NSException raise:NSInvalidArgumentException format:@"configuration.processPool is nil"];
427
428     if (!self.preferences)
429         [NSException raise:NSInvalidArgumentException format:@"configuration.preferences is nil"];
430
431     if (!self.userContentController)
432         [NSException raise:NSInvalidArgumentException format:@"configuration.userContentController is nil"];
433
434     if (!self.websiteDataStore)
435         [NSException raise:NSInvalidArgumentException format:@"configuration.websiteDataStore is nil"];
436
437     if (!self._visitedLinkStore)
438         [NSException raise:NSInvalidArgumentException format:@"configuration._visitedLinkStore is nil"];
439
440 #if PLATFORM(IOS)
441     if (!self._contentProviderRegistry)
442         [NSException raise:NSInvalidArgumentException format:@"configuration._contentProviderRegistry is nil"];
443 #endif
444 }
445
446 @end
447
448 @implementation WKWebViewConfiguration (WKPrivate)
449
450 - (WKWebView *)_relatedWebView
451 {
452     return _relatedWebView.getAutoreleased();
453 }
454
455 - (void)_setRelatedWebView:(WKWebView *)relatedWebView
456 {
457     _relatedWebView = relatedWebView;
458 }
459
460 - (WKWebView *)_alternateWebViewForNavigationGestures
461 {
462     return _alternateWebViewForNavigationGestures.getAutoreleased();
463 }
464
465 - (void)_setAlternateWebViewForNavigationGestures:(WKWebView *)alternateView
466 {
467     _alternateWebViewForNavigationGestures = alternateView;
468 }
469
470 - (NSString *)_groupIdentifier
471 {
472     return _groupIdentifier.get();
473 }
474
475 - (void)_setGroupIdentifier:(NSString *)groupIdentifier
476 {
477     _groupIdentifier = groupIdentifier;
478 }
479
480 - (BOOL)_treatsSHA1SignedCertificatesAsInsecure
481 {
482     return _treatsSHA1SignedCertificatesAsInsecure;
483 }
484
485 - (void)_setTreatsSHA1SignedCertificatesAsInsecure:(BOOL)insecure
486 {
487     _treatsSHA1SignedCertificatesAsInsecure = insecure;
488 }
489
490 - (BOOL)_respectsImageOrientation
491 {
492     return _respectsImageOrientation;
493 }
494
495 - (void)_setRespectsImageOrientation:(BOOL)respectsImageOrientation
496 {
497     _respectsImageOrientation = respectsImageOrientation;
498 }
499
500 - (BOOL)_printsBackgrounds
501 {
502     return _printsBackgrounds;
503 }
504
505 - (void)_setPrintsBackgrounds:(BOOL)printsBackgrounds
506 {
507     _printsBackgrounds = printsBackgrounds;
508 }
509
510 - (CGFloat)_incrementalRenderingSuppressionTimeout
511 {
512     return _incrementalRenderingSuppressionTimeout;
513 }
514
515 - (void)_setIncrementalRenderingSuppressionTimeout:(CGFloat)incrementalRenderingSuppressionTimeout
516 {
517     _incrementalRenderingSuppressionTimeout = incrementalRenderingSuppressionTimeout;
518 }
519
520 - (BOOL)_allowsJavaScriptMarkup
521 {
522     return _allowsJavaScriptMarkup;
523 }
524
525 - (void)_setAllowsJavaScriptMarkup:(BOOL)allowsJavaScriptMarkup
526 {
527     _allowsJavaScriptMarkup = allowsJavaScriptMarkup;
528 }
529
530 - (BOOL)_allowUniversalAccessFromFileURLs
531 {
532     return _allowUniversalAccessFromFileURLs;
533 }
534
535 - (void)_setAllowUniversalAccessFromFileURLs:(BOOL)allowUniversalAccessFromFileURLs
536 {
537     _allowUniversalAccessFromFileURLs = allowUniversalAccessFromFileURLs;
538 }
539
540 - (BOOL)_convertsPositionStyleOnCopy
541 {
542     return _convertsPositionStyleOnCopy;
543 }
544
545 - (void)_setConvertsPositionStyleOnCopy:(BOOL)convertsPositionStyleOnCopy
546 {
547     _convertsPositionStyleOnCopy = convertsPositionStyleOnCopy;
548 }
549
550 - (BOOL)_allowsMetaRefresh
551 {
552     return _allowsMetaRefresh;
553 }
554
555 - (void)_setAllowsMetaRefresh:(BOOL)allowsMetaRefresh
556 {
557     _allowsMetaRefresh = allowsMetaRefresh;
558 }
559
560 #if PLATFORM(IOS)
561 - (BOOL)_alwaysRunsAtForegroundPriority
562 {
563     return _alwaysRunsAtForegroundPriority;
564 }
565
566 - (void)_setAlwaysRunsAtForegroundPriority:(BOOL)alwaysRunsAtForegroundPriority
567 {
568     _alwaysRunsAtForegroundPriority = alwaysRunsAtForegroundPriority;
569 }
570
571 - (BOOL)_inlineMediaPlaybackRequiresPlaysInlineAttribute
572 {
573     return _inlineMediaPlaybackRequiresPlaysInlineAttribute;
574 }
575
576 - (void)_setInlineMediaPlaybackRequiresPlaysInlineAttribute:(BOOL)requires
577 {
578     _inlineMediaPlaybackRequiresPlaysInlineAttribute = requires;
579 }
580
581 - (BOOL)_allowsInlineMediaPlaybackAfterFullscreen
582 {
583     return _allowsInlineMediaPlaybackAfterFullscreen;
584 }
585
586 - (void)_setAllowsInlineMediaPlaybackAfterFullscreen:(BOOL)allows
587 {
588     _allowsInlineMediaPlaybackAfterFullscreen = allows;
589 }
590 #endif // PLATFORM(IOS)
591
592 - (BOOL)_invisibleAutoplayNotPermitted
593 {
594     return _invisibleAutoplayNotPermitted;
595 }
596
597 - (void)_setInvisibleAutoplayNotPermitted:(BOOL)notPermitted
598 {
599     _invisibleAutoplayNotPermitted = notPermitted;
600 }
601
602 - (BOOL)_mediaDataLoadsAutomatically
603 {
604     return _mediaDataLoadsAutomatically;
605 }
606
607 - (void)_setMediaDataLoadsAutomatically:(BOOL)mediaDataLoadsAutomatically
608 {
609     _mediaDataLoadsAutomatically = mediaDataLoadsAutomatically;
610 }
611
612 - (BOOL)_attachmentElementEnabled
613 {
614     return _attachmentElementEnabled;
615 }
616
617 - (void)_setAttachmentElementEnabled:(BOOL)attachmentElementEnabled
618 {
619     _attachmentElementEnabled = attachmentElementEnabled;
620 }
621
622 - (BOOL)_requiresUserActionForVideoPlayback
623 {
624     return self.mediaTypesRequiringUserActionForPlayback & WKAudiovisualMediaTypeVideo;
625 }
626
627 - (void)_setRequiresUserActionForVideoPlayback:(BOOL)requiresUserActionForVideoPlayback
628 {
629     if (requiresUserActionForVideoPlayback)
630         self.mediaTypesRequiringUserActionForPlayback |= WKAudiovisualMediaTypeVideo;
631     else
632         self.mediaTypesRequiringUserActionForPlayback &= ~WKAudiovisualMediaTypeVideo;
633 }
634
635 - (BOOL)_requiresUserActionForAudioPlayback
636 {
637     return self.mediaTypesRequiringUserActionForPlayback & WKAudiovisualMediaTypeAudio;
638 }
639
640 - (void)_setRequiresUserActionForAudioPlayback:(BOOL)requiresUserActionForAudioPlayback
641 {
642     if (requiresUserActionForAudioPlayback)
643         self.mediaTypesRequiringUserActionForPlayback |= WKAudiovisualMediaTypeAudio;
644     else
645         self.mediaTypesRequiringUserActionForPlayback &= ~WKAudiovisualMediaTypeAudio;
646 }
647
648 - (BOOL)_mainContentUserGestureOverrideEnabled
649 {
650     return _mainContentUserGestureOverrideEnabled;
651 }
652
653 - (void)_setMainContentUserGestureOverrideEnabled:(BOOL)mainContentUserGestureOverrideEnabled
654 {
655     _mainContentUserGestureOverrideEnabled = mainContentUserGestureOverrideEnabled;
656 }
657
658 - (BOOL)_initialCapitalizationEnabled
659 {
660     return _initialCapitalizationEnabled;
661 }
662
663 - (void)_setInitialCapitalizationEnabled:(BOOL)initialCapitalizationEnabled
664 {
665     _initialCapitalizationEnabled = initialCapitalizationEnabled;
666 }
667
668 #if PLATFORM(MAC)
669 - (BOOL)_showsURLsInToolTips
670 {
671     return _showsURLsInToolTips;
672 }
673
674 - (void)_setShowsURLsInToolTips:(BOOL)showsURLsInToolTips
675 {
676     _showsURLsInToolTips = showsURLsInToolTips;
677 }
678
679 - (BOOL)_serviceControlsEnabled
680 {
681     return _serviceControlsEnabled;
682 }
683
684 - (void)_setServiceControlsEnabled:(BOOL)serviceControlsEnabled
685 {
686     _serviceControlsEnabled = serviceControlsEnabled;
687 }
688
689 - (BOOL)_imageControlsEnabled
690 {
691     return _imageControlsEnabled;
692 }
693
694 - (void)_setImageControlsEnabled:(BOOL)imageControlsEnabled
695 {
696     _imageControlsEnabled = imageControlsEnabled;
697 }
698
699 - (BOOL)_requiresUserActionForEditingControlsManager
700 {
701     return _requiresUserActionForEditingControlsManager;
702 }
703
704 - (void)_setRequiresUserActionForEditingControlsManager:(BOOL)requiresUserAction
705 {
706     _requiresUserActionForEditingControlsManager = requiresUserAction;
707 }
708
709 #endif // PLATFORM(MAC)
710
711 - (BOOL)_applePayEnabled
712 {
713 #if ENABLE(APPLE_PAY)
714     return _applePayEnabled;
715 #else
716     return NO;
717 #endif
718 }
719
720 - (void)_setApplePayEnabled:(BOOL)applePayEnabled
721 {
722 #if ENABLE(APPLE_PAY)
723     _applePayEnabled = applePayEnabled;
724 #endif
725 }
726
727 - (BOOL)_paymentsEnabled
728 {
729     return self._applePayEnabled;
730 }
731
732 - (void)_setPaymentsEnabled:(BOOL)paymentsEnabled
733 {
734     [self _setApplePayEnabled:paymentsEnabled];
735 }
736
737 @end
738
739 @implementation WKWebViewConfiguration (WKDeprecated)
740
741 #if PLATFORM(IOS)
742 - (BOOL)mediaPlaybackAllowsAirPlay
743 {
744     return self.allowsAirPlayForMediaPlayback;
745 }
746
747 - (void)setMediaPlaybackAllowsAirPlay:(BOOL)allowed
748 {
749     self.allowsAirPlayForMediaPlayback = allowed;
750 }
751
752 - (BOOL)mediaPlaybackRequiresUserAction
753 {
754     return self.requiresUserActionForMediaPlayback;
755 }
756
757 - (void)setMediaPlaybackRequiresUserAction:(BOOL)required
758 {
759     self.requiresUserActionForMediaPlayback = required;
760 }
761
762 - (BOOL)requiresUserActionForMediaPlayback
763 {
764     return self.mediaTypesRequiringUserActionForPlayback == WKAudiovisualMediaTypeAll;
765 }
766
767 - (void)setRequiresUserActionForMediaPlayback:(BOOL)requiresUserActionForMediaPlayback
768 {
769     self.mediaTypesRequiringUserActionForPlayback = requiresUserActionForMediaPlayback ? WKAudiovisualMediaTypeAll : WKAudiovisualMediaTypeNone;
770 }
771
772 #endif // PLATFORM(IOS)
773
774 @end
775
776 #endif // WK_API_ENABLED