| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/renderer/safe_browsing/phishing_dom_feature_extractor.h" | 5 #include "chrome/renderer/safe_browsing/phishing_dom_feature_extractor.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/containers/hash_tables.h" | 9 #include "base/containers/hash_tables.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 net::registry_controlled_domains::GetDomainAndRegistry( | 386 net::registry_controlled_domains::GetDomainAndRegistry( |
| 387 cur_document_.url(), | 387 cur_document_.url(), |
| 388 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); | 388 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES); |
| 389 } | 389 } |
| 390 | 390 |
| 391 blink::WebDocument PhishingDOMFeatureExtractor::GetNextDocument() { | 391 blink::WebDocument PhishingDOMFeatureExtractor::GetNextDocument() { |
| 392 DCHECK(!cur_document_.isNull()); | 392 DCHECK(!cur_document_.isNull()); |
| 393 blink::WebFrame* frame = cur_document_.frame(); | 393 blink::WebFrame* frame = cur_document_.frame(); |
| 394 // Advance to the next frame that contains a document, with no wrapping. | 394 // Advance to the next frame that contains a document, with no wrapping. |
| 395 if (frame) { | 395 if (frame) { |
| 396 while ((frame = frame->traverseNext(false))) { | 396 for (frame = frame->traverseNext(false); frame; |
| 397 frame = frame->traverseNext(false)) { |
| 397 if (!frame->document().isNull()) { | 398 if (!frame->document().isNull()) { |
| 398 return frame->document(); | 399 return frame->document(); |
| 399 } | 400 } |
| 400 } | 401 } |
| 401 } else { | 402 } else { |
| 402 // Keep track of how often frame traversal got "stuck" due to the | 403 // Keep track of how often frame traversal got "stuck" due to the |
| 403 // current subdocument getting removed from the frame tree. | 404 // current subdocument getting removed from the frame tree. |
| 404 UMA_HISTOGRAM_COUNTS("SBClientPhishing.DOMFeatureFrameRemoved", 1); | 405 UMA_HISTOGRAM_COUNTS("SBClientPhishing.DOMFeatureFrameRemoved", 1); |
| 405 } | 406 } |
| 406 return blink::WebDocument(); | 407 return blink::WebDocument(); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 // Record number of script tags (discretized for numerical stability.) | 489 // Record number of script tags (discretized for numerical stability.) |
| 489 if (page_feature_state_->num_script_tags > 1) { | 490 if (page_feature_state_->num_script_tags > 1) { |
| 490 features_->AddBooleanFeature(features::kPageNumScriptTagsGTOne); | 491 features_->AddBooleanFeature(features::kPageNumScriptTagsGTOne); |
| 491 if (page_feature_state_->num_script_tags > 6) { | 492 if (page_feature_state_->num_script_tags > 6) { |
| 492 features_->AddBooleanFeature(features::kPageNumScriptTagsGTSix); | 493 features_->AddBooleanFeature(features::kPageNumScriptTagsGTSix); |
| 493 } | 494 } |
| 494 } | 495 } |
| 495 } | 496 } |
| 496 | 497 |
| 497 } // namespace safe_browsing | 498 } // namespace safe_browsing |
| OLD | NEW |