| 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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 316 | 316 |
| 317 void PhishingDOMFeatureExtractor::HandleInput( | 317 void PhishingDOMFeatureExtractor::HandleInput( |
| 318 const blink::WebElement& element) { | 318 const blink::WebElement& element) { |
| 319 // The HTML spec says that if the type is unspecified, it defaults to text. | 319 // The HTML spec says that if the type is unspecified, it defaults to text. |
| 320 // In addition, any unrecognized type will be treated as a text input. | 320 // In addition, any unrecognized type will be treated as a text input. |
| 321 // | 321 // |
| 322 // Note that we use the attribute value rather than | 322 // Note that we use the attribute value rather than |
| 323 // WebFormControlElement::formControlType() for consistency with the | 323 // WebFormControlElement::formControlType() for consistency with the |
| 324 // way the phishing classification model is created. | 324 // way the phishing classification model is created. |
| 325 std::string type = element.getAttribute("type").utf8(); | 325 std::string type = element.getAttribute("type").utf8(); |
| 326 StringToLowerASCII(&type); | 326 base::StringToLowerASCII(&type); |
| 327 if (type == "password") { | 327 if (type == "password") { |
| 328 ++page_feature_state_->num_pswd_inputs; | 328 ++page_feature_state_->num_pswd_inputs; |
| 329 } else if (type == "radio") { | 329 } else if (type == "radio") { |
| 330 ++page_feature_state_->num_radio_inputs; | 330 ++page_feature_state_->num_radio_inputs; |
| 331 } else if (type == "checkbox") { | 331 } else if (type == "checkbox") { |
| 332 ++page_feature_state_->num_check_inputs; | 332 ++page_feature_state_->num_check_inputs; |
| 333 } else if (type != "submit" && type != "reset" && type != "file" && | 333 } else if (type != "submit" && type != "reset" && type != "file" && |
| 334 type != "hidden" && type != "image" && type != "button") { | 334 type != "hidden" && type != "image" && type != "button") { |
| 335 // Note that there are a number of new input types in HTML5 that are not | 335 // Note that there are a number of new input types in HTML5 that are not |
| 336 // handled above. For now, we will consider these as text inputs since | 336 // handled above. For now, we will consider these as text inputs since |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 489 // Record number of script tags (discretized for numerical stability.) | 489 // Record number of script tags (discretized for numerical stability.) |
| 490 if (page_feature_state_->num_script_tags > 1) { | 490 if (page_feature_state_->num_script_tags > 1) { |
| 491 features_->AddBooleanFeature(features::kPageNumScriptTagsGTOne); | 491 features_->AddBooleanFeature(features::kPageNumScriptTagsGTOne); |
| 492 if (page_feature_state_->num_script_tags > 6) { | 492 if (page_feature_state_->num_script_tags > 6) { |
| 493 features_->AddBooleanFeature(features::kPageNumScriptTagsGTSix); | 493 features_->AddBooleanFeature(features::kPageNumScriptTagsGTSix); |
| 494 } | 494 } |
| 495 } | 495 } |
| 496 } | 496 } |
| 497 | 497 |
| 498 } // namespace safe_browsing | 498 } // namespace safe_browsing |
| OLD | NEW |