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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 23 matching lines...) Expand all Loading... |
208 // | 216 // |
209 // - Grant universal access. | 217 // - Grant universal access. |
210 // - Grant loading of local resources. | 218 // - Grant loading of local resources. |
211 // - Use path-based file:// origins. | 219 // - Use path-based file:// origins. |
212 // | 220 // |
213 // Note: It is dangerous to change the privileges of an origin | 221 // Note: It is dangerous to change the privileges of an origin |
214 // at any other time than during initialization. | 222 // at any other time than during initialization. |
215 void transferPrivilegesFrom(const SecurityOrigin&); | 223 void transferPrivilegesFrom(const SecurityOrigin&); |
216 | 224 |
217 private: | 225 private: |
| 226 // FIXME: After the merge with the Chromium repo, this should be refactored |
| 227 // to use FRIEND_TEST in base/gtest_prod_util.h. |
| 228 friend class SecurityOriginTest; |
| 229 friend class SecurityOriginTest_Suborigins_Test; |
| 230 friend class SecurityOriginTest_SuboriginsParsing_Test; |
| 231 |
218 SecurityOrigin(); | 232 SecurityOrigin(); |
219 explicit SecurityOrigin(const KURL&); | 233 explicit SecurityOrigin(const KURL&); |
220 explicit SecurityOrigin(const SecurityOrigin*); | 234 explicit SecurityOrigin(const SecurityOrigin*); |
221 | 235 |
222 // FIXME: Rename this function to something more semantic. | 236 // FIXME: Rename this function to something more semantic. |
223 bool passesFileCheck(const SecurityOrigin*) const; | 237 bool passesFileCheck(const SecurityOrigin*) const; |
224 void buildRawString(StringBuilder&) const; | 238 void buildRawString(StringBuilder&) const; |
225 | 239 |
| 240 static bool deserializeSuboriginAndHost(const String&, String&, String&); |
| 241 |
226 String m_protocol; | 242 String m_protocol; |
227 String m_host; | 243 String m_host; |
228 String m_domain; | 244 String m_domain; |
| 245 String m_suboriginName; |
229 unsigned short m_port; | 246 unsigned short m_port; |
230 bool m_isUnique; | 247 bool m_isUnique; |
231 bool m_universalAccess; | 248 bool m_universalAccess; |
232 bool m_domainWasSetInDOM; | 249 bool m_domainWasSetInDOM; |
233 bool m_canLoadLocalResources; | 250 bool m_canLoadLocalResources; |
234 bool m_enforceFilePathSeparation; | 251 bool m_enforceFilePathSeparation; |
235 bool m_needsDatabaseIdentifierQuirkForFiles; | 252 bool m_needsDatabaseIdentifierQuirkForFiles; |
236 }; | 253 }; |
237 | 254 |
238 } // namespace blink | 255 } // namespace blink |
239 | 256 |
240 #endif // SecurityOrigin_h | 257 #endif // SecurityOrigin_h |
OLD | NEW |