| 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 // This class handles the process of extracting all of the features from a | 5 // This class handles the process of extracting all of the features from a |
| 6 // page and computing a phishyness score. The basic steps are: | 6 // page and computing a phishyness score. The basic steps are: |
| 7 // - Run each feature extractor over the page, building up a FeatureMap of | 7 // - Run each feature extractor over the page, building up a FeatureMap of |
| 8 // feature -> value. | 8 // feature -> value. |
| 9 // - SHA-256 hash all of the feature names in the map so that they match the | 9 // - SHA-256 hash all of the feature names in the map so that they match the |
| 10 // supplied model. | 10 // supplied model. |
| 11 // - Hand the hashed map off to a Scorer, which computes the probability that | 11 // - Hand the hashed map off to a Scorer, which computes the probability that |
| 12 // the page is phishy. | 12 // the page is phishy. |
| 13 // - If the page is phishy, run the supplied callback. | 13 // - If the page is phishy, run the supplied callback. |
| 14 // | 14 // |
| 15 // For more details, see phishing_*_feature_extractor.h, scorer.h, and | 15 // For more details, see phishing_*_feature_extractor.h, scorer.h, and |
| 16 // client_model.proto. | 16 // client_model.proto. |
| 17 | 17 |
| 18 #ifndef CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_H_ | 18 #ifndef CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_H_ |
| 19 #define CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_H_ | 19 #define CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_H_ |
| 20 | 20 |
| 21 #include <set> | 21 #include <set> |
| 22 | 22 |
| 23 #include "base/basictypes.h" | 23 #include <stdint.h> |
| 24 |
| 24 #include "base/callback.h" | 25 #include "base/callback.h" |
| 26 #include "base/macros.h" |
| 25 #include "base/memory/scoped_ptr.h" | 27 #include "base/memory/scoped_ptr.h" |
| 26 #include "base/memory/weak_ptr.h" | 28 #include "base/memory/weak_ptr.h" |
| 27 #include "base/strings/string16.h" | 29 #include "base/strings/string16.h" |
| 28 | 30 |
| 29 namespace content { | 31 namespace content { |
| 30 class RenderFrame; | 32 class RenderFrame; |
| 31 } | 33 } |
| 32 | 34 |
| 33 namespace safe_browsing { | 35 namespace safe_browsing { |
| 34 class ClientPhishingRequest; | 36 class ClientPhishingRequest; |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 132 |
| 131 content::RenderFrame* render_frame_; // owns us | 133 content::RenderFrame* render_frame_; // owns us |
| 132 const Scorer* scorer_; // owned by the caller | 134 const Scorer* scorer_; // owned by the caller |
| 133 scoped_ptr<FeatureExtractorClock> clock_; | 135 scoped_ptr<FeatureExtractorClock> clock_; |
| 134 scoped_ptr<PhishingUrlFeatureExtractor> url_extractor_; | 136 scoped_ptr<PhishingUrlFeatureExtractor> url_extractor_; |
| 135 scoped_ptr<PhishingDOMFeatureExtractor> dom_extractor_; | 137 scoped_ptr<PhishingDOMFeatureExtractor> dom_extractor_; |
| 136 scoped_ptr<PhishingTermFeatureExtractor> term_extractor_; | 138 scoped_ptr<PhishingTermFeatureExtractor> term_extractor_; |
| 137 | 139 |
| 138 // State for any in-progress extraction. | 140 // State for any in-progress extraction. |
| 139 scoped_ptr<FeatureMap> features_; | 141 scoped_ptr<FeatureMap> features_; |
| 140 scoped_ptr<std::set<uint32> > shingle_hashes_; | 142 scoped_ptr<std::set<uint32_t>> shingle_hashes_; |
| 141 const base::string16* page_text_; // owned by the caller | 143 const base::string16* page_text_; // owned by the caller |
| 142 DoneCallback done_callback_; | 144 DoneCallback done_callback_; |
| 143 | 145 |
| 144 // Used in scheduling BeginFeatureExtraction tasks. | 146 // Used in scheduling BeginFeatureExtraction tasks. |
| 145 // These pointers are invalidated if classification is cancelled. | 147 // These pointers are invalidated if classification is cancelled. |
| 146 base::WeakPtrFactory<PhishingClassifier> weak_factory_; | 148 base::WeakPtrFactory<PhishingClassifier> weak_factory_; |
| 147 | 149 |
| 148 DISALLOW_COPY_AND_ASSIGN(PhishingClassifier); | 150 DISALLOW_COPY_AND_ASSIGN(PhishingClassifier); |
| 149 }; | 151 }; |
| 150 | 152 |
| 151 } // namespace safe_browsing | 153 } // namespace safe_browsing |
| 152 | 154 |
| 153 #endif // CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_H_ | 155 #endif // CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_H_ |
| OLD | NEW |