Unreviewed, fix iOS build with recent SDKs.
[WebKit-https.git] / Source / WebKit / UIProcess / API / Cocoa / _WKWebsiteDataStoreConfiguration.mm
1 /*
2  * Copyright (C) 2017 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 "_WKWebsiteDataStoreConfigurationInternal.h"
28
29 #import <wtf/RetainPtr.h>
30
31 static void checkURLArgument(NSURL *url)
32 {
33     if (url && ![url isFileURL])
34         [NSException raise:NSInvalidArgumentException format:@"%@ is not a file URL", url];
35 }
36
37 @implementation _WKWebsiteDataStoreConfiguration
38
39 - (NSURL *)_webStorageDirectory
40 {
41     return [NSURL fileURLWithPath:_configuration->webStorageDirectory() isDirectory:YES];
42 }
43
44 - (void)_setWebStorageDirectory:(NSURL *)url
45 {
46     checkURLArgument(url);
47     _configuration->setWebStorageDirectory(url.path);
48 }
49
50 - (NSURL *)_indexedDBDatabaseDirectory
51 {
52     return [NSURL fileURLWithPath:_configuration->indexedDBDatabaseDirectory() isDirectory:YES];
53 }
54
55 - (void)_setIndexedDBDatabaseDirectory:(NSURL *)url
56 {
57     checkURLArgument(url);
58     _configuration->setIndexedDBDatabaseDirectory(url.path);
59 }
60
61 - (NSURL *)_webSQLDatabaseDirectory
62 {
63     return [NSURL fileURLWithPath:_configuration->webSQLDatabaseDirectory() isDirectory:YES];
64 }
65
66 - (void)_setWebSQLDatabaseDirectory:(NSURL *)url
67 {
68     checkURLArgument(url);
69     _configuration->setWebSQLDatabaseDirectory(url.path);
70 }
71
72 - (NSURL *)httpProxy
73 {
74     return _configuration->httpProxy();
75 }
76
77 - (void)setHTTPProxy:(NSURL *)proxy
78 {
79     _configuration->setHTTPProxy(proxy);
80 }
81
82 - (NSURL *)httpsProxy
83 {
84     return _configuration->httpsProxy();
85 }
86
87 - (void)setHTTPSProxy:(NSURL *)proxy
88 {
89     _configuration->setHTTPSProxy(proxy);
90 }
91
92 - (NSURL *)_cookieStorageFile
93 {
94     return [NSURL fileURLWithPath:_configuration->cookieStorageFile() isDirectory:NO];
95 }
96
97 - (void)_setCookieStorageFile:(NSURL *)url
98 {
99     checkURLArgument(url);
100     if ([url hasDirectoryPath])
101         [NSException raise:NSInvalidArgumentException format:@"The cookie storage path must point to a file, not a directory."];
102
103     _configuration->setCookieStorageFile(url.path);
104 }
105
106 - (NSURL *)_resourceLoadStatisticsDirectory
107 {
108     return [NSURL fileURLWithPath:_configuration->resourceLoadStatisticsDirectory() isDirectory:YES];
109 }
110
111 - (void)_setResourceLoadStatisticsDirectory:(NSURL *)url
112 {
113     checkURLArgument(url);
114     _configuration->setResourceLoadStatisticsDirectory(url.path);
115 }
116
117 - (NSURL *)_cacheStorageDirectory
118 {
119     return [NSURL fileURLWithPath:_configuration->cacheStorageDirectory() isDirectory:YES];
120 }
121
122 - (void)_setCacheStorageDirectory:(NSURL *)url
123 {
124     checkURLArgument(url);
125     _configuration->setCacheStorageDirectory(url.path);
126 }
127
128 - (NSURL *)_serviceWorkerRegistrationDirectory
129 {
130     return [NSURL fileURLWithPath:_configuration->serviceWorkerRegistrationDirectory() isDirectory:YES];
131 }
132
133 - (void)_setServiceWorkerRegistrationDirectory:(NSURL *)url
134 {
135     checkURLArgument(url);
136     _configuration->setServiceWorkerRegistrationDirectory(url.path);
137 }
138
139 - (void)setSourceApplicationBundleIdentifier:(NSString *)identifier
140 {
141     _configuration->setSourceApplicationBundleIdentifier(identifier);
142 }
143
144 - (NSString *)sourceApplicationBundleIdentifier
145 {
146     return _configuration->sourceApplicationBundleIdentifier();
147 }
148
149 - (NSString *)sourceApplicationSecondaryIdentifier
150 {
151     return _configuration->sourceApplicationSecondaryIdentifier();
152 }
153
154 - (void)setSourceApplicationSecondaryIdentifier:(NSString *)identifier
155 {
156     _configuration->setSourceApplicationSecondaryIdentifier(identifier);
157 }
158
159 - (API::Object&)_apiObject
160 {
161     return *_configuration;
162 }
163
164 @end