OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 class ClientSideDetectionHost : public content::WebContentsObserver, | 31 class ClientSideDetectionHost : public content::WebContentsObserver, |
32 public content::NotificationObserver, | 32 public content::NotificationObserver, |
33 public SafeBrowsingUIManager::Observer { | 33 public SafeBrowsingUIManager::Observer { |
34 public: | 34 public: |
35 // The caller keeps ownership of the tab object and is responsible for | 35 // The caller keeps ownership of the tab object and is responsible for |
36 // ensuring that it stays valid until WebContentsDestroyed is called. | 36 // ensuring that it stays valid until WebContentsDestroyed is called. |
37 static ClientSideDetectionHost* Create(content::WebContents* tab); | 37 static ClientSideDetectionHost* Create(content::WebContents* tab); |
38 virtual ~ClientSideDetectionHost(); | 38 virtual ~ClientSideDetectionHost(); |
39 | 39 |
40 // From content::WebContentsObserver. | 40 // From content::WebContentsObserver. |
41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 41 virtual bool OnMessageReceived(const IPC::Message& message) override; |
42 | 42 |
43 // From content::WebContentsObserver. If we navigate away we cancel all | 43 // From content::WebContentsObserver. If we navigate away we cancel all |
44 // pending callbacks that could show an interstitial, and check to see whether | 44 // pending callbacks that could show an interstitial, and check to see whether |
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 // Called when the SafeBrowsingService finds a match on the SB lists. | 55 // Called when the SafeBrowsingService finds a match on the SB lists. |
56 // Called on the UI thread. Called even if the resource is whitelisted. | 56 // Called on the UI thread. Called even if the resource is whitelisted. |
57 virtual void OnSafeBrowsingMatch( | 57 virtual void OnSafeBrowsingMatch( |
58 const SafeBrowsingUIManager::UnsafeResource& resource) OVERRIDE; | 58 const SafeBrowsingUIManager::UnsafeResource& resource) override; |
59 | 59 |
60 virtual scoped_refptr<SafeBrowsingDatabaseManager> database_manager(); | 60 virtual scoped_refptr<SafeBrowsingDatabaseManager> database_manager(); |
61 | 61 |
62 // Returns whether the current page contains a malware or phishing safe | 62 // Returns whether the current page contains a malware or phishing safe |
63 // browsing match. | 63 // browsing match. |
64 bool DidPageReceiveSafeBrowsingMatch() const; | 64 bool DidPageReceiveSafeBrowsingMatch() const; |
65 | 65 |
66 protected: | 66 protected: |
67 explicit ClientSideDetectionHost(content::WebContents* tab); | 67 explicit ClientSideDetectionHost(content::WebContents* tab); |
68 | 68 |
69 // From content::WebContentsObserver. | 69 // From content::WebContentsObserver. |
70 virtual void WebContentsDestroyed() OVERRIDE; | 70 virtual void WebContentsDestroyed() override; |
71 | 71 |
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; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 void UpdateIPUrlMap(const std::string& ip, | 117 void UpdateIPUrlMap(const std::string& ip, |
118 const std::string& url, | 118 const std::string& url, |
119 const std::string& method, | 119 const std::string& method, |
120 const std::string& referrer, | 120 const std::string& referrer, |
121 const content::ResourceType resource_type); | 121 const content::ResourceType resource_type); |
122 | 122 |
123 // From NotificationObserver. Called when a notification comes in. This | 123 // From NotificationObserver. Called when a notification comes in. This |
124 // method is called in the UI thread. | 124 // method is called in the UI thread. |
125 virtual void Observe(int type, | 125 virtual void Observe(int type, |
126 const content::NotificationSource& source, | 126 const content::NotificationSource& source, |
127 const content::NotificationDetails& details) OVERRIDE; | 127 const content::NotificationDetails& details) override; |
128 | 128 |
129 // Inherited from WebContentsObserver. This is called once the page is | 129 // Inherited from WebContentsObserver. This is called once the page is |
130 // done loading. | 130 // done loading. |
131 virtual void DidStopLoading(content::RenderViewHost* rvh) OVERRIDE; | 131 virtual void DidStopLoading(content::RenderViewHost* rvh) override; |
132 | 132 |
133 // Returns true if the user has seen a regular SafeBrowsing | 133 // Returns true if the user has seen a regular SafeBrowsing |
134 // interstitial for the current page. This is only true if the user has | 134 // interstitial for the current page. This is only true if the user has |
135 // actually clicked through the warning. This method is called on the UI | 135 // actually clicked through the warning. This method is called on the UI |
136 // thread. | 136 // thread. |
137 bool DidShowSBInterstitial() const; | 137 bool DidShowSBInterstitial() const; |
138 | 138 |
139 // Used for testing. This function does not take ownership of the service | 139 // Used for testing. This function does not take ownership of the service |
140 // class. | 140 // class. |
141 void set_client_side_detection_service(ClientSideDetectionService* service); | 141 void set_client_side_detection_service(ClientSideDetectionService* service); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 scoped_ptr<SafeBrowsingUIManager::UnsafeResource> unsafe_resource_; | 178 scoped_ptr<SafeBrowsingUIManager::UnsafeResource> unsafe_resource_; |
179 | 179 |
180 base::WeakPtrFactory<ClientSideDetectionHost> weak_factory_; | 180 base::WeakPtrFactory<ClientSideDetectionHost> weak_factory_; |
181 | 181 |
182 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); | 182 DISALLOW_COPY_AND_ASSIGN(ClientSideDetectionHost); |
183 }; | 183 }; |
184 | 184 |
185 } // namespace safe_browsing | 185 } // namespace safe_browsing |
186 | 186 |
187 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ | 187 #endif // CHROME_BROWSER_SAFE_BROWSING_CLIENT_SIDE_DETECTION_HOST_H_ |
OLD | NEW |