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

Side by Side Diff: content/common/cross_site_document_classifier.h

Issue 2568133007: Allow CrossSiteDocumentClassifier to operate on Origins (Closed)
Patch Set: pkasting review Created 3 years, 11 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_COMMON_CROSS_SITE_DOCUMENT_CLASSIFIER_H_ 5 #ifndef CONTENT_COMMON_CROSS_SITE_DOCUMENT_CLASSIFIER_H_
6 #define CONTENT_COMMON_CROSS_SITE_DOCUMENT_CLASSIFIER_H_ 6 #define CONTENT_COMMON_CROSS_SITE_DOCUMENT_CLASSIFIER_H_
7 7
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/strings/string_piece.h" 9 #include "base/strings/string_piece.h"
10 #include "content/common/content_export.h" 10 #include "content/common/content_export.h"
11 #include "url/gurl.h" 11 #include "url/gurl.h"
12 #include "url/origin.h"
12 13
13 namespace content { 14 namespace content {
14 15
15 // CrossSiteDocumentClassifier implements the cross-site document blocking 16 // CrossSiteDocumentClassifier implements the cross-site document blocking
16 // policy (XSDP) for Site Isolation. XSDP will monitor network responses to a 17 // policy (XSDP) for Site Isolation. XSDP will monitor network responses to a
17 // renderer and block illegal responses so that a compromised renderer cannot 18 // renderer and block illegal responses so that a compromised renderer cannot
18 // steal private information from other sites. 19 // steal private information from other sites.
19 20
20 enum CrossSiteDocumentMimeType { 21 enum CrossSiteDocumentMimeType {
21 // Note that these values are used in histograms, and must not change. 22 // Note that these values are used in histograms, and must not change.
(...skipping 11 matching lines...) Expand all
33 // response. For example, this returns the same value for all text/xml mime 34 // response. For example, this returns the same value for all text/xml mime
34 // type families such as application/xml, application/rss+xml. 35 // type families such as application/xml, application/rss+xml.
35 static CrossSiteDocumentMimeType GetCanonicalMimeType( 36 static CrossSiteDocumentMimeType GetCanonicalMimeType(
36 const std::string& mime_type); 37 const std::string& mime_type);
37 38
38 // Returns whether this scheme is a target of cross-site document 39 // Returns whether this scheme is a target of cross-site document
39 // policy(XSDP). This returns true only for http://* and https://* urls. 40 // policy(XSDP). This returns true only for http://* and https://* urls.
40 static bool IsBlockableScheme(const GURL& frame_origin); 41 static bool IsBlockableScheme(const GURL& frame_origin);
41 42
42 // Returns whether the two urls belong to the same sites. 43 // Returns whether the two urls belong to the same sites.
43 static bool IsSameSite(const GURL& frame_origin, const GURL& response_url); 44 static bool IsSameSite(const url::Origin& frame_origin,
45 const GURL& response_url);
44 46
45 // Returns whether there's a valid CORS header for frame_origin. This is 47 // Returns whether there's a valid CORS header for frame_origin. This is
46 // simliar to CrossOriginAccessControl::passesAccessControlCheck(), but we use 48 // simliar to CrossOriginAccessControl::passesAccessControlCheck(), but we use
47 // sites as our security domain, not origins. 49 // sites as our security domain, not origins.
48 // TODO(dsjang): this must be improved to be more accurate to the actual CORS 50 // TODO(dsjang): this must be improved to be more accurate to the actual CORS
49 // specification. For now, this works conservatively, allowing XSDs that are 51 // specification. For now, this works conservatively, allowing XSDs that are
50 // not allowed by actual CORS rules by ignoring 1) credentials and 2) 52 // not allowed by actual CORS rules by ignoring 1) credentials and 2)
51 // methods. Preflight requests don't matter here since they are not used to 53 // methods. Preflight requests don't matter here since they are not used to
52 // decide whether to block a document or not on the client side. 54 // decide whether to block a document or not on the client side.
53 static bool IsValidCorsHeaderSet(const GURL& frame_origin, 55 static bool IsValidCorsHeaderSet(const url::Origin& frame_origin,
54 const GURL& website_origin, 56 const GURL& website_origin,
55 const std::string& access_control_origin); 57 const std::string& access_control_origin);
56 58
57 static bool SniffForHTML(base::StringPiece data); 59 static bool SniffForHTML(base::StringPiece data);
58 static bool SniffForXML(base::StringPiece data); 60 static bool SniffForXML(base::StringPiece data);
59 static bool SniffForJSON(base::StringPiece data); 61 static bool SniffForJSON(base::StringPiece data);
60 62
61 private: 63 private:
62 CrossSiteDocumentClassifier(); // Not instantiable. 64 CrossSiteDocumentClassifier(); // Not instantiable.
63 65
64 DISALLOW_COPY_AND_ASSIGN(CrossSiteDocumentClassifier); 66 DISALLOW_COPY_AND_ASSIGN(CrossSiteDocumentClassifier);
65 }; 67 };
66 68
67 } // namespace content 69 } // namespace content
68 70
69 #endif // CONTENT_COMMON_CROSS_SITE_DOCUMENT_CLASSIFIER_H_ 71 #endif // CONTENT_COMMON_CROSS_SITE_DOCUMENT_CLASSIFIER_H_
OLDNEW
« no previous file with comments | « content/child/site_isolation_stats_gatherer.cc ('k') | content/common/cross_site_document_classifier.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698