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

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

Issue 23842002: Whitelisting exts and plugins from cross-site document blocking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Comments & Coding style are improved. Created 7 years, 3 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 | « content/child/resource_dispatcher.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
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 // # of responses failed to be sniffed for its MIME type, but blocked by 47 // # of responses failed to be sniffed for its MIME type, but blocked by
48 // "X-Content-Type-Options: nosniff" header, and with non-renderable status 48 // "X-Content-Type-Options: nosniff" header, and with non-renderable status
49 // code out of SiteIsolation.XSD.[%MIMETYPE].Blocked. 49 // code out of SiteIsolation.XSD.[%MIMETYPE].Blocked.
50 // SiteIsolation.XSD.[%MIMETYPE].NotBlocked : 50 // SiteIsolation.XSD.[%MIMETYPE].NotBlocked :
51 // # of responses, but not blocked due to failure of mime sniffing. 51 // # of responses, but not blocked due to failure of mime sniffing.
52 // SiteIsolation.XSD.[%MIMETYPE].NotBlocked.MaybeJS : 52 // SiteIsolation.XSD.[%MIMETYPE].NotBlocked.MaybeJS :
53 // # of responses that are plausibly sniffed to be JavaScript. 53 // # of responses that are plausibly sniffed to be JavaScript.
54 54
55 class CONTENT_EXPORT SiteIsolationPolicy { 55 class CONTENT_EXPORT SiteIsolationPolicy {
56 public: 56 public:
57 // Set activation flag for the UMA data collection for this renderer process.
58 static void SetPolicyEnabled(bool enabled);
57 59
58 // Records the bookkeeping data about the HTTP header information for the 60 // Records the bookkeeping data about the HTTP header information for the
59 // request identified by |request_id|. The bookkeeping data is used by 61 // request identified by |request_id|. The bookkeeping data is used by
60 // ShouldBlockResponse. We have to make sure to call OnRequestComplete to free 62 // ShouldBlockResponse. We have to make sure to call OnRequestComplete to free
61 // the bookkeeping data. 63 // the bookkeeping data.
62 static void OnReceivedResponse(int request_id, 64 static void OnReceivedResponse(int request_id,
63 GURL& frame_origin, 65 GURL& frame_origin,
64 GURL& response_url, 66 GURL& response_url,
65 ResourceType::Type resource_type, 67 ResourceType::Type resource_type,
68 int origin_pid,
66 const webkit_glue::ResourceResponseInfo& info); 69 const webkit_glue::ResourceResponseInfo& info);
67 70
68 // Examines the first network packet in case response_url is registered as a 71 // Examines the first network packet in case response_url is registered as a
69 // cross-site document by DidReceiveResponse(). In case that this response is 72 // cross-site document by DidReceiveResponse(). In case that this response is
70 // blocked, it returns an alternative data to be sent to the renderer in 73 // blocked, it returns an alternative data to be sent to the renderer in
71 // |alternative_data|. This records various kinds of UMA data stats. This 74 // |alternative_data|. This records various kinds of UMA data stats. This
72 // function is called only if the length of received data is non-zero. 75 // function is called only if the length of received data is non-zero.
73 static bool ShouldBlockResponse(int request_id, 76 static bool ShouldBlockResponse(int request_id,
74 const char* payload, 77 const char* payload,
75 int length, 78 int length,
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 // Maintain the bookkeeping data between OnReceivedResponse and 163 // Maintain the bookkeeping data between OnReceivedResponse and
161 // OnReceivedData. The key is a request id maintained by ResourceDispatcher. 164 // OnReceivedData. The key is a request id maintained by ResourceDispatcher.
162 static RequestIdToMetaDataMap* GetRequestIdToMetaDataMap(); 165 static RequestIdToMetaDataMap* GetRequestIdToMetaDataMap();
163 166
164 // Maintain the bookkeeping data for OnReceivedData. Blocking decision is made 167 // Maintain the bookkeeping data for OnReceivedData. Blocking decision is made
165 // when OnReceivedData is called for the first time for a request, and the 168 // when OnReceivedData is called for the first time for a request, and the
166 // decision will remain the same for following data. This map maintains the 169 // decision will remain the same for following data. This map maintains the
167 // decision. The key is a request id maintained by ResourceDispatcher. 170 // decision. The key is a request id maintained by ResourceDispatcher.
168 static RequestIdToResultMap* GetRequestIdToResultMap(); 171 static RequestIdToResultMap* GetRequestIdToResultMap();
169 172
173 // This is false by default, but enables UMA logging and cross-site document
174 // blocking.
175 static bool g_policy_enabled;
176
170 // Never needs to be constructed/destructed. 177 // Never needs to be constructed/destructed.
171 SiteIsolationPolicy() {} 178 SiteIsolationPolicy() {}
172 ~SiteIsolationPolicy() {} 179 ~SiteIsolationPolicy() {}
173 180
174 DISALLOW_COPY_AND_ASSIGN(SiteIsolationPolicy); 181 DISALLOW_COPY_AND_ASSIGN(SiteIsolationPolicy);
175 }; 182 };
176 183
177 } // namespace content 184 } // namespace content
178 185
179 #endif // CONTENT_CHILD_SITE_ISOLATION_POLICY_H_ 186 #endif // CONTENT_CHILD_SITE_ISOLATION_POLICY_H_
OLDNEW
« no previous file with comments | « content/child/resource_dispatcher.cc ('k') | content/child/site_isolation_policy.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698