Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/hash_tables.h" | 8 #include "base/hash_tables.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| 11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
| 12 #include "base/string_util.h" | |
| 12 #include "base/time.h" | 13 #include "base/time.h" |
| 13 #include "chrome/renderer/render_view.h" | 14 #include "chrome/renderer/render_view.h" |
| 14 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" | 15 #include "chrome/renderer/safe_browsing/feature_extractor_clock.h" |
| 15 #include "chrome/renderer/safe_browsing/features.h" | 16 #include "chrome/renderer/safe_browsing/features.h" |
| 16 #include "net/base/registry_controlled_domain.h" | 17 #include "net/base/registry_controlled_domain.h" |
| 17 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" | 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebDocument.h" |
| 18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebElement.h" |
| 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeCollection.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebNodeCollection.h" |
| 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 139 } | 140 } |
| 140 | 141 |
| 141 void PhishingDOMFeatureExtractor::ExtractFeaturesWithTimeout() { | 142 void PhishingDOMFeatureExtractor::ExtractFeaturesWithTimeout() { |
| 142 DCHECK(page_feature_state_.get()); | 143 DCHECK(page_feature_state_.get()); |
| 143 ++page_feature_state_->num_iterations; | 144 ++page_feature_state_->num_iterations; |
| 144 base::TimeTicks current_chunk_start_time = clock_->Now(); | 145 base::TimeTicks current_chunk_start_time = clock_->Now(); |
| 145 | 146 |
| 146 if (!cur_frame_) { | 147 if (!cur_frame_) { |
| 147 WebKit::WebView* web_view = render_view_->webview(); | 148 WebKit::WebView* web_view = render_view_->webview(); |
| 148 if (!web_view) { | 149 if (!web_view) { |
| 149 // When the WebView is going away, the render view should have called | 150 // RenderView might be closing. |
|
Tom Sepez
2011/02/08 21:21:21
Did we loose a comment here during a sync?
jam
2011/02/08 21:38:39
this was actually from an earlier change, but I fo
| |
| 150 // CancelPendingExtraction() which should have stopped any pending work, | |
| 151 // so this case should not happen. | |
| 152 NOTREACHED(); | |
| 153 RunCallback(false); | 151 RunCallback(false); |
| 154 return; | 152 return; |
| 155 } | 153 } |
| 156 cur_frame_ = web_view->mainFrame(); | 154 cur_frame_ = web_view->mainFrame(); |
| 157 } | 155 } |
| 158 | 156 |
| 159 int num_elements = 0; | 157 int num_elements = 0; |
| 160 for (; cur_frame_; | 158 for (; cur_frame_; |
| 161 cur_frame_ = cur_frame_->traverseNext(false /* don't wrap around */)) { | 159 cur_frame_ = cur_frame_->traverseNext(false /* don't wrap around */)) { |
| 162 WebKit::WebNode cur_node; | 160 WebKit::WebNode cur_node; |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 480 // Record number of script tags (discretized for numerical stability.) | 478 // Record number of script tags (discretized for numerical stability.) |
| 481 if (page_feature_state_->num_script_tags > 1) { | 479 if (page_feature_state_->num_script_tags > 1) { |
| 482 features_->AddBooleanFeature(features::kPageNumScriptTagsGTOne); | 480 features_->AddBooleanFeature(features::kPageNumScriptTagsGTOne); |
| 483 if (page_feature_state_->num_script_tags > 6) { | 481 if (page_feature_state_->num_script_tags > 6) { |
| 484 features_->AddBooleanFeature(features::kPageNumScriptTagsGTSix); | 482 features_->AddBooleanFeature(features::kPageNumScriptTagsGTSix); |
| 485 } | 483 } |
| 486 } | 484 } |
| 487 } | 485 } |
| 488 | 486 |
| 489 } // namespace safe_browsing | 487 } // namespace safe_browsing |
| OLD | NEW |