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

Side by Side Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory.cc

Issue 2645283007: Add the client for accessing Subresource Filter only list. (Closed)
Patch Set: feature Created 3 years, 8 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h" 5 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h"
6 6
7 #include "base/metrics/histogram_macros.h" 7 #include "base/metrics/histogram_macros.h"
8 #include "base/rand_util.h" 8 #include "base/rand_util.h"
9 #include "base/time/time.h" 9 #include "base/time/time.h"
10 #include "components/subresource_filter/content/browser/content_activation_list_ utils.h" 10 #include "components/subresource_filter/content/browser/content_activation_list_ utils.h"
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 if (url.has_host() && url.SchemeIsHTTPOrHTTPS()) 349 if (url.has_host() && url.SchemeIsHTTPOrHTTPS())
350 activation_list_matches_[DistillURLToHostAndPath(url)].insert(match_type); 350 activation_list_matches_[DistillURLToHostAndPath(url)].insert(match_type);
351 } 351 }
352 352
353 int ContentSubresourceFilterDriverFactory::CalculateHitPatternForActivationList( 353 int ContentSubresourceFilterDriverFactory::CalculateHitPatternForActivationList(
354 ActivationList activation_list) const { 354 ActivationList activation_list) const {
355 int hits_pattern = 0; 355 int hits_pattern = 0;
356 const int kInitialURLHitMask = 0x4; 356 const int kInitialURLHitMask = 0x4;
357 const int kRedirectURLHitMask = 0x2; 357 const int kRedirectURLHitMask = 0x2;
358 const int kFinalURLHitMask = 0x1; 358 const int kFinalURLHitMask = 0x1;
359
359 if (navigation_chain_.size() > 1) { 360 if (navigation_chain_.size() > 1) {
360 if (DidURLMatchActivationList(navigation_chain_.back(), activation_list)) 361 if (DidURLMatchActivationList(navigation_chain_.back(), activation_list))
361 hits_pattern |= kFinalURLHitMask; 362 hits_pattern |= kFinalURLHitMask;
362 if (DidURLMatchActivationList(navigation_chain_.front(), activation_list)) 363 if (DidURLMatchActivationList(navigation_chain_.front(), activation_list))
363 hits_pattern |= kInitialURLHitMask; 364 hits_pattern |= kInitialURLHitMask;
364 365
365 // Examine redirects. 366 // Examine redirects.
366 for (size_t i = 1; i < navigation_chain_.size() - 1; ++i) { 367 for (size_t i = 1; i < navigation_chain_.size() - 1; ++i) {
367 if (DidURLMatchActivationList(navigation_chain_[i], activation_list)) { 368 if (DidURLMatchActivationList(navigation_chain_[i], activation_list)) {
368 hits_pattern |= kRedirectURLHitMask; 369 hits_pattern |= kRedirectURLHitMask;
369 break; 370 break;
370 } 371 }
371 } 372 }
372 } else { 373 } else {
373 if (navigation_chain_.size() && 374 if (navigation_chain_.size() &&
374 DidURLMatchActivationList(navigation_chain_.front(), activation_list)) { 375 DidURLMatchActivationList(navigation_chain_.front(), activation_list)) {
375 hits_pattern = 0x8; // One url hit. 376 hits_pattern = 0x8; // One url hit.
376 } 377 }
377 } 378 }
378 return hits_pattern; 379 return hits_pattern;
379 } 380 }
380 381
381 void ContentSubresourceFilterDriverFactory::RecordRedirectChainMatchPattern() 382 void ContentSubresourceFilterDriverFactory::RecordRedirectChainMatchPattern()
382 const { 383 const {
383 RecordRedirectChainMatchPatternForList( 384 RecordRedirectChainMatchPatternForList(
384 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL); 385 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL);
385 RecordRedirectChainMatchPatternForList(ActivationList::PHISHING_INTERSTITIAL); 386 RecordRedirectChainMatchPatternForList(ActivationList::PHISHING_INTERSTITIAL);
387 RecordRedirectChainMatchPatternForList(ActivationList::SUBRESOURCE_FILTER);
386 } 388 }
387 389
388 void ContentSubresourceFilterDriverFactory:: 390 void ContentSubresourceFilterDriverFactory::
389 RecordRedirectChainMatchPatternForList( 391 RecordRedirectChainMatchPatternForList(
390 ActivationList activation_list) const { 392 ActivationList activation_list) const {
391 int hits_pattern = CalculateHitPatternForActivationList(activation_list); 393 int hits_pattern = CalculateHitPatternForActivationList(activation_list);
392 if (!hits_pattern) 394 if (!hits_pattern)
393 return; 395 return;
394 size_t chain_size = navigation_chain_.size(); 396 size_t chain_size = navigation_chain_.size();
395 switch (activation_list) { 397 switch (activation_list) {
396 case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL: 398 case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL:
397 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SocialEngineeringAdsInterstitial", 399 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SocialEngineeringAdsInterstitial",
398 hits_pattern, chain_size); 400 hits_pattern, chain_size);
399 break; 401 break;
400 case ActivationList::PHISHING_INTERSTITIAL: 402 case ActivationList::PHISHING_INTERSTITIAL:
401 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("PhishingInterstital", hits_pattern, 403 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("PhishingInterstital", hits_pattern,
402 chain_size); 404 chain_size);
403 break; 405 break;
406 case ActivationList::SUBRESOURCE_FILTER:
407 REPORT_REDIRECT_PATTERN_FOR_SUFFIX("SubresourceFilterOnly", hits_pattern,
408 chain_size);
409 break;
404 default: 410 default:
405 NOTREACHED(); 411 NOTREACHED();
406 break; 412 break;
407 } 413 }
408 } 414 }
409 415
410 } // namespace subresource_filter 416 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698