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