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 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 void SetUp() override { | 216 void SetUp() override { |
217 ChromeRenderViewHostTestHarness::SetUp(); | 217 ChromeRenderViewHostTestHarness::SetUp(); |
218 ASSERT_TRUE(profile()->CreateHistoryService(true /* delete_file */, | 218 ASSERT_TRUE(profile()->CreateHistoryService(true /* delete_file */, |
219 false /* no_db */)); | 219 false /* no_db */)); |
220 } | 220 } |
221 | 221 |
222 std::string WaitForSerializedReport(ThreatDetails* report, | 222 std::string WaitForSerializedReport(ThreatDetails* report, |
223 bool did_proceed, | 223 bool did_proceed, |
224 int num_visit) { | 224 int num_visit) { |
225 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, | 225 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, |
226 base::Bind(&ThreatDetails::FinishCollection, report, | 226 base::BindOnce(&ThreatDetails::FinishCollection, |
227 did_proceed, num_visit)); | 227 report, did_proceed, num_visit)); |
228 // Wait for the callback (SendSerializedThreatDetails). | 228 // Wait for the callback (SendSerializedThreatDetails). |
229 DVLOG(1) << "Waiting for SendSerializedThreatDetails"; | 229 DVLOG(1) << "Waiting for SendSerializedThreatDetails"; |
230 base::RunLoop run_loop; | 230 base::RunLoop run_loop; |
231 ui_manager_->SetRunLoopToQuit(&run_loop); | 231 ui_manager_->SetRunLoopToQuit(&run_loop); |
232 run_loop.Run(); | 232 run_loop.Run(); |
233 return ui_manager_->GetSerialized(); | 233 return ui_manager_->GetSerialized(); |
234 } | 234 } |
235 | 235 |
236 history::HistoryService* history_service() { | 236 history::HistoryService* history_service() { |
237 return HistoryServiceFactory::GetForProfile( | 237 return HistoryServiceFactory::GetForProfile( |
(...skipping 834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1072 UnsafeResource resource; | 1072 UnsafeResource resource; |
1073 InitResource(&resource, SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, | 1073 InitResource(&resource, SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, |
1074 true /* is_subresource */, GURL(kThreatURL)); | 1074 true /* is_subresource */, GURL(kThreatURL)); |
1075 | 1075 |
1076 scoped_refptr<ThreatDetailsWrap> report = | 1076 scoped_refptr<ThreatDetailsWrap> report = |
1077 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, | 1077 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, |
1078 profile()->GetRequestContext(), history_service()); | 1078 profile()->GetRequestContext(), history_service()); |
1079 | 1079 |
1080 BrowserThread::PostTask( | 1080 BrowserThread::PostTask( |
1081 BrowserThread::IO, FROM_HERE, | 1081 BrowserThread::IO, FROM_HERE, |
1082 base::Bind(&FillCache, | 1082 base::BindOnce(&FillCache, |
1083 base::RetainedRef(profile()->GetRequestContext()))); | 1083 base::RetainedRef(profile()->GetRequestContext()))); |
1084 | 1084 |
1085 // The cache collection starts after the IPC from the DOM is fired. | 1085 // The cache collection starts after the IPC from the DOM is fired. |
1086 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params; | 1086 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params; |
1087 report->OnReceivedThreatDOMDetails(main_rfh(), params); | 1087 report->OnReceivedThreatDOMDetails(main_rfh(), params); |
1088 | 1088 |
1089 // Let the cache callbacks complete. | 1089 // Let the cache callbacks complete. |
1090 base::RunLoop().RunUntilIdle(); | 1090 base::RunLoop().RunUntilIdle(); |
1091 | 1091 |
1092 DVLOG(1) << "Getting serialized report"; | 1092 DVLOG(1) << "Getting serialized report"; |
1093 std::string serialized = WaitForSerializedReport( | 1093 std::string serialized = WaitForSerializedReport( |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 UnsafeResource resource; | 1155 UnsafeResource resource; |
1156 InitResource(&resource, SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, | 1156 InitResource(&resource, SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, |
1157 true /* is_subresource */, GURL(kThreatURLHttps)); | 1157 true /* is_subresource */, GURL(kThreatURLHttps)); |
1158 | 1158 |
1159 scoped_refptr<ThreatDetailsWrap> report = | 1159 scoped_refptr<ThreatDetailsWrap> report = |
1160 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, | 1160 new ThreatDetailsWrap(ui_manager_.get(), web_contents(), resource, |
1161 profile()->GetRequestContext(), history_service()); | 1161 profile()->GetRequestContext(), history_service()); |
1162 | 1162 |
1163 BrowserThread::PostTask( | 1163 BrowserThread::PostTask( |
1164 BrowserThread::IO, FROM_HERE, | 1164 BrowserThread::IO, FROM_HERE, |
1165 base::Bind(&FillCacheHttps, | 1165 base::BindOnce(&FillCacheHttps, |
1166 base::RetainedRef(profile()->GetRequestContext()))); | 1166 base::RetainedRef(profile()->GetRequestContext()))); |
1167 | 1167 |
1168 // The cache collection starts after the IPC from the DOM is fired. | 1168 // The cache collection starts after the IPC from the DOM is fired. |
1169 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params; | 1169 std::vector<SafeBrowsingHostMsg_ThreatDOMDetails_Node> params; |
1170 report->OnReceivedThreatDOMDetails(main_rfh(), params); | 1170 report->OnReceivedThreatDOMDetails(main_rfh(), params); |
1171 | 1171 |
1172 // Let the cache callbacks complete. | 1172 // Let the cache callbacks complete. |
1173 base::RunLoop().RunUntilIdle(); | 1173 base::RunLoop().RunUntilIdle(); |
1174 | 1174 |
1175 DVLOG(1) << "Getting serialized report"; | 1175 DVLOG(1) << "Getting serialized report"; |
1176 std::string serialized = WaitForSerializedReport( | 1176 std::string serialized = WaitForSerializedReport( |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1329 pb_resource->set_parent_id(3); | 1329 pb_resource->set_parent_id(3); |
1330 pb_resource->set_url(kSecondRedirectURL); | 1330 pb_resource->set_url(kSecondRedirectURL); |
1331 pb_resource = expected.add_resources(); | 1331 pb_resource = expected.add_resources(); |
1332 pb_resource->set_id(3); | 1332 pb_resource->set_id(3); |
1333 pb_resource->set_url(kFirstRedirectURL); | 1333 pb_resource->set_url(kFirstRedirectURL); |
1334 | 1334 |
1335 VerifyResults(actual, expected); | 1335 VerifyResults(actual, expected); |
1336 } | 1336 } |
1337 | 1337 |
1338 } // namespace safe_browsing | 1338 } // namespace safe_browsing |
OLD | NEW |