Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(420)

Side by Side Diff: chrome/renderer/safe_browsing/phishing_classifier_delegate.h

Issue 6398001: Run pre-classification checks in the browser before starting client-side phishing detection. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix switch/case formatting Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This class is used by the RenderView to interact with a PhishingClassifier. 5 // This class is used by the RenderView to interact with a PhishingClassifier.
6 6
7 #ifndef CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_DELEGATE_H_ 7 #ifndef CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_DELEGATE_H_
8 #define CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_DELEGATE_H_ 8 #define CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_DELEGATE_H_
9 #pragma once 9 #pragma once
10 10
(...skipping 17 matching lines...) Expand all
28 // Note that if classifier is null, a default instance of PhishingClassifier 28 // Note that if classifier is null, a default instance of PhishingClassifier
29 // will be used. 29 // will be used.
30 PhishingClassifierDelegate(RenderView* render_view, 30 PhishingClassifierDelegate(RenderView* render_view,
31 PhishingClassifier* classifier); 31 PhishingClassifier* classifier);
32 ~PhishingClassifierDelegate(); 32 ~PhishingClassifierDelegate();
33 33
34 // Called by the RenderView once there is a phishing scorer available. 34 // Called by the RenderView once there is a phishing scorer available.
35 // The scorer is passed on to the classifier. 35 // The scorer is passed on to the classifier.
36 void SetPhishingScorer(const safe_browsing::Scorer* scorer); 36 void SetPhishingScorer(const safe_browsing::Scorer* scorer);
37 37
38 // Called by the RenderView when it receives a StartPhishingDetection IPC
39 // from the browser. This signals that it is ok to begin classification
40 // for the given toplevel URL. If the URL has been fully loaded into the
41 // RenderView and a Scorer has been set, this will begin classification,
42 // otherwise classification will be deferred until these conditions are met.
43 void OnStartPhishingDetection(const GURL& url);
44
38 // Called by the RenderView when a page has started loading in the given 45 // Called by the RenderView when a page has started loading in the given
39 // WebFrame. Typically, this will cause any pending classification to be 46 // WebFrame. Typically, this will cause any pending classification to be
40 // cancelled. However, if the load is for the main frame, and the toplevel 47 // cancelled. However, if the load is for the main frame, and the toplevel
41 // URL has not changed, we continue running the current classification. 48 // URL has not changed, we continue running the current classification.
42 void CommittedLoadInFrame(WebKit::WebFrame* frame); 49 void CommittedLoadInFrame(WebKit::WebFrame* frame);
43 50
44 // Called by the RenderView once a page has finished loading. Determines 51 // Called by the RenderView once a page has finished loading. Determines
45 // whether a new toplevel load has taken place, and if so, begins 52 // whether a new toplevel load has taken place, and if so, begins
46 // classification. May modify page_text. Note that it is an error to 53 // classification. May modify page_text. Note that it is an error to
lzheng 2011/02/04 20:05:22 this comment needs slight update because it cals M
Brian Ryner 2011/02/10 01:12:52 Done, also added back some comments that were remo
47 // call OnNavigate if there is a pending classification. 54 // call OnNavigate if there is a pending classification.
48 void FinishedLoad(string16* page_text); 55 void FinishedLoad(string16* page_text);
49 56
50 // Cancels any pending classification and frees the page text. Called by 57 // Cancels any pending classification and frees the page text. Called by
51 // the RenderView when the RenderView is going away. 58 // the RenderView when the RenderView is going away.
52 void CancelPendingClassification(); 59 void CancelPendingClassification();
53 60
54 private: 61 private:
55 friend class PhishingClassifierDelegateTest; 62 friend class PhishingClassifierDelegateTest;
56 63
57 // Called when classification for the current page finishes. 64 // Called when classification for the current page finishes.
58 void ClassificationDone(bool is_phishy, double phishy_score); 65 void ClassificationDone(bool is_phishy, double phishy_score);
59 66
60 // Returns the RenderView's toplevel URL, with the ref stripped. 67 // Returns the RenderView's toplevel URL, with the ref stripped.
61 GURL StripToplevelUrl(); 68 GURL StripToplevelUrl();
62 69
70 // Shared code to begin classification if all conditions are met.
71 void MaybeStartClassification();
72
63 // The RenderView that owns this object. 73 // The RenderView that owns this object.
64 RenderView* render_view_; 74 RenderView* render_view_;
65 75
66 // The PhishingClassifier to use for the RenderView. This is created once 76 // The PhishingClassifier to use for the RenderView. This is created once
67 // a scorer is made available via SetPhishingScorer(). 77 // a scorer is made available via SetPhishingScorer().
68 scoped_ptr<PhishingClassifier> classifier_; 78 scoped_ptr<PhishingClassifier> classifier_;
69 79
70 // The last URL that was sent to the phishing classifier. 80 // The last URL that the browser instructed us to classify.
81 GURL last_url_received_from_browser_;
82
83 // The last URL and page id that have finished loading in the RenderView.
84 // These correspond to the text in classifier_page_text_.
85 GURL last_finished_load_url_;
86 int32 last_finished_load_id_;
87
88 // The URL and page id of the last load that we actually started
89 // classification on. This is used to suppress phishing classification on
90 // subframe navigation and back and forward navigations in history.
71 GURL last_url_sent_to_classifier_; 91 GURL last_url_sent_to_classifier_;
72
73 // The page id of the last load that was sent to the phishing classifier.
74 // This is used to suppress phishing classification on back and forward
75 // navigations in history.
76 int32 last_page_id_sent_to_classifier_; 92 int32 last_page_id_sent_to_classifier_;
77 93
78 // The page text that will be analyzed by the phishing classifier. This is 94 // The page text that will be analyzed by the phishing classifier. This is
79 // set by OnNavigate and cleared when the classifier finishes. Note that if 95 // set by OnNavigate and cleared when the classifier finishes. Note that if
80 // there is no classifier yet when OnNavigate is called, the page text will 96 // there is no Scorer yet when OnNavigate is called, or the browser has not
81 // be cached until the scorer is set and a classifier can be created. 97 // instructed us to classify the page, the page text will be cached until
98 // these conditions are met.
82 string16 classifier_page_text_; 99 string16 classifier_page_text_;
83 100
84 // Set to true if we should run the phishing classifier on the current page
85 // as soon as SetPhishingScorer() is called.
86 bool pending_classification_;
87
88 DISALLOW_COPY_AND_ASSIGN(PhishingClassifierDelegate); 101 DISALLOW_COPY_AND_ASSIGN(PhishingClassifierDelegate);
89 }; 102 };
90 103
91 } // namespace safe_browsing 104 } // namespace safe_browsing
92 105
93 #endif // CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_DELEGATE_H_ 106 #endif // CHROME_RENDERER_SAFE_BROWSING_PHISHING_CLASSIFIER_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698