OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 // | 136 // |
137 // Note: This method exists only to support backwards compatibility | 137 // Note: This method exists only to support backwards compatibility |
138 // with older versions of WebKit. | 138 // with older versions of WebKit. |
139 void grantLoadLocalResources(); | 139 void grantLoadLocalResources(); |
140 | 140 |
141 // Explicitly grant the ability to access every other SecurityOrigin. | 141 // Explicitly grant the ability to access every other SecurityOrigin. |
142 // | 142 // |
143 // WARNING: This is an extremely powerful ability. Use with caution! | 143 // WARNING: This is an extremely powerful ability. Use with caution! |
144 void grantUniversalAccess(); | 144 void grantUniversalAccess(); |
145 | 145 |
146 bool canAccessDatabase() const { return !isUnique(); }; | 146 bool canAccessDatabase() const { return !isUnique() && !hasSuborigin(); }; |
147 bool canAccessLocalStorage() const { return !isUnique(); }; | 147 bool canAccessLocalStorage() const { return !isUnique() && !hasSuborigin();
}; |
148 bool canAccessSharedWorkers() const { return !isUnique(); } | 148 bool canAccessSharedWorkers() const { return !isUnique() && !hasSuborigin();
} |
149 bool canAccessCookies() const { return !isUnique(); } | 149 bool canAccessCookies() const { return !isUnique() && !hasSuborigin(); } |
150 bool canAccessPasswordManager() const { return !isUnique(); } | 150 bool canAccessPasswordManager() const { return !isUnique() && !hasSuborigin(
); } |
151 bool canAccessFileSystem() const { return !isUnique(); } | 151 bool canAccessFileSystem() const { return !isUnique() && !hasSuborigin(); } |
152 Policy canShowNotifications() const; | 152 Policy canShowNotifications() const; |
153 | 153 |
154 // Technically, we should always allow access to sessionStorage, but we | 154 // Technically, we should always allow access to sessionStorage, but we |
155 // currently don't handle creating a sessionStorage area for unique | 155 // currently don't handle creating a sessionStorage area for unique |
156 // origins. | 156 // origins. |
157 bool canAccessSessionStorage() const { return !isUnique(); } | 157 bool canAccessSessionStorage() const { return !isUnique() && !hasSuborigin()
; } |
158 | 158 |
159 // The local SecurityOrigin is the most privileged SecurityOrigin. | 159 // The local SecurityOrigin is the most privileged SecurityOrigin. |
160 // The local SecurityOrigin can script any document, navigate to local | 160 // The local SecurityOrigin can script any document, navigate to local |
161 // resources, and can set arbitrary headers on XMLHttpRequests. | 161 // resources, and can set arbitrary headers on XMLHttpRequests. |
162 bool isLocal() const; | 162 bool isLocal() const; |
163 | 163 |
164 // Returns true if the host is one of 127.0.0.1/8, ::1/128, or "localhost". | 164 // Returns true if the host is one of 127.0.0.1/8, ::1/128, or "localhost". |
165 bool isLocalhost() const; | 165 bool isLocalhost() const; |
166 | 166 |
167 // The origin is a globally unique identifier assigned when the Document is | 167 // The origin is a globally unique identifier assigned when the Document is |
168 // created. http://www.whatwg.org/specs/web-apps/current-work/#sandboxOrigin | 168 // created. http://www.whatwg.org/specs/web-apps/current-work/#sandboxOrigin |
169 // | 169 // |
170 // There's a subtle difference between a unique origin and an origin that | 170 // There's a subtle difference between a unique origin and an origin that |
171 // has the SandboxOrigin flag set. The latter implies the former, and, in | 171 // has the SandboxOrigin flag set. The latter implies the former, and, in |
172 // addition, the SandboxOrigin flag is inherited by iframes. | 172 // addition, the SandboxOrigin flag is inherited by iframes. |
173 bool isUnique() const { return m_isUnique; } | 173 bool isUnique() const { return m_isUnique; } |
174 | 174 |
| 175 // Assigns a suborigin namespace to the SecurityOrigin. addSuborigin() must |
| 176 // only ever be called once per SecurityOrigin(). If it is called on a |
| 177 // SecurityOrigin that has already had a suborigin assigned, it will hit a |
| 178 // RELEASE_ASSERT(). |
| 179 void addSuborigin(const String&); |
| 180 bool hasSuborigin() const { return !m_suboriginName.isNull(); } |
| 181 const String& suboriginName() const { return m_suboriginName; } |
| 182 |
175 // Marks a file:// origin as being in a domain defined by its path. | 183 // Marks a file:// origin as being in a domain defined by its path. |
176 // FIXME 81578: The naming of this is confusing. Files with restricted acces
s to other local files | 184 // FIXME 81578: The naming of this is confusing. Files with restricted acces
s to other local files |
177 // still can have other privileges that can be remembered, thereby not makin
g them unique. | 185 // still can have other privileges that can be remembered, thereby not makin
g them unique. |
178 void enforceFilePathSeparation(); | 186 void enforceFilePathSeparation(); |
179 | 187 |
180 // Convert this SecurityOrigin into a string. The string | 188 // Convert this SecurityOrigin into a string. The string |
181 // representation of a SecurityOrigin is similar to a URL, except it | 189 // representation of a SecurityOrigin is similar to a URL, except it |
182 // lacks a path component. The string representation does not encode | 190 // lacks a path component. The string representation does not encode |
183 // the value of the SecurityOrigin's domain property. | 191 // the value of the SecurityOrigin's domain property. |
184 // | 192 // |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 explicit SecurityOrigin(const SecurityOrigin*); | 228 explicit SecurityOrigin(const SecurityOrigin*); |
221 | 229 |
222 // FIXME: Rename this function to something more semantic. | 230 // FIXME: Rename this function to something more semantic. |
223 bool passesFileCheck(const SecurityOrigin*) const; | 231 bool passesFileCheck(const SecurityOrigin*) const; |
224 void buildRawString(StringBuilder&) const; | 232 void buildRawString(StringBuilder&) const; |
225 | 233 |
226 String m_protocol; | 234 String m_protocol; |
227 String m_host; | 235 String m_host; |
228 String m_domain; | 236 String m_domain; |
229 String m_filePath; | 237 String m_filePath; |
| 238 String m_suboriginName; |
230 unsigned short m_port; | 239 unsigned short m_port; |
231 bool m_isUnique; | 240 bool m_isUnique; |
232 bool m_universalAccess; | 241 bool m_universalAccess; |
233 bool m_domainWasSetInDOM; | 242 bool m_domainWasSetInDOM; |
234 bool m_canLoadLocalResources; | 243 bool m_canLoadLocalResources; |
235 bool m_enforceFilePathSeparation; | 244 bool m_enforceFilePathSeparation; |
236 bool m_needsDatabaseIdentifierQuirkForFiles; | 245 bool m_needsDatabaseIdentifierQuirkForFiles; |
237 }; | 246 }; |
238 | 247 |
239 } // namespace blink | 248 } // namespace blink |
240 | 249 |
241 #endif // SecurityOrigin_h | 250 #endif // SecurityOrigin_h |
OLD | NEW |