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