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

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

Issue 42553002: Mostly integrate new malware IP blacklist with the csd client. When (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix leaks in the unit-tests Created 7 years, 1 month 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 // we should classify the new URL. 45 // we should classify the new URL.
46 virtual void DidNavigateMainFrame( 46 virtual void DidNavigateMainFrame(
47 const content::LoadCommittedDetails& details, 47 const content::LoadCommittedDetails& details,
48 const content::FrameNavigateParams& params) OVERRIDE; 48 const content::FrameNavigateParams& params) OVERRIDE;
49 49
50 // Called when the SafeBrowsingService found a hit with one of the 50 // Called when the SafeBrowsingService found a hit with one of the
51 // SafeBrowsing lists. This method is called on the UI thread. 51 // SafeBrowsing lists. This method is called on the UI thread.
52 virtual void OnSafeBrowsingHit( 52 virtual void OnSafeBrowsingHit(
53 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; 53 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE;
54 54
55 virtual scoped_refptr<SafeBrowsingDatabaseManager> database_manager();
56
55 protected: 57 protected:
58 explicit ClientSideDetectionHost(content::WebContents* tab);
59
56 // From content::WebContentsObserver. 60 // From content::WebContentsObserver.
57 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE; 61 virtual void WebContentsDestroyed(content::WebContents* tab) OVERRIDE;
58 62
63 // Used for testing.
64 void set_safe_browsing_managers(
65 SafeBrowsingUIManager* ui_manager,
66 SafeBrowsingDatabaseManager* database_manager);
67
59 private: 68 private:
60 friend class ClientSideDetectionHostTest; 69 friend class ClientSideDetectionHostTest;
61 class ShouldClassifyUrlRequest; 70 class ShouldClassifyUrlRequest;
62 friend class ShouldClassifyUrlRequest; 71 friend class ShouldClassifyUrlRequest;
63 72
64 explicit ClientSideDetectionHost(content::WebContents* tab);
65
66 // Verdict is an encoded ClientPhishingRequest protocol message. 73 // Verdict is an encoded ClientPhishingRequest protocol message.
67 void OnPhishingDetectionDone(const std::string& verdict); 74 void OnPhishingDetectionDone(const std::string& verdict);
68 75
69 // Callback that is called when the server ping back is 76 // Callback that is called when the server ping back is
70 // done. Display an interstitial if |is_phishing| is true. 77 // done. Display an interstitial if |is_phishing| is true.
71 // Otherwise, we do nothing. Called in UI thread. 78 // Otherwise, we do nothing. Called in UI thread.
72 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing); 79 void MaybeShowPhishingWarning(GURL phishing_url, bool is_phishing);
73 80
74 // Callback that is called when the malware IP server ping back is 81 // Callback that is called when the malware IP server ping back is
75 // done. Display an interstitial if |is_malware| is true. 82 // done. Display an interstitial if |is_malware| is true.
76 // Otherwise, we do nothing. Called in UI thread. 83 // Otherwise, we do nothing. Called in UI thread.
77 void MaybeShowMalwareWarning(GURL original_url, GURL malware_url, 84 void MaybeShowMalwareWarning(GURL original_url, GURL malware_url,
78 bool is_malware); 85 bool is_malware);
79 86
80 // Callback that is called when the browser feature extractor is done. 87 // Callback that is called when the browser feature extractor is done.
81 // This method is responsible for deleting the request object. Called on 88 // This method is responsible for deleting the request object. Called on
82 // the UI thread. 89 // the UI thread.
83 void FeatureExtractionDone(bool success, ClientPhishingRequest* request); 90 void FeatureExtractionDone(bool success, ClientPhishingRequest* request);
91
84 // Function to be called when the browser malware feature extractor is done. 92 // Function to be called when the browser malware feature extractor is done.
85 void MalwareFeatureExtractionDone(scoped_ptr<ClientMalwareRequest> request); 93 // Called on the UI thread.
94 void MalwareFeatureExtractionDone(bool success,
95 scoped_ptr<ClientMalwareRequest> request);
86 96
87 // Update the entries in browse_info_->ips map. 97 // Update the entries in browse_info_->ips map.
88 void UpdateIPUrlMap(const std::string& ip, const std::string& url); 98 void UpdateIPUrlMap(const std::string& ip, const std::string& url);
89 99
90 // From NotificationObserver. Called when a notification comes in. This 100 // From NotificationObserver. Called when a notification comes in. This
91 // method is called in the UI thread. 101 // method is called in the UI thread.
92 virtual void Observe(int type, 102 virtual void Observe(int type,
93 const content::NotificationSource& source, 103 const content::NotificationSource& source,
94 const content::NotificationDetails& details) OVERRIDE; 104 const content::NotificationDetails& details) OVERRIDE;
95 105
96 // Returns true if the user has seen a regular SafeBrowsing 106 // Returns true if the user has seen a regular SafeBrowsing
97 // interstitial for the current page. This is only true if the user has 107 // interstitial for the current page. This is only true if the user has
98 // actually clicked through the warning. This method is called on the UI 108 // actually clicked through the warning. This method is called on the UI
99 // thread. 109 // thread.
100 bool DidShowSBInterstitial(); 110 bool DidShowSBInterstitial();
101 111
102 // Used for testing. This function does not take ownership of the service 112 // Used for testing. This function does not take ownership of the service
103 // class. 113 // class.
104 void set_client_side_detection_service(ClientSideDetectionService* service); 114 void set_client_side_detection_service(ClientSideDetectionService* service);
105 115
106 // Used for testing.
107 void set_safe_browsing_managers(
108 SafeBrowsingUIManager* ui_manager,
109 SafeBrowsingDatabaseManager* database_manager);
110
111 // Get/Set malware_killswitch_on_ value. These methods called on UI thread. 116 // Get/Set malware_killswitch_on_ value. These methods called on UI thread.
112 bool MalwareKillSwitchIsOn(); 117 bool MalwareKillSwitchIsOn();
113 void SetMalwareKillSwitch(bool killswitch_on); 118 void SetMalwareKillSwitch(bool killswitch_on);
114 119
115 // This pointer may be NULL if client-side phishing detection is disabled. 120 // This pointer may be NULL if client-side phishing detection is disabled.
116 ClientSideDetectionService* csd_service_; 121 ClientSideDetectionService* csd_service_;
117 // These pointers may be NULL if SafeBrowsing is disabled. 122 // These pointers may be NULL if SafeBrowsing is disabled.
118 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_; 123 scoped_refptr<SafeBrowsingDatabaseManager> database_manager_;
119 scoped_refptr<SafeBrowsingUIManager> ui_manager_; 124 scoped_refptr<SafeBrowsingUIManager> ui_manager_;
120 // Keep a handle to the latest classification request so that we can cancel 125 // Keep a handle to the latest classification request so that we can cancel
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 // Whether the malware bad ip matching and report feature is enabled. 159 // Whether the malware bad ip matching and report feature is enabled.
155 // This should be accessed from UI thread. 160 // This should be accessed from UI thread.
156 bool malware_report_enabled_; 161 bool malware_report_enabled_;
157 162
158 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); 163 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost);
159 }; 164 };
160 165
161 } // namespace safe_browsing 166 } // namespace safe_browsing
162 167
163 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ 168 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698