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 // The Safe Browsing service is responsible for downloading anti-phishing and | 5 // The Safe Browsing service is responsible for downloading anti-phishing and |
6 // anti-malware tables and checking urls against them. | 6 // anti-malware tables and checking urls against them. |
7 | 7 |
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
9 #define CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
10 | 10 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 60 |
61 // Called to stop or shutdown operations on the io_thread. This may be called | 61 // Called to stop or shutdown operations on the io_thread. This may be called |
62 // multiple times during the life of the UIManager. Should be called | 62 // multiple times during the life of the UIManager. Should be called |
63 // on IO thread. If shutdown is true, the manager is disabled permanently. | 63 // on IO thread. If shutdown is true, the manager is disabled permanently. |
64 void StopOnIOThread(bool shutdown) override; | 64 void StopOnIOThread(bool shutdown) override; |
65 | 65 |
66 // Called on the IO thread by the ThreatDetails with the serialized | 66 // Called on the IO thread by the ThreatDetails with the serialized |
67 // protocol buffer, so the service can send it over. | 67 // protocol buffer, so the service can send it over. |
68 void SendSerializedThreatDetails(const std::string& serialized) override; | 68 void SendSerializedThreatDetails(const std::string& serialized) override; |
69 | 69 |
70 // Report hits to the unsafe contents (malware, phishing, unsafe download URL) | 70 // Report hits to unsafe contents (malware, phishing, unsafe download URL) |
71 // to the server. Can only be called on UI thread. If |post_data| is | 71 // to the server. Can only be called on UI thread. The hit report will |
72 // non-empty, the request will be sent as a POST instead of a GET. | 72 // only be sent if the user has enabled SBER and is not in incognito mode. |
73 void MaybeReportSafeBrowsingHit(const safe_browsing::HitReport& hit_report, | 73 void MaybeReportSafeBrowsingHit( |
74 content::WebContents* web_contents) override; | 74 const safe_browsing::HitReport& hit_report, |
| 75 const content::WebContents* web_contents) override; |
75 | 76 |
76 // Report permission action to SafeBrowsing servers. Can only be called on UI | 77 // Report permission action to SafeBrowsing servers. Can only be called on UI |
77 // thread. | 78 // thread. |
78 void ReportPermissionAction(const PermissionReportInfo& report_info); | 79 void ReportPermissionAction(const PermissionReportInfo& report_info); |
79 | 80 |
80 // Creates the whitelist URL set for tests that create a blocking page | 81 // Creates the whitelist URL set for tests that create a blocking page |
81 // themselves and then simulate OnBlockingPageDone(). OnBlockingPageDone() | 82 // themselves and then simulate OnBlockingPageDone(). OnBlockingPageDone() |
82 // expects the whitelist to exist, but the tests don't necessarily call | 83 // expects the whitelist to exist, but the tests don't necessarily call |
83 // DisplayBlockingPage(), which creates it. | 84 // DisplayBlockingPage(), which creates it. |
84 static void CreateWhitelistForTesting(content::WebContents* web_contents); | 85 static void CreateWhitelistForTesting(content::WebContents* web_contents); |
(...skipping 18 matching lines...) Expand all Loading... |
103 // MaybeReportSafeBrowsingHit. This also notifies all observers in | 104 // MaybeReportSafeBrowsingHit. This also notifies all observers in |
104 // |observer_list_|. | 105 // |observer_list_|. |
105 void CreateAndSendHitReport(const UnsafeResource& resource) override; | 106 void CreateAndSendHitReport(const UnsafeResource& resource) override; |
106 | 107 |
107 // Calls SafeBrowsingBlockingPage::ShowBlockingPage(). | 108 // Calls SafeBrowsingBlockingPage::ShowBlockingPage(). |
108 void ShowBlockingPageForResource(const UnsafeResource& resource) override; | 109 void ShowBlockingPageForResource(const UnsafeResource& resource) override; |
109 | 110 |
110 // Helper method to ensure hit reports are only sent when the user has | 111 // Helper method to ensure hit reports are only sent when the user has |
111 // opted in to extended reporting and is not currently in incognito mode. | 112 // opted in to extended reporting and is not currently in incognito mode. |
112 static bool ShouldSendHitReport(const HitReport& hit_report, | 113 static bool ShouldSendHitReport(const HitReport& hit_report, |
113 content::WebContents* web_contents); | 114 const content::WebContents* web_contents); |
114 | 115 |
115 private: | 116 private: |
116 friend class SafeBrowsingUIManagerTest; | 117 friend class SafeBrowsingUIManagerTest; |
117 friend class TestSafeBrowsingUIManager; | 118 friend class TestSafeBrowsingUIManager; |
118 | 119 |
119 // Report permission action to SafeBrowsing servers. | 120 // Report permission action to SafeBrowsing servers. |
120 void ReportPermissionActionOnIOThread( | 121 void ReportPermissionActionOnIOThread( |
121 const PermissionReportInfo& report_info); | 122 const PermissionReportInfo& report_info); |
122 | 123 |
123 static GURL GetMainFrameWhitelistUrlForResourceForTesting( | 124 static GURL GetMainFrameWhitelistUrlForResourceForTesting( |
124 const safe_browsing::SafeBrowsingUIManager::UnsafeResource& resource); | 125 const safe_browsing::SafeBrowsingUIManager::UnsafeResource& resource); |
125 | 126 |
126 // Safebrowsing service. | 127 // Safebrowsing service. |
127 scoped_refptr<SafeBrowsingService> sb_service_; | 128 scoped_refptr<SafeBrowsingService> sb_service_; |
128 | 129 |
129 base::ObserverList<Observer> observer_list_; | 130 base::ObserverList<Observer> observer_list_; |
130 | 131 |
131 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); | 132 DISALLOW_COPY_AND_ASSIGN(SafeBrowsingUIManager); |
132 }; | 133 }; |
133 | 134 |
134 } // namespace safe_browsing | 135 } // namespace safe_browsing |
135 | 136 |
136 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ | 137 #endif // CHROME_BROWSER_SAFE_BROWSING_UI_MANAGER_H_ |
OLD | NEW |