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

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

Issue 27073003: CSP Suborigins Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address abarth's comments Created 6 years, 2 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
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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(); };
Mike West 2014/10/23 12:59:20 Why are we blocking access to these for suborigins
jww 2015/03/20 22:50:03 The proposal/initial spec calls for these sensitiv
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(); }
Mike West 2014/10/23 12:59:20 Here too?
jww 2015/03/20 22:50:04 Yup, good catch. Rebase mistake, I think.
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 void addSuborigin(const String&);
176 bool hasSuborigin() const { return !m_suboriginName.isNull(); }
177 const String& suboriginName() const { return m_suboriginName; }
178
175 // Marks a file:// origin as being in a domain defined by its path. 179 // 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 180 // 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. 181 // still can have other privileges that can be remembered, thereby not makin g them unique.
178 void enforceFilePathSeparation(); 182 void enforceFilePathSeparation();
179 183
180 // Convert this SecurityOrigin into a string. The string 184 // Convert this SecurityOrigin into a string. The string
181 // representation of a SecurityOrigin is similar to a URL, except it 185 // representation of a SecurityOrigin is similar to a URL, except it
182 // lacks a path component. The string representation does not encode 186 // lacks a path component. The string representation does not encode
183 // the value of the SecurityOrigin's domain property. 187 // the value of the SecurityOrigin's domain property.
184 // 188 //
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 explicit SecurityOrigin(const SecurityOrigin*); 224 explicit SecurityOrigin(const SecurityOrigin*);
221 225
222 // FIXME: Rename this function to something more semantic. 226 // FIXME: Rename this function to something more semantic.
223 bool passesFileCheck(const SecurityOrigin*) const; 227 bool passesFileCheck(const SecurityOrigin*) const;
224 void buildRawString(StringBuilder&) const; 228 void buildRawString(StringBuilder&) const;
225 229
226 String m_protocol; 230 String m_protocol;
227 String m_host; 231 String m_host;
228 String m_domain; 232 String m_domain;
229 String m_filePath; 233 String m_filePath;
234 String m_suboriginName;
230 unsigned short m_port; 235 unsigned short m_port;
231 bool m_isUnique; 236 bool m_isUnique;
232 bool m_universalAccess; 237 bool m_universalAccess;
233 bool m_domainWasSetInDOM; 238 bool m_domainWasSetInDOM;
234 bool m_canLoadLocalResources; 239 bool m_canLoadLocalResources;
235 bool m_enforceFilePathSeparation; 240 bool m_enforceFilePathSeparation;
236 bool m_needsDatabaseIdentifierQuirkForFiles; 241 bool m_needsDatabaseIdentifierQuirkForFiles;
237 }; 242 };
238 243
239 } // namespace blink 244 } // namespace blink
240 245
241 #endif // SecurityOrigin_h 246 #endif // SecurityOrigin_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698