OLD | NEW |
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 "webkit/common/resource_type.h" | 15 #include "webkit/common/resource_type.h" |
16 | 16 |
17 class GURL; | 17 class GURL; |
18 | 18 |
19 namespace webkit_glue { | 19 namespace content { |
| 20 |
20 struct ResourceResponseInfo; | 21 struct ResourceResponseInfo; |
21 } | |
22 | |
23 namespace content { | |
24 | 22 |
25 // SiteIsolationPolicy implements the cross-site document blocking policy (XSDP) | 23 // SiteIsolationPolicy implements the cross-site document blocking policy (XSDP) |
26 // for Site Isolation. XSDP will monitor network responses to a renderer and | 24 // for Site Isolation. XSDP will monitor network responses to a renderer and |
27 // block illegal responses so that a compromised renderer cannot steal private | 25 // block illegal responses so that a compromised renderer cannot steal private |
28 // information from other sites. For now SiteIsolationPolicy monitors responses | 26 // information from other sites. For now SiteIsolationPolicy monitors responses |
29 // to gather various UMA stats to see the compatibility impact of actual | 27 // to gather various UMA stats to see the compatibility impact of actual |
30 // deployment of the policy. The UMA stat categories SiteIsolationPolicy gathers | 28 // deployment of the policy. The UMA stat categories SiteIsolationPolicy gathers |
31 // are as follows: | 29 // are as follows: |
32 // | 30 // |
33 // SiteIsolation.AllResponses : # of all network responses. | 31 // SiteIsolation.AllResponses : # of all network responses. |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
79 | 77 |
80 class CONTENT_EXPORT SiteIsolationPolicy { | 78 class CONTENT_EXPORT SiteIsolationPolicy { |
81 public: | 79 public: |
82 // Set activation flag for the UMA data collection for this renderer process. | 80 // Set activation flag for the UMA data collection for this renderer process. |
83 static void SetPolicyEnabled(bool enabled); | 81 static void SetPolicyEnabled(bool enabled); |
84 | 82 |
85 // Returns any bookkeeping data about the HTTP header information for the | 83 // Returns any bookkeeping data about the HTTP header information for the |
86 // request identified by |request_id|. Any data returned should then be | 84 // request identified by |request_id|. Any data returned should then be |
87 // passed to ShouldBlockResponse with the first packet. | 85 // passed to ShouldBlockResponse with the first packet. |
88 static linked_ptr<SiteIsolationResponseMetaData> OnReceivedResponse( | 86 static linked_ptr<SiteIsolationResponseMetaData> OnReceivedResponse( |
89 const GURL& frame_origin, const GURL& response_url, | 87 const GURL& frame_origin, |
90 ResourceType::Type resource_type, int origin_pid, | 88 const GURL& response_url, |
91 const webkit_glue::ResourceResponseInfo& info); | 89 ResourceType::Type resource_type, |
| 90 int origin_pid, |
| 91 const ResourceResponseInfo& info); |
92 | 92 |
93 // Examines the first network packet in case response_url is registered as a | 93 // 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 | 94 // 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 | 95 // 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 | 96 // |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. | 97 // function is called only if the length of received data is non-zero. |
98 static bool ShouldBlockResponse( | 98 static bool ShouldBlockResponse( |
99 linked_ptr<SiteIsolationResponseMetaData>& resp_data, const char* payload, | 99 linked_ptr<SiteIsolationResponseMetaData>& resp_data, const char* payload, |
100 int length, std::string* alternative_data); | 100 int length, std::string* alternative_data); |
101 | 101 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // Never needs to be constructed/destructed. | 144 // Never needs to be constructed/destructed. |
145 SiteIsolationPolicy() {} | 145 SiteIsolationPolicy() {} |
146 ~SiteIsolationPolicy() {} | 146 ~SiteIsolationPolicy() {} |
147 | 147 |
148 DISALLOW_COPY_AND_ASSIGN(SiteIsolationPolicy); | 148 DISALLOW_COPY_AND_ASSIGN(SiteIsolationPolicy); |
149 }; | 149 }; |
150 | 150 |
151 } // namespace content | 151 } // namespace content |
152 | 152 |
153 #endif // CONTENT_CHILD_SITE_ISOLATION_POLICY_H_ | 153 #endif // CONTENT_CHILD_SITE_ISOLATION_POLICY_H_ |
OLD | NEW |