1 | /* |
2 | * Copyright (C) 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 | #pragma once |
27 | |
28 | #include "APIObject.h" |
29 | #include "WebContentMode.h" |
30 | #include "WebsiteAutoplayPolicy.h" |
31 | #include "WebsiteAutoplayQuirk.h" |
32 | #include "WebsiteLegacyOverflowScrollingTouchPolicy.h" |
33 | #include "WebsiteMediaSourcePolicy.h" |
34 | #include "WebsiteMetaViewportPolicy.h" |
35 | #include "WebsitePopUpPolicy.h" |
36 | #include "WebsiteSimulatedMouseEventsDispatchPolicy.h" |
37 | #include <WebCore/CustomHeaderFields.h> |
38 | #include <WebCore/DeviceOrientationOrMotionPermissionState.h> |
39 | #include <WebCore/HTTPHeaderField.h> |
40 | #include <wtf/OptionSet.h> |
41 | #include <wtf/Vector.h> |
42 | |
43 | namespace WebKit { |
44 | struct WebsitePoliciesData; |
45 | } |
46 | |
47 | namespace API { |
48 | |
49 | class WebsiteDataStore; |
50 | |
51 | class WebsitePolicies final : public API::ObjectImpl<API::Object::Type::WebsitePolicies> { |
52 | public: |
53 | static Ref<WebsitePolicies> create() { return adoptRef(*new WebsitePolicies); } |
54 | WebsitePolicies(); |
55 | ~WebsitePolicies(); |
56 | |
57 | Ref<WebsitePolicies> copy() const; |
58 | |
59 | bool contentBlockersEnabled() const { return m_contentBlockersEnabled; } |
60 | void setContentBlockersEnabled(bool enabled) { m_contentBlockersEnabled = enabled; } |
61 | |
62 | OptionSet<WebKit::WebsiteAutoplayQuirk> allowedAutoplayQuirks() const { return m_allowedAutoplayQuirks; } |
63 | void setAllowedAutoplayQuirks(OptionSet<WebKit::WebsiteAutoplayQuirk> quirks) { m_allowedAutoplayQuirks = quirks; } |
64 | |
65 | WebKit::WebsiteAutoplayPolicy autoplayPolicy() const { return m_autoplayPolicy; } |
66 | void setAutoplayPolicy(WebKit::WebsiteAutoplayPolicy policy) { m_autoplayPolicy = policy; } |
67 | |
68 | #if ENABLE(DEVICE_ORIENTATION) |
69 | WebCore::DeviceOrientationOrMotionPermissionState deviceOrientationAndMotionAccessState() const { return m_deviceOrientationAndMotionAccessState; } |
70 | void setDeviceOrientationAndMotionAccessState(WebCore::DeviceOrientationOrMotionPermissionState state) { m_deviceOrientationAndMotionAccessState = state; } |
71 | #endif |
72 | |
73 | const Vector<WebCore::HTTPHeaderField>& () const { return m_legacyCustomHeaderFields; } |
74 | void (Vector<WebCore::HTTPHeaderField>&& fields) { m_legacyCustomHeaderFields = WTFMove(fields); } |
75 | |
76 | const Vector<WebCore::CustomHeaderFields>& () const { return m_customHeaderFields; } |
77 | void (Vector<WebCore::CustomHeaderFields>&& fields) { m_customHeaderFields = WTFMove(fields); } |
78 | |
79 | WebKit::WebsitePopUpPolicy () const { return m_popUpPolicy; } |
80 | void (WebKit::WebsitePopUpPolicy policy) { m_popUpPolicy = policy; } |
81 | |
82 | WebsiteDataStore* websiteDataStore() const { return m_websiteDataStore.get(); } |
83 | void setWebsiteDataStore(RefPtr<WebsiteDataStore>&&); |
84 | |
85 | WebKit::WebsitePoliciesData data(); |
86 | |
87 | void setCustomUserAgent(const WTF::String& customUserAgent) { m_customUserAgent = customUserAgent; } |
88 | const WTF::String& customUserAgent() const { return m_customUserAgent; } |
89 | |
90 | void setCustomJavaScriptUserAgentAsSiteSpecificQuirks(const WTF::String& customUserAgent) { m_customJavaScriptUserAgentAsSiteSpecificQuirks = customUserAgent; } |
91 | const WTF::String& customJavaScriptUserAgentAsSiteSpecificQuirks() const { return m_customJavaScriptUserAgentAsSiteSpecificQuirks; } |
92 | |
93 | void setCustomNavigatorPlatform(const WTF::String& customNavigatorPlatform) { m_customNavigatorPlatform = customNavigatorPlatform; } |
94 | const WTF::String& customNavigatorPlatform() const { return m_customNavigatorPlatform; } |
95 | |
96 | WebKit::WebContentMode preferredContentMode() const { return m_preferredContentMode; } |
97 | void setPreferredContentMode(WebKit::WebContentMode mode) { m_preferredContentMode = mode; } |
98 | |
99 | WebKit::WebsiteMetaViewportPolicy metaViewportPolicy() const { return m_metaViewportPolicy; } |
100 | void setMetaViewportPolicy(WebKit::WebsiteMetaViewportPolicy policy) { m_metaViewportPolicy = policy; } |
101 | |
102 | WebKit::WebsiteMediaSourcePolicy mediaSourcePolicy() const { return m_mediaSourcePolicy; } |
103 | void setMediaSourcePolicy(WebKit::WebsiteMediaSourcePolicy policy) { m_mediaSourcePolicy = policy; } |
104 | |
105 | WebKit::WebsiteSimulatedMouseEventsDispatchPolicy simulatedMouseEventsDispatchPolicy() const { return m_simulatedMouseEventsDispatchPolicy; } |
106 | void setSimulatedMouseEventsDispatchPolicy(WebKit::WebsiteSimulatedMouseEventsDispatchPolicy policy) { m_simulatedMouseEventsDispatchPolicy = policy; } |
107 | |
108 | WebKit::WebsiteLegacyOverflowScrollingTouchPolicy legacyOverflowScrollingTouchPolicy() const { return m_legacyOverflowScrollingTouchPolicy; } |
109 | void setLegacyOverflowScrollingTouchPolicy(WebKit::WebsiteLegacyOverflowScrollingTouchPolicy policy) { m_legacyOverflowScrollingTouchPolicy = policy; } |
110 | |
111 | bool allowSiteSpecificQuirksToOverrideContentMode() const { return m_allowSiteSpecificQuirksToOverrideContentMode; } |
112 | void setAllowSiteSpecificQuirksToOverrideContentMode(bool value) { m_allowSiteSpecificQuirksToOverrideContentMode = value; } |
113 | |
114 | WTF::String applicationNameForDesktopUserAgent() const { return m_applicationNameForDesktopUserAgent; } |
115 | void setApplicationNameForDesktopUserAgent(const WTF::String& applicationName) { m_applicationNameForDesktopUserAgent = applicationName; } |
116 | |
117 | private: |
118 | (bool contentBlockersEnabled, OptionSet<WebKit::WebsiteAutoplayQuirk>, WebKit::WebsiteAutoplayPolicy, Vector<WebCore::HTTPHeaderField>&&, Vector<WebCore::CustomHeaderFields>&&, WebKit::WebsitePopUpPolicy, RefPtr<WebsiteDataStore>&&); |
119 | |
120 | bool m_contentBlockersEnabled { true }; |
121 | OptionSet<WebKit::WebsiteAutoplayQuirk> m_allowedAutoplayQuirks; |
122 | WebKit::WebsiteAutoplayPolicy m_autoplayPolicy { WebKit::WebsiteAutoplayPolicy::Default }; |
123 | #if ENABLE(DEVICE_ORIENTATION) |
124 | WebCore::DeviceOrientationOrMotionPermissionState m_deviceOrientationAndMotionAccessState { WebCore::DeviceOrientationOrMotionPermissionState::Prompt }; |
125 | #endif |
126 | Vector<WebCore::HTTPHeaderField> ; |
127 | Vector<WebCore::CustomHeaderFields> ; |
128 | WebKit::WebsitePopUpPolicy { WebKit::WebsitePopUpPolicy::Default }; |
129 | RefPtr<WebsiteDataStore> m_websiteDataStore; |
130 | WTF::String m_customUserAgent; |
131 | WTF::String m_customJavaScriptUserAgentAsSiteSpecificQuirks; |
132 | WTF::String m_customNavigatorPlatform; |
133 | WebKit::WebContentMode m_preferredContentMode { WebKit::WebContentMode::Recommended }; |
134 | WebKit::WebsiteMetaViewportPolicy m_metaViewportPolicy { WebKit::WebsiteMetaViewportPolicy::Default }; |
135 | WebKit::WebsiteMediaSourcePolicy m_mediaSourcePolicy { WebKit::WebsiteMediaSourcePolicy::Default }; |
136 | WebKit::WebsiteSimulatedMouseEventsDispatchPolicy m_simulatedMouseEventsDispatchPolicy { WebKit::WebsiteSimulatedMouseEventsDispatchPolicy::Default }; |
137 | WebKit::WebsiteLegacyOverflowScrollingTouchPolicy m_legacyOverflowScrollingTouchPolicy { WebKit::WebsiteLegacyOverflowScrollingTouchPolicy::Default }; |
138 | bool m_allowSiteSpecificQuirksToOverrideContentMode { false }; |
139 | WTF::String m_applicationNameForDesktopUserAgent; |
140 | }; |
141 | |
142 | } // namespace API |
143 | |