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

Side by Side Diff: chrome/browser/safe_browsing/client_side_detection_host.h

Issue 173133004: Separate pre-classification checks for client-side malware and phishing (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Set right enum type for boolean histograms. Created 6 years, 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_
6 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ 6 #define CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 // Used for testing. 72 // Used for testing.
73 void set_safe_browsing_managers( 73 void set_safe_browsing_managers(
74 SafeBrowsingUIManager* ui_manager, 74 SafeBrowsingUIManager* ui_manager,
75 SafeBrowsingDatabaseManager* database_manager); 75 SafeBrowsingDatabaseManager* database_manager);
76 76
77 private: 77 private:
78 friend class ClientSideDetectionHostTest; 78 friend class ClientSideDetectionHostTest;
79 class ShouldClassifyUrlRequest; 79 class ShouldClassifyUrlRequest;
80 friend class ShouldClassifyUrlRequest; 80 friend class ShouldClassifyUrlRequest;
81 81
82 // These methods are called when pre-classification checks are done for
83 // the phishing and malware clasifiers.
84 void OnPhishingPreClassificationDone(bool should_classify);
85 void OnMalwarePreClassificationDone(bool should_classify);
86
82 // Verdict is an encoded ClientPhishingRequest protocol message. 87 // Verdict is an encoded ClientPhishingRequest protocol message.
83 void OnPhishingDetectionDone(const std::string& verdict); 88 void OnPhishingDetectionDone(const std::string& verdict);
84 89
85 // Callback that is called when the server ping back is 90 // Callback that is called when the server ping back is
86 // done. Display an interstitial if |is_phishing| is true. 91 // done. Display an interstitial if |is_phishing| is true.
87 // Otherwise, we do nothing. Called in UI thread. 92 // Otherwise, we do nothing. Called in UI thread.
88 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing); 93 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing);
89 94
90 // Callback that is called when the malware IP server ping back is 95 // Callback that is called when the malware IP server ping back is
91 // done. Display an interstitial if |is_malware| is true. 96 // done. Display an interstitial if |is_malware| is true.
92 // Otherwise, we do nothing. Called in UI thread. 97 // Otherwise, we do nothing. Called in UI thread.
93 void MaybeShowMalwareWarning(GURL original_url, GURL malware_url, 98 void MaybeShowMalwareWarning(GURL original_url, GURL malware_url,
94 bool is_malware); 99 bool is_malware);
95 100
96 // Callback that is called when the browser feature extractor is done. 101 // Callback that is called when the browser feature extractor is done.
97 // This method is responsible for deleting the request object. Called on 102 // This method is responsible for deleting the request object. Called on
98 // the UI thread. 103 // the UI thread.
99 void FeatureExtractionDone(bool success, ClientPhishingRequest* request); 104 void FeatureExtractionDone(bool success, ClientPhishingRequest* request);
100 105
106 // Start malware classification once the onload handler was called and
107 // malware pre-classification checks are done and passed.
108 void MaybeStartMalwareFeatureExtraction();
109
101 // Function to be called when the browser malware feature extractor is done. 110 // Function to be called when the browser malware feature extractor is done.
102 // Called on the UI thread. 111 // Called on the UI thread.
103 void MalwareFeatureExtractionDone(bool success, 112 void MalwareFeatureExtractionDone(
104 scoped_ptr<ClientMalwareRequest> request); 113 bool success, scoped_ptr<ClientMalwareRequest> request);
105 114
106 // Update the entries in browse_info_->ips map. 115 // Update the entries in browse_info_->ips map.
107 void UpdateIPUrlMap(const std::string& ip, 116 void UpdateIPUrlMap(const std::string& ip,
108 const std::string& url, 117 const std::string& url,
109 const std::string& method, 118 const std::string& method,
110 const std::string& referrer, 119 const std::string& referrer,
111 const ResourceType::Type resource_type); 120 const ResourceType::Type resource_type);
112 121
113 // From NotificationObserver. Called when a notification comes in. This 122 // From NotificationObserver. Called when a notification comes in. This
114 // method is called in the UI thread. 123 // method is called in the UI thread.
115 virtual void Observe(int type, 124 virtual void Observe(int type,
116 const content::NotificationSource& source, 125 const content::NotificationSource& source,
117 const content::NotificationDetails& details) OVERRIDE; 126 const content::NotificationDetails& details) OVERRIDE;
118 127
128 // Inherited from WebContentsObserver. This is called once the onload handler
129 // is called.
130 virtual void DocumentOnLoadCompletedInMainFrame(int32 page_id) OVERRIDE;
131
119 // Returns true if the user has seen a regular SafeBrowsing 132 // Returns true if the user has seen a regular SafeBrowsing
120 // interstitial for the current page. This is only true if the user has 133 // interstitial for the current page. This is only true if the user has
121 // actually clicked through the warning. This method is called on the UI 134 // actually clicked through the warning. This method is called on the UI
122 // thread. 135 // thread.
123 bool DidShowSBInterstitial() const; 136 bool DidShowSBInterstitial() const;
124 137
125 // Used for testing. This function does not take ownership of the service 138 // Used for testing. This function does not take ownership of the service
126 // class. 139 // class.
127 void set_client_side_detection_service(ClientSideDetectionService* service); 140 void set_client_side_detection_service(ClientSideDetectionService* service);
128 141
129 // Get/Set malware_killswitch_on_ value. These methods called on UI thread.
130 bool MalwareKillSwitchIsOn();
131 void SetMalwareKillSwitch(bool killswitch_on);
132
133 // This pointer may be NULL if client-side phishing detection is disabled. 142 // This pointer may be NULL if client-side phishing detection is disabled.
134 ClientSideDetectionService* csd_service_; 143 ClientSideDetectionService* csd_service_;
135 // These pointers may be NULL if SafeBrowsing is disabled. 144 // These pointers may be NULL if SafeBrowsing is disabled.
136 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; 145 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_;
137 scoped_refptr<SafeBrowsingUIManager> ui_manager_; 146 scoped_refptr<SafeBrowsingUIManager> ui_manager_;
138 // Keep a handle to the latest classification request so that we can cancel 147 // Keep a handle to the latest classification request so that we can cancel
139 // it if necessary. 148 // it if necessary.
140 scoped_refptr<ShouldClassifyUrlRequest> classification_request_; 149 scoped_refptr<ShouldClassifyUrlRequest> classification_request_;
141 // Browser-side feature extractor. 150 // Browser-side feature extractor.
142 scoped_ptr<BrowserFeatureExtractor> feature_extractor_; 151 scoped_ptr<BrowserFeatureExtractor> feature_extractor_;
143 // Keeps some info about the current page visit while the renderer 152 // Keeps some info about the current page visit while the renderer
144 // classification is going on. Since we cancel classification on 153 // classification is going on. Since we cancel classification on
145 // every page load we can simply keep this data around as a member 154 // every page load we can simply keep this data around as a member
146 // variable. This information will be passed on to the feature extractor. 155 // variable. This information will be passed on to the feature extractor.
147 scoped_ptr<BrowseInfo> browse_info_; 156 scoped_ptr<BrowseInfo> browse_info_;
148 // Redirect chain that leads to the first page of the current host. We keep 157 // Redirect chain that leads to the first page of the current host. We keep
149 // track of this for browse_info_. 158 // track of this for browse_info_.
150 std::vector<GURL> cur_host_redirects_; 159 std::vector<GURL> cur_host_redirects_;
151 // Current host, used to help determine cur_host_redirects_. 160 // Current host, used to help determine cur_host_redirects_.
152 std::string cur_host_; 161 std::string cur_host_;
153 // Handles registering notifications with the NotificationService. 162 // Handles registering notifications with the NotificationService.
154 content::NotificationRegistrar registrar_; 163 content::NotificationRegistrar registrar_;
155 164
156 // Max number of ips we save for each browse 165 // Max number of ips we save for each browse
157 static const int kMaxIPsPerBrowse; 166 static const int kMaxIPsPerBrowse;
158 // Max number of urls we report for each malware IP. 167 // Max number of urls we report for each malware IP.
159 static const int kMaxUrlsPerIP; 168 static const int kMaxUrlsPerIP;
160 169
170 bool should_extract_malware_features_;
171 bool should_classify_for_malware_;
172 bool onload_complete_;
173
161 base::WeakPtrFactory<ClientSideDetectionHost> weak_factory_; 174 base::WeakPtrFactory<ClientSideDetectionHost> weak_factory_;
162 175
163 // Unique page ID of the most recent unsafe site that was loaded in this tab 176 // Unique page ID of the most recent unsafe site that was loaded in this tab
164 // as well as the UnsafeResource. 177 // as well as the UnsafeResource.
165 int unsafe_unique_page_id_; 178 int unsafe_unique_page_id_;
166 scoped_ptr<SafeBrowsingUIManager::UnsafeResource> unsafe_resource_; 179 scoped_ptr<SafeBrowsingUIManager::UnsafeResource> unsafe_resource_;
167 180
168 // Whether the malware IP matching feature killswitch is on.
169 // This should be accessed from UI thread.
170 bool malware_killswitch_on_;
171
172 // Whether the malware bad ip matching and report feature is enabled.
173 // This should be accessed from UI thread.
174 bool malware_report_enabled_;
175
176 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); 181 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost);
177 }; 182 };
178 183
179 } // namespace safe_browsing 184 } // namespace safe_browsing
180 185
181 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ 186 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_
OLDNEW
« no previous file with comments | « chrome/browser/safe_browsing/browser_feature_extractor.cc ('k') | chrome/browser/safe_browsing/client_side_detection_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698