2 * Copyright (C) 2014 Apple Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
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.
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.
27 #import "WKPreferencesInternal.h"
31 #import "WebPreferences.h"
32 #import <WebCore/SecurityOrigin.h>
33 #import <wtf/RetainPtr.h>
35 @implementation WKPreferences
39 if (!(self = [super init]))
42 _preferences = WebKit::WebPreferences::create(String(), "WebKit", "WebKit");
46 - (CGFloat)minimumFontSize
48 return _preferences->minimumFontSize();
51 - (void)setMinimumFontSize:(CGFloat)minimumFontSize
53 _preferences->setMinimumFontSize(minimumFontSize);
56 - (BOOL)javaScriptEnabled
58 return _preferences->javaScriptEnabled();
61 - (void)setJavaScriptEnabled:(BOOL)javaScriptEnabled
63 _preferences->setJavaScriptEnabled(javaScriptEnabled);
66 - (BOOL)javaScriptCanOpenWindowsAutomatically
68 return _preferences->javaScriptCanOpenWindowsAutomatically();
71 - (void)setJavaScriptCanOpenWindowsAutomatically:(BOOL)javaScriptCanOpenWindowsAutomatically
73 _preferences->setJavaScriptCanOpenWindowsAutomatically(javaScriptCanOpenWindowsAutomatically);
76 #pragma mark OS X-specific methods
82 return _preferences->javaEnabled();
85 - (void)setJavaEnabled:(BOOL)javaEnabled
87 _preferences->setJavaEnabled(javaEnabled);
90 - (BOOL)plugInsEnabled
92 return _preferences->pluginsEnabled();
95 - (void)setPlugInsEnabled:(BOOL)plugInsEnabled
97 _preferences->setPluginsEnabled(plugInsEnabled);
104 @implementation WKPreferences (WKPrivate)
106 - (BOOL)_telephoneNumberDetectionIsEnabled
108 return _preferences->telephoneNumberParsingEnabled();
111 - (void)_setTelephoneNumberDetectionIsEnabled:(BOOL)telephoneNumberDetectionIsEnabled
113 _preferences->setTelephoneNumberParsingEnabled(telephoneNumberDetectionIsEnabled);
116 static WebCore::SecurityOrigin::StorageBlockingPolicy toStorageBlockingPolicy(_WKStorageBlockingPolicy policy)
119 case _WKStorageBlockingPolicyAllowAll:
120 return WebCore::SecurityOrigin::AllowAllStorage;
121 case _WKStorageBlockingPolicyBlockThirdParty:
122 return WebCore::SecurityOrigin::BlockThirdPartyStorage;
123 case _WKStorageBlockingPolicyBlockAll:
124 return WebCore::SecurityOrigin::BlockAllStorage;
127 ASSERT_NOT_REACHED();
128 return WebCore::SecurityOrigin::AllowAllStorage;
131 static _WKStorageBlockingPolicy toAPI(WebCore::SecurityOrigin::StorageBlockingPolicy policy)
134 case WebCore::SecurityOrigin::AllowAllStorage:
135 return _WKStorageBlockingPolicyAllowAll;
136 case WebCore::SecurityOrigin::BlockThirdPartyStorage:
137 return _WKStorageBlockingPolicyBlockThirdParty;
138 case WebCore::SecurityOrigin::BlockAllStorage:
139 return _WKStorageBlockingPolicyBlockAll;
142 ASSERT_NOT_REACHED();
143 return _WKStorageBlockingPolicyAllowAll;
146 - (_WKStorageBlockingPolicy)_storageBlockingPolicy
148 return toAPI(static_cast<WebCore::SecurityOrigin::StorageBlockingPolicy>(_preferences->storageBlockingPolicy()));
151 - (void)_setStorageBlockingPolicy:(_WKStorageBlockingPolicy)policy
153 _preferences->setStorageBlockingPolicy(toStorageBlockingPolicy(policy));
156 - (BOOL)_offlineApplicationCacheIsEnabled
158 return _preferences->offlineWebApplicationCacheEnabled();
161 - (void)_setOfflineApplicationCacheIsEnabled:(BOOL)offlineApplicationCacheIsEnabled
163 _preferences->setOfflineWebApplicationCacheEnabled(offlineApplicationCacheIsEnabled);
166 - (BOOL)_compositingBordersVisible
168 return _preferences->compositingBordersVisible();
171 - (void)_setCompositingBordersVisible:(BOOL)compositingBordersVisible
173 _preferences->setCompositingBordersVisible(compositingBordersVisible);
176 - (BOOL)_compositingRepaintCountersVisible
178 return _preferences->compositingRepaintCountersVisible();
181 - (void)_setCompositingRepaintCountersVisible:(BOOL)repaintCountersVisible
183 _preferences->setCompositingRepaintCountersVisible(repaintCountersVisible);
186 - (BOOL)_tiledScrollingIndicatorVisible
188 return _preferences->tiledScrollingIndicatorVisible();
191 - (void)_setTiledScrollingIndicatorVisible:(BOOL)tiledScrollingIndicatorVisible
193 _preferences->setTiledScrollingIndicatorVisible(tiledScrollingIndicatorVisible);
198 #endif // WK_API_ENABLED