Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(89)

Side by Side Diff: sky/engine/platform/weborigin/SchemeRegistry.cpp

Issue 758233004: Remove SchemeRegistry and WebSecurityPolicy. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/platform/weborigin/SchemeRegistry.h ('k') | sky/engine/public/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2010 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. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 *
25 */
26
27 #include "sky/engine/config.h"
28 #include "sky/engine/platform/weborigin/SchemeRegistry.h"
29
30 #include "sky/engine/wtf/MainThread.h"
31 #include "sky/engine/wtf/text/StringBuilder.h"
32
33 namespace blink {
34
35 static URLSchemesMap& localURLSchemes()
36 {
37 DEFINE_STATIC_LOCAL(URLSchemesMap, localSchemes, ());
38
39 if (localSchemes.isEmpty())
40 localSchemes.add("file");
41
42 return localSchemes;
43 }
44
45 static URLSchemesMap& displayIsolatedURLSchemes()
46 {
47 DEFINE_STATIC_LOCAL(URLSchemesMap, displayIsolatedSchemes, ());
48 return displayIsolatedSchemes;
49 }
50
51 static URLSchemesMap& secureSchemes()
52 {
53 DEFINE_STATIC_LOCAL(URLSchemesMap, secureSchemes, ());
54
55 if (secureSchemes.isEmpty()) {
56 secureSchemes.add("https");
57 secureSchemes.add("about");
58 secureSchemes.add("data");
59 secureSchemes.add("wss");
60 }
61
62 return secureSchemes;
63 }
64
65 static URLSchemesMap& schemesWithUniqueOrigins()
66 {
67 DEFINE_STATIC_LOCAL(URLSchemesMap, schemesWithUniqueOrigins, ());
68
69 if (schemesWithUniqueOrigins.isEmpty()) {
70 schemesWithUniqueOrigins.add("about");
71 schemesWithUniqueOrigins.add("javascript");
72 // This is a willful violation of HTML5.
73 // See https://bugs.webkit.org/show_bug.cgi?id=11885
74 schemesWithUniqueOrigins.add("data");
75 }
76
77 return schemesWithUniqueOrigins;
78 }
79
80 static URLSchemesMap& emptyDocumentSchemes()
81 {
82 DEFINE_STATIC_LOCAL(URLSchemesMap, emptyDocumentSchemes, ());
83
84 if (emptyDocumentSchemes.isEmpty())
85 emptyDocumentSchemes.add("about");
86
87 return emptyDocumentSchemes;
88 }
89
90 static HashSet<String>& schemesForbiddenFromDomainRelaxation()
91 {
92 DEFINE_STATIC_LOCAL(HashSet<String>, schemes, ());
93 return schemes;
94 }
95
96 static URLSchemesMap& canDisplayOnlyIfCanRequestSchemes()
97 {
98 DEFINE_STATIC_LOCAL(URLSchemesMap, canDisplayOnlyIfCanRequestSchemes, ());
99
100 if (canDisplayOnlyIfCanRequestSchemes.isEmpty()) {
101 canDisplayOnlyIfCanRequestSchemes.add("blob");
102 canDisplayOnlyIfCanRequestSchemes.add("filesystem");
103 }
104
105 return canDisplayOnlyIfCanRequestSchemes;
106 }
107
108 void SchemeRegistry::registerURLSchemeAsLocal(const String& scheme)
109 {
110 localURLSchemes().add(scheme);
111 }
112
113 void SchemeRegistry::removeURLSchemeRegisteredAsLocal(const String& scheme)
114 {
115 if (scheme == "file")
116 return;
117 localURLSchemes().remove(scheme);
118 }
119
120 const URLSchemesMap& SchemeRegistry::localSchemes()
121 {
122 return localURLSchemes();
123 }
124
125 static URLSchemesMap& CORSEnabledSchemes()
126 {
127 // FIXME: http://bugs.webkit.org/show_bug.cgi?id=77160
128 DEFINE_STATIC_LOCAL(URLSchemesMap, CORSEnabledSchemes, ());
129
130 if (CORSEnabledSchemes.isEmpty()) {
131 CORSEnabledSchemes.add("http");
132 CORSEnabledSchemes.add("https");
133 CORSEnabledSchemes.add("data");
134 }
135
136 return CORSEnabledSchemes;
137 }
138
139 bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
140 {
141 if (scheme.isEmpty())
142 return false;
143 return localURLSchemes().contains(scheme);
144 }
145
146 void SchemeRegistry::registerURLSchemeAsNoAccess(const String& scheme)
147 {
148 schemesWithUniqueOrigins().add(scheme);
149 }
150
151 bool SchemeRegistry::shouldTreatURLSchemeAsNoAccess(const String& scheme)
152 {
153 if (scheme.isEmpty())
154 return false;
155 return schemesWithUniqueOrigins().contains(scheme);
156 }
157
158 void SchemeRegistry::registerURLSchemeAsDisplayIsolated(const String& scheme)
159 {
160 displayIsolatedURLSchemes().add(scheme);
161 }
162
163 bool SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(const String& scheme)
164 {
165 if (scheme.isEmpty())
166 return false;
167 return displayIsolatedURLSchemes().contains(scheme);
168 }
169
170 void SchemeRegistry::registerURLSchemeAsSecure(const String& scheme)
171 {
172 secureSchemes().add(scheme);
173 }
174
175 bool SchemeRegistry::shouldTreatURLSchemeAsSecure(const String& scheme)
176 {
177 if (scheme.isEmpty())
178 return false;
179 return secureSchemes().contains(scheme);
180 }
181
182 void SchemeRegistry::registerURLSchemeAsEmptyDocument(const String& scheme)
183 {
184 emptyDocumentSchemes().add(scheme);
185 }
186
187 bool SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(const String& scheme)
188 {
189 if (scheme.isEmpty())
190 return false;
191 return emptyDocumentSchemes().contains(scheme);
192 }
193
194 void SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(bool forbidden, co nst String& scheme)
195 {
196 if (scheme.isEmpty())
197 return;
198
199 if (forbidden)
200 schemesForbiddenFromDomainRelaxation().add(scheme);
201 else
202 schemesForbiddenFromDomainRelaxation().remove(scheme);
203 }
204
205 bool SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(const String& schem e)
206 {
207 if (scheme.isEmpty())
208 return false;
209 return schemesForbiddenFromDomainRelaxation().contains(scheme);
210 }
211
212 bool SchemeRegistry::canDisplayOnlyIfCanRequest(const String& scheme)
213 {
214 if (scheme.isEmpty())
215 return false;
216 return canDisplayOnlyIfCanRequestSchemes().contains(scheme);
217 }
218
219 void SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest(const String& scheme)
220 {
221 canDisplayOnlyIfCanRequestSchemes().add(scheme);
222 }
223
224 void SchemeRegistry::registerURLSchemeAsCORSEnabled(const String& scheme)
225 {
226 CORSEnabledSchemes().add(scheme);
227 }
228
229 bool SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(const String& scheme)
230 {
231 if (scheme.isEmpty())
232 return false;
233 return CORSEnabledSchemes().contains(scheme);
234 }
235
236 String SchemeRegistry::listOfCORSEnabledURLSchemes()
237 {
238 StringBuilder builder;
239 const URLSchemesMap& corsEnabledSchemes = CORSEnabledSchemes();
240
241 bool addSeparator = false;
242 for (URLSchemesMap::const_iterator it = corsEnabledSchemes.begin(); it != co rsEnabledSchemes.end(); ++it) {
243 if (addSeparator)
244 builder.appendLiteral(", ");
245 else
246 addSeparator = true;
247
248 builder.append(*it);
249 }
250 return builder.toString();
251 }
252
253 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/platform/weborigin/SchemeRegistry.h ('k') | sky/engine/public/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698