OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_d
etector.h" | 5 #include "chrome/browser/safe_browsing/incident_reporting/off_domain_inclusion_d
etector.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 // Only analyze top-level frames within the main frame. | 138 // Only analyze top-level frames within the main frame. |
139 return request_info->ParentIsMainFrame(); | 139 return request_info->ParentIsMainFrame(); |
140 case content::RESOURCE_TYPE_STYLESHEET: | 140 case content::RESOURCE_TYPE_STYLESHEET: |
141 case content::RESOURCE_TYPE_SCRIPT: | 141 case content::RESOURCE_TYPE_SCRIPT: |
142 case content::RESOURCE_TYPE_IMAGE: | 142 case content::RESOURCE_TYPE_IMAGE: |
143 case content::RESOURCE_TYPE_FONT_RESOURCE: | 143 case content::RESOURCE_TYPE_FONT_RESOURCE: |
144 case content::RESOURCE_TYPE_SUB_RESOURCE: | 144 case content::RESOURCE_TYPE_SUB_RESOURCE: |
145 case content::RESOURCE_TYPE_OBJECT: | 145 case content::RESOURCE_TYPE_OBJECT: |
146 case content::RESOURCE_TYPE_MEDIA: | 146 case content::RESOURCE_TYPE_MEDIA: |
147 case content::RESOURCE_TYPE_XHR: | 147 case content::RESOURCE_TYPE_XHR: |
| 148 case content::RESOURCE_TYPE_PLUGIN_RESOURCE: |
148 // Types above are to be analyzed for off-domain inclusion if they are | 149 // Types above are to be analyzed for off-domain inclusion if they are |
149 // loaded as part of the main frame. | 150 // loaded as part of the main frame. |
150 return request_info->IsMainFrame(); | 151 return request_info->IsMainFrame(); |
151 case content::RESOURCE_TYPE_WORKER: | 152 case content::RESOURCE_TYPE_WORKER: |
152 case content::RESOURCE_TYPE_SHARED_WORKER: | 153 case content::RESOURCE_TYPE_SHARED_WORKER: |
153 case content::RESOURCE_TYPE_PREFETCH: | 154 case content::RESOURCE_TYPE_PREFETCH: |
154 case content::RESOURCE_TYPE_FAVICON: | 155 case content::RESOURCE_TYPE_FAVICON: |
155 case content::RESOURCE_TYPE_PING: | 156 case content::RESOURCE_TYPE_PING: |
156 case content::RESOURCE_TYPE_SERVICE_WORKER: | 157 case content::RESOURCE_TYPE_SERVICE_WORKER: |
| 158 case content::RESOURCE_TYPE_CSP_REPORT: |
157 // Types above are not to be analyzed for off-domain inclusion. | 159 // Types above are not to be analyzed for off-domain inclusion. |
158 return false; | 160 return false; |
159 case content::RESOURCE_TYPE_LAST_TYPE: | 161 case content::RESOURCE_TYPE_LAST_TYPE: |
160 NOTREACHED(); | 162 NOTREACHED(); |
161 break; | 163 break; |
162 } | 164 } |
163 NOTREACHED(); | 165 NOTREACHED(); |
164 return false; | 166 return false; |
165 } | 167 } |
166 | 168 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
304 } | 306 } |
305 } | 307 } |
306 | 308 |
307 void OffDomainInclusionDetector::ReportAnalysisResult( | 309 void OffDomainInclusionDetector::ReportAnalysisResult( |
308 scoped_ptr<const OffDomainInclusionInfo> off_domain_inclusion_info, | 310 scoped_ptr<const OffDomainInclusionInfo> off_domain_inclusion_info, |
309 AnalysisEvent analysis_event) { | 311 AnalysisEvent analysis_event) { |
310 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 312 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
311 | 313 |
312 // Always record this histogram for the resource type analyzed to be able to | 314 // Always record this histogram for the resource type analyzed to be able to |
313 // do ratio analysis w.r.t. other histograms below. | 315 // do ratio analysis w.r.t. other histograms below. |
314 UMA_HISTOGRAM_ENUMERATION("SBOffDomainInclusion.RequestAnalyzed", | 316 UMA_HISTOGRAM_ENUMERATION("SBOffDomainInclusion2.RequestAnalyzed", |
315 off_domain_inclusion_info->resource_type, | 317 off_domain_inclusion_info->resource_type, |
316 content::RESOURCE_TYPE_LAST_TYPE); | 318 content::RESOURCE_TYPE_LAST_TYPE); |
317 | 319 |
318 // Log a histogram for the analysis result along with the associated | 320 // Log a histogram for the analysis result along with the associated |
319 // ResourceType. | 321 // ResourceType. |
320 std::string histogram_name; | 322 std::string histogram_name; |
321 switch (analysis_event) { | 323 switch (analysis_event) { |
322 case AnalysisEvent::NO_EVENT: | 324 case AnalysisEvent::NO_EVENT: |
323 break; | 325 break; |
324 case AnalysisEvent::ABORT_EMPTY_MAIN_FRAME_URL: | 326 case AnalysisEvent::ABORT_EMPTY_MAIN_FRAME_URL: |
325 histogram_name = "SBOffDomainInclusion.Abort.EmptyMainFrameURL"; | 327 histogram_name = "SBOffDomainInclusion2.Abort.EmptyMainFrameURL"; |
326 break; | 328 break; |
327 case AnalysisEvent::ABORT_NO_PROFILE: | 329 case AnalysisEvent::ABORT_NO_PROFILE: |
328 histogram_name = "SBOffDomainInclusion.Abort.NoProfile"; | 330 histogram_name = "SBOffDomainInclusion2.Abort.NoProfile"; |
329 break; | 331 break; |
330 case AnalysisEvent::ABORT_INCOGNITO: | 332 case AnalysisEvent::ABORT_INCOGNITO: |
331 histogram_name = "SBOffDomainInclusion.Abort.Incognito"; | 333 histogram_name = "SBOffDomainInclusion2.Abort.Incognito"; |
332 break; | 334 break; |
333 case AnalysisEvent::ABORT_NO_HISTORY_SERVICE: | 335 case AnalysisEvent::ABORT_NO_HISTORY_SERVICE: |
334 histogram_name = "SBOffDomainInclusion.Abort.NoHistoryService"; | 336 histogram_name = "SBOffDomainInclusion2.Abort.NoHistoryService"; |
335 break; | 337 break; |
336 case AnalysisEvent::ABORT_HISTORY_LOOKUP_FAILED: | 338 case AnalysisEvent::ABORT_HISTORY_LOOKUP_FAILED: |
337 histogram_name = "SBOffDomainInclusion.Abort.HistoryLookupFailed"; | 339 histogram_name = "SBOffDomainInclusion2.Abort.HistoryLookupFailed"; |
338 break; | 340 break; |
339 case AnalysisEvent::OFF_DOMAIN_INCLUSION_WHITELISTED: | 341 case AnalysisEvent::OFF_DOMAIN_INCLUSION_WHITELISTED: |
340 histogram_name = "SBOffDomainInclusion.Whitelisted"; | 342 histogram_name = "SBOffDomainInclusion2.Whitelisted"; |
341 break; | 343 break; |
342 case AnalysisEvent::OFF_DOMAIN_INCLUSION_IN_HISTORY: | 344 case AnalysisEvent::OFF_DOMAIN_INCLUSION_IN_HISTORY: |
343 histogram_name = "SBOffDomainInclusion.InHistory"; | 345 histogram_name = "SBOffDomainInclusion2.InHistory"; |
344 break; | 346 break; |
345 case AnalysisEvent::OFF_DOMAIN_INCLUSION_SUSPICIOUS: | 347 case AnalysisEvent::OFF_DOMAIN_INCLUSION_SUSPICIOUS: |
346 histogram_name = "SBOffDomainInclusion.Suspicious"; | 348 histogram_name = "SBOffDomainInclusion2.Suspicious"; |
347 break; | 349 break; |
348 } | 350 } |
349 if (!histogram_name.empty()) { | 351 if (!histogram_name.empty()) { |
350 // Expanded from the UMA_HISTOGRAM_ENUMERATION macro. | 352 // Expanded from the UMA_HISTOGRAM_ENUMERATION macro. |
351 base::LinearHistogram::FactoryGet( | 353 base::LinearHistogram::FactoryGet( |
352 histogram_name, | 354 histogram_name, |
353 1, // minimum, | 355 1, // minimum, |
354 content::RESOURCE_TYPE_LAST_TYPE, // maximum | 356 content::RESOURCE_TYPE_LAST_TYPE, // maximum |
355 content::RESOURCE_TYPE_LAST_TYPE + 1, // bucket_count | 357 content::RESOURCE_TYPE_LAST_TYPE + 1, // bucket_count |
356 base::HistogramBase::kUmaTargetedHistogramFlag) | 358 base::HistogramBase::kUmaTargetedHistogramFlag) |
357 ->Add(off_domain_inclusion_info->resource_type); | 359 ->Add(off_domain_inclusion_info->resource_type); |
358 } | 360 } |
359 | 361 |
360 if (!report_analysis_event_callback_.is_null() && | 362 if (!report_analysis_event_callback_.is_null() && |
361 analysis_event != AnalysisEvent::NO_EVENT) { | 363 analysis_event != AnalysisEvent::NO_EVENT) { |
362 report_analysis_event_callback_.Run(analysis_event); | 364 report_analysis_event_callback_.Run(analysis_event); |
363 } | 365 } |
364 } | 366 } |
365 | 367 |
366 } // namespace safe_browsing | 368 } // namespace safe_browsing |
OLD | NEW |