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

Side by Side Diff: content/child/site_isolation_policy.h

Issue 425653002: content: ResourceType cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: REBASE Created 6 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/child/site_isolation_policy.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_CHILD_SITE_ISOLATION_POLICY_H_ 5 #ifndef CONTENT_CHILD_SITE_ISOLATION_POLICY_H_
6 #define CONTENT_CHILD_SITE_ISOLATION_POLICY_H_ 6 #define CONTENT_CHILD_SITE_ISOLATION_POLICY_H_
7 7
8 #include <map> 8 #include <map>
9 #include <utility> 9 #include <utility>
10 10
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/memory/linked_ptr.h" 12 #include "base/memory/linked_ptr.h"
13 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "content/public/common/resource_type.h" 15 #include "content/public/common/resource_type.h"
16 16 #include "url/gurl.h"
17 class GURL;
18 17
19 namespace content { 18 namespace content {
20 19
21 struct ResourceResponseInfo; 20 struct ResourceResponseInfo;
22 21
23 // SiteIsolationPolicy implements the cross-site document blocking policy (XSDP) 22 // SiteIsolationPolicy implements the cross-site document blocking policy (XSDP)
24 // for Site Isolation. XSDP will monitor network responses to a renderer and 23 // for Site Isolation. XSDP will monitor network responses to a renderer and
25 // block illegal responses so that a compromised renderer cannot steal private 24 // block illegal responses so that a compromised renderer cannot steal private
26 // information from other sites. For now SiteIsolationPolicy monitors responses 25 // information from other sites. For now SiteIsolationPolicy monitors responses
27 // to gather various UMA stats to see the compatibility impact of actual 26 // to gather various UMA stats to see the compatibility impact of actual
(...skipping 20 matching lines...) Expand all
48 // SiteIsolation.XSD.[%MIMETYPE].NoSniffBlocked.NonRenderableStatusCode : 47 // SiteIsolation.XSD.[%MIMETYPE].NoSniffBlocked.NonRenderableStatusCode :
49 // # of responses failed to be sniffed for its MIME type, but blocked by 48 // # of responses failed to be sniffed for its MIME type, but blocked by
50 // "X-Content-Type-Options: nosniff" header, and with non-renderable status 49 // "X-Content-Type-Options: nosniff" header, and with non-renderable status
51 // code out of SiteIsolation.XSD.[%MIMETYPE].Blocked. 50 // code out of SiteIsolation.XSD.[%MIMETYPE].Blocked.
52 // SiteIsolation.XSD.[%MIMETYPE].NotBlocked : 51 // SiteIsolation.XSD.[%MIMETYPE].NotBlocked :
53 // # of responses, but not blocked due to failure of mime sniffing. 52 // # of responses, but not blocked due to failure of mime sniffing.
54 // SiteIsolation.XSD.[%MIMETYPE].NotBlocked.MaybeJS : 53 // SiteIsolation.XSD.[%MIMETYPE].NotBlocked.MaybeJS :
55 // # of responses that are plausibly sniffed to be JavaScript. 54 // # of responses that are plausibly sniffed to be JavaScript.
56 55
57 struct SiteIsolationResponseMetaData { 56 struct SiteIsolationResponseMetaData {
58
59 enum CanonicalMimeType { 57 enum CanonicalMimeType {
60 HTML = 0, 58 HTML = 0,
61 XML = 1, 59 XML = 1,
62 JSON = 2, 60 JSON = 2,
63 Plain = 3, 61 Plain = 3,
64 Others = 4, 62 Others = 4,
65 MaxCanonicalMimeType, 63 MaxCanonicalMimeType,
66 }; 64 };
67 65
68 SiteIsolationResponseMetaData(); 66 SiteIsolationResponseMetaData();
69 67
70 std::string frame_origin; 68 std::string frame_origin;
71 GURL response_url; 69 GURL response_url;
72 ResourceType::Type resource_type; 70 ResourceType resource_type;
73 CanonicalMimeType canonical_mime_type; 71 CanonicalMimeType canonical_mime_type;
74 int http_status_code; 72 int http_status_code;
75 bool no_sniff; 73 bool no_sniff;
76 }; 74 };
77 75
78 class CONTENT_EXPORT SiteIsolationPolicy { 76 class CONTENT_EXPORT SiteIsolationPolicy {
79 public: 77 public:
80 // Set activation flag for the UMA data collection for this renderer process. 78 // Set activation flag for the UMA data collection for this renderer process.
81 static void SetPolicyEnabled(bool enabled); 79 static void SetPolicyEnabled(bool enabled);
82 80
83 // Returns any bookkeeping data about the HTTP header information for the 81 // Returns any bookkeeping data about the HTTP header information for the
84 // request identified by |request_id|. Any data returned should then be 82 // request identified by |request_id|. Any data returned should then be
85 // passed to ShouldBlockResponse with the first packet. 83 // passed to ShouldBlockResponse with the first packet.
86 static linked_ptr<SiteIsolationResponseMetaData> OnReceivedResponse( 84 static linked_ptr<SiteIsolationResponseMetaData> OnReceivedResponse(
87 const GURL& frame_origin, 85 const GURL& frame_origin,
88 const GURL& response_url, 86 const GURL& response_url,
89 ResourceType::Type resource_type, 87 ResourceType resource_type,
90 int origin_pid, 88 int origin_pid,
91 const ResourceResponseInfo& info); 89 const ResourceResponseInfo& info);
92 90
93 // Examines the first network packet in case response_url is registered as a 91 // Examines the first network packet in case response_url is registered as a
94 // cross-site document by DidReceiveResponse(). In case that this response is 92 // cross-site document by DidReceiveResponse(). In case that this response is
95 // blocked, it returns an alternative data to be sent to the renderer in 93 // blocked, it returns an alternative data to be sent to the renderer in
96 // |alternative_data|. This records various kinds of UMA data stats. This 94 // |alternative_data|. This records various kinds of UMA data stats. This
97 // function is called only if the length of received data is non-zero. 95 // function is called only if the length of received data is non-zero.
98 static bool ShouldBlockResponse( 96 static bool ShouldBlockResponse(
99 linked_ptr<SiteIsolationResponseMetaData>& resp_data, const char* payload, 97 linked_ptr<SiteIsolationResponseMetaData>& resp_data, const char* payload,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 // Never needs to be constructed/destructed. 142 // Never needs to be constructed/destructed.
145 SiteIsolationPolicy() {} 143 SiteIsolationPolicy() {}
146 ~SiteIsolationPolicy() {} 144 ~SiteIsolationPolicy() {}
147 145
148 DISALLOW_COPY_AND_ASSIGN(SiteIsolationPolicy); 146 DISALLOW_COPY_AND_ASSIGN(SiteIsolationPolicy);
149 }; 147 };
150 148
151 } // namespace content 149 } // namespace content
152 150
153 #endif // CONTENT_CHILD_SITE_ISOLATION_POLICY_H_ 151 #endif // CONTENT_CHILD_SITE_ISOLATION_POLICY_H_
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher_unittest.cc ('k') | content/child/site_isolation_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698