| 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 #include "content/child/site_isolation_policy.h" | 5 #include "content/child/site_isolation_policy.h" |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 void HistogramCountNotBlockedResponse(const std::string& bucket_prefix, | 154 void HistogramCountNotBlockedResponse(const std::string& bucket_prefix, |
| 155 bool sniffed_as_js) { | 155 bool sniffed_as_js) { |
| 156 IncrementHistogramCount(bucket_prefix + ".NotBlocked"); | 156 IncrementHistogramCount(bucket_prefix + ".NotBlocked"); |
| 157 if (sniffed_as_js) | 157 if (sniffed_as_js) |
| 158 IncrementHistogramCount(bucket_prefix + ".NotBlocked.MaybeJS"); | 158 IncrementHistogramCount(bucket_prefix + ".NotBlocked.MaybeJS"); |
| 159 } | 159 } |
| 160 | 160 |
| 161 void HistogramCountPolicyDecision( | |
| 162 const std::string& bucket_prefix, | |
| 163 bool sniffed_as_document, | |
| 164 bool sniffed_as_js, | |
| 165 const SiteIsolationPolicy::ResponseMetaData& resp_data) { | |
| 166 if (sniffed_as_document) { | |
| 167 HistogramCountBlockedResponse(bucket_prefix, resp_data, false); | |
| 168 } else { | |
| 169 if (resp_data.no_sniff) | |
| 170 HistogramCountBlockedResponse(bucket_prefix, resp_data, true); | |
| 171 else | |
| 172 HistogramCountNotBlockedResponse(bucket_prefix, sniffed_as_js); | |
| 173 } | |
| 174 } | |
| 175 | |
| 176 } // namespace | 161 } // namespace |
| 177 | 162 |
| 178 SiteIsolationPolicy::ResponseMetaData::ResponseMetaData() {} | 163 SiteIsolationPolicy::ResponseMetaData::ResponseMetaData() {} |
| 179 | 164 |
| 180 void SiteIsolationPolicy::SetPolicyEnabled(bool enabled) { | 165 void SiteIsolationPolicy::SetPolicyEnabled(bool enabled) { |
| 181 g_policy_enabled = enabled; | 166 g_policy_enabled = enabled; |
| 182 } | 167 } |
| 183 | 168 |
| 184 void SiteIsolationPolicy::OnReceivedResponse( | 169 void SiteIsolationPolicy::OnReceivedResponse( |
| 185 int request_id, | 170 int request_id, |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 // TODO(dsjang): This is a real hack. The only purpose of this function is to | 569 // TODO(dsjang): This is a real hack. The only purpose of this function is to |
| 585 // try to see if there's any possibility that this data can be JavaScript | 570 // try to see if there's any possibility that this data can be JavaScript |
| 586 // (superset of JS). This function will be removed once UMA stats are | 571 // (superset of JS). This function will be removed once UMA stats are |
| 587 // gathered. | 572 // gathered. |
| 588 | 573 |
| 589 // Search for "var " for JS detection. | 574 // Search for "var " for JS detection. |
| 590 return data.find("var ") != base::StringPiece::npos; | 575 return data.find("var ") != base::StringPiece::npos; |
| 591 } | 576 } |
| 592 | 577 |
| 593 } // namespace content | 578 } // namespace content |
| OLD | NEW |