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

Side by Side Diff: Source/platform/weborigin/SecurityOrigin.h

Issue 1180923003: Add window access checks for Suborigins (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix tests on Windows Created 5 years, 6 months 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 | « Source/core/frame/LocalDOMWindow.cpp ('k') | Source/platform/weborigin/SecurityOrigin.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // own protocol, or, when relevant, on the protocol of its "inner URL" 86 // own protocol, or, when relevant, on the protocol of its "inner URL"
87 // Protocols like blob: and filesystem: fall into this latter category. 87 // Protocols like blob: and filesystem: fall into this latter category.
88 static bool isSecure(const KURL&); 88 static bool isSecure(const KURL&);
89 89
90 // Returns true if this SecurityOrigin can script objects in the given 90 // Returns true if this SecurityOrigin can script objects in the given
91 // SecurityOrigin. For example, call this function before allowing 91 // SecurityOrigin. For example, call this function before allowing
92 // script from one security origin to read or write objects from 92 // script from one security origin to read or write objects from
93 // another SecurityOrigin. 93 // another SecurityOrigin.
94 bool canAccess(const SecurityOrigin*) const; 94 bool canAccess(const SecurityOrigin*) const;
95 95
96 // Same as canAccess, except that it adds an additional check to make sure
97 // that the SecurityOrigins have the same suborigin name. If you're not
98 // familiar with Suborigins, you probably want canAccess() for now.
99 // Suborigins is a spec in progress, and where it should be enforced is
100 // still in flux. See https://crbug.com/336894 for more details.
101 bool canAccessCheckSuborigins(const SecurityOrigin*) const;
102
96 // Returns true if this SecurityOrigin can read content retrieved from 103 // Returns true if this SecurityOrigin can read content retrieved from
97 // the given URL. For example, call this function before issuing 104 // the given URL. For example, call this function before issuing
98 // XMLHttpRequests. 105 // XMLHttpRequests.
99 bool canRequest(const KURL&) const; 106 bool canRequest(const KURL&) const;
100 107
108 // Same as canRequest, except that it adds an additional check to make sure
109 // that the SecurityOrigin does not have a suborigin name. Like with
110 // canAccessCheckSuborigins() above, if you're not familiar with
111 // Suborigins, you probably want canRequest() for now. Suborigins is a spec
112 // in progress, and where it should be enforced is still in flux. See
113 // https://crbug.com/336894 for more details.
114 bool canRequestNoSuborigin(const KURL&) const;
115
101 // Returns true if drawing an image from this URL taints a canvas from 116 // Returns true if drawing an image from this URL taints a canvas from
102 // this security origin. For example, call this function before 117 // this security origin. For example, call this function before
103 // drawing an image onto an HTML canvas element with the drawImage API. 118 // drawing an image onto an HTML canvas element with the drawImage API.
104 bool taintsCanvas(const KURL&) const; 119 bool taintsCanvas(const KURL&) const;
105 120
106 // Returns true if this SecurityOrigin can receive drag content from the 121 // Returns true if this SecurityOrigin can receive drag content from the
107 // initiator. For example, call this function before allowing content to be 122 // initiator. For example, call this function before allowing content to be
108 // dropped onto a target. 123 // dropped onto a target.
109 bool canReceiveDragData(const SecurityOrigin* dragInitiator) const; 124 bool canReceiveDragData(const SecurityOrigin* dragInitiator) const;
110 125
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 AtomicString toAtomicString() const; 214 AtomicString toAtomicString() const;
200 215
201 // Similar to toString(), but does not take into account any factors that 216 // Similar to toString(), but does not take into account any factors that
202 // could make the string return "null". 217 // could make the string return "null".
203 String toRawString() const; 218 String toRawString() const;
204 AtomicString toRawAtomicString() const; 219 AtomicString toRawAtomicString() const;
205 220
206 // This method checks for equality, ignoring the value of document.domain 221 // This method checks for equality, ignoring the value of document.domain
207 // (and whether it was set) but considering the host. It is used for postMes sage. 222 // (and whether it was set) but considering the host. It is used for postMes sage.
208 bool isSameSchemeHostPort(const SecurityOrigin*) const; 223 bool isSameSchemeHostPort(const SecurityOrigin*) const;
224 bool isSameSchemeHostPortAndSuborigin(const SecurityOrigin*) const;
209 225
210 bool needsDatabaseIdentifierQuirkForFiles() const { return m_needsDatabaseId entifierQuirkForFiles; } 226 bool needsDatabaseIdentifierQuirkForFiles() const { return m_needsDatabaseId entifierQuirkForFiles; }
211 227
212 static const KURL& urlWithUniqueSecurityOrigin(); 228 static const KURL& urlWithUniqueSecurityOrigin();
213 229
214 // Transfer origin privileges from another security origin. 230 // Transfer origin privileges from another security origin.
215 // The following privileges are currently copied over: 231 // The following privileges are currently copied over:
216 // 232 //
217 // - Grant universal access. 233 // - Grant universal access.
218 // - Grant loading of local resources. 234 // - Grant loading of local resources.
219 // - Use path-based file:// origins. 235 // - Use path-based file:// origins.
220 // 236 //
221 // Note: It is dangerous to change the privileges of an origin 237 // Note: It is dangerous to change the privileges of an origin
222 // at any other time than during initialization. 238 // at any other time than during initialization.
223 void transferPrivilegesFrom(const SecurityOrigin&); 239 void transferPrivilegesFrom(const SecurityOrigin&);
224 240
225 private: 241 private:
226 // FIXME: After the merge with the Chromium repo, this should be refactored 242 // FIXME: After the merge with the Chromium repo, this should be refactored
227 // to use FRIEND_TEST in base/gtest_prod_util.h. 243 // to use FRIEND_TEST in base/gtest_prod_util.h.
228 friend class SecurityOriginTest; 244 friend class SecurityOriginTest;
229 friend class SecurityOriginTest_Suborigins_Test; 245 friend class SecurityOriginTest_Suborigins_Test;
230 friend class SecurityOriginTest_SuboriginsParsing_Test; 246 friend class SecurityOriginTest_SuboriginsParsing_Test;
247 friend class SecurityOriginTest_SuboriginsIsSameSchemeHostPortAndSuborigin_T est;
231 248
232 SecurityOrigin(); 249 SecurityOrigin();
233 explicit SecurityOrigin(const KURL&); 250 explicit SecurityOrigin(const KURL&);
234 explicit SecurityOrigin(const SecurityOrigin*); 251 explicit SecurityOrigin(const SecurityOrigin*);
235 252
236 // FIXME: Rename this function to something more semantic. 253 // FIXME: Rename this function to something more semantic.
237 bool passesFileCheck(const SecurityOrigin*) const; 254 bool passesFileCheck(const SecurityOrigin*) const;
238 void buildRawString(StringBuilder&) const; 255 void buildRawString(StringBuilder&) const;
239 256
240 static bool deserializeSuboriginAndHost(const String&, String&, String&); 257 static bool deserializeSuboriginAndHost(const String&, String&, String&);
241 258
242 String m_protocol; 259 String m_protocol;
243 String m_host; 260 String m_host;
244 String m_domain; 261 String m_domain;
245 String m_suboriginName; 262 String m_suboriginName;
246 unsigned short m_port; 263 unsigned short m_port;
247 bool m_isUnique; 264 bool m_isUnique;
248 bool m_universalAccess; 265 bool m_universalAccess;
249 bool m_domainWasSetInDOM; 266 bool m_domainWasSetInDOM;
250 bool m_canLoadLocalResources; 267 bool m_canLoadLocalResources;
251 bool m_enforceFilePathSeparation; 268 bool m_enforceFilePathSeparation;
252 bool m_needsDatabaseIdentifierQuirkForFiles; 269 bool m_needsDatabaseIdentifierQuirkForFiles;
253 }; 270 };
254 271
255 } // namespace blink 272 } // namespace blink
256 273
257 #endif // SecurityOrigin_h 274 #endif // SecurityOrigin_h
OLDNEW
« no previous file with comments | « Source/core/frame/LocalDOMWindow.cpp ('k') | Source/platform/weborigin/SecurityOrigin.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698