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