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 // This test creates a safebrowsing service using test safebrowsing database | 5 // This test creates a safebrowsing service using test safebrowsing database |
6 // and a test protocol manager. It is used to test logics in safebrowsing | 6 // and a test protocol manager. It is used to test logics in safebrowsing |
7 // service. | 7 // service. |
8 | 8 |
9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 9 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
10 | 10 |
11 #include <algorithm> | |
12 #include <utility> | 11 #include <utility> |
13 | 12 |
14 #include "base/bind.h" | 13 #include "base/bind.h" |
15 #include "base/command_line.h" | 14 #include "base/command_line.h" |
16 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
17 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
18 #include "base/macros.h" | 17 #include "base/macros.h" |
19 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
20 #include "base/metrics/field_trial.h" | 19 #include "base/metrics/field_trial.h" |
21 #include "base/path_service.h" | 20 #include "base/path_service.h" |
| 21 #include "base/stl_util.h" |
22 #include "base/strings/string_split.h" | 22 #include "base/strings/string_split.h" |
23 #include "base/strings/string_util.h" | 23 #include "base/strings/string_util.h" |
24 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
25 #include "base/test/thread_test_helper.h" | 25 #include "base/test/thread_test_helper.h" |
26 #include "base/time/time.h" | 26 #include "base/time/time.h" |
27 #include "build/build_config.h" | 27 #include "build/build_config.h" |
28 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" | 28 #include "chrome/browser/bookmarks/startup_task_runner_service_factory.h" |
29 #include "chrome/browser/browser_process.h" | 29 #include "chrome/browser/browser_process.h" |
30 #include "chrome/browser/chrome_notification_types.h" | 30 #include "chrome/browser/chrome_notification_types.h" |
31 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" | 31 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 std::vector<SBPrefix>* prefix_hits) { | 318 std::vector<SBPrefix>* prefix_hits) { |
319 bool hit = false; | 319 bool hit = false; |
320 for (const GURL& url : urls) { | 320 for (const GURL& url : urls) { |
321 base::hash_map<std::string, Hits>::const_iterator badurls_it = | 321 base::hash_map<std::string, Hits>::const_iterator badurls_it = |
322 badurls_.find(url.spec()); | 322 badurls_.find(url.spec()); |
323 | 323 |
324 if (badurls_it == badurls_.end()) | 324 if (badurls_it == badurls_.end()) |
325 continue; | 325 continue; |
326 | 326 |
327 std::vector<int> list_ids_for_url = badurls_it->second.list_ids; | 327 std::vector<int> list_ids_for_url = badurls_it->second.list_ids; |
328 if (std::find(list_ids_for_url.begin(), list_ids_for_url.end(), list_id0) | 328 if (ContainsValue(list_ids_for_url, list_id0) || |
329 != list_ids_for_url.end() || | 329 ContainsValue(list_ids_for_url, list_id1)) { |
330 std::find(list_ids_for_url.begin(), list_ids_for_url.end(), list_id1) | |
331 != list_ids_for_url.end()) { | |
332 prefix_hits->insert(prefix_hits->end(), | 330 prefix_hits->insert(prefix_hits->end(), |
333 badurls_it->second.prefix_hits.begin(), | 331 badurls_it->second.prefix_hits.begin(), |
334 badurls_it->second.prefix_hits.end()); | 332 badurls_it->second.prefix_hits.end()); |
335 hit = true; | 333 hit = true; |
336 } | 334 } |
337 } | 335 } |
338 return hit; | 336 return hit; |
339 } | 337 } |
340 | 338 |
341 std::vector<GURL> UrlsForHashes(const std::vector<SBFullHash>& full_hashes) { | 339 std::vector<GURL> UrlsForHashes(const std::vector<SBFullHash>& full_hashes) { |
(...skipping 1385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1727 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, | 1725 chrome::NOTIFICATION_SAFE_BROWSING_UPDATE_COMPLETE, |
1728 content::Source<SafeBrowsingDatabaseManager>( | 1726 content::Source<SafeBrowsingDatabaseManager>( |
1729 sb_service_->database_manager().get())); | 1727 sb_service_->database_manager().get())); |
1730 BrowserThread::PostTask( | 1728 BrowserThread::PostTask( |
1731 BrowserThread::IO, FROM_HERE, | 1729 BrowserThread::IO, FROM_HERE, |
1732 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); | 1730 base::Bind(&SafeBrowsingDatabaseManagerCookieTest::ForceUpdate, this)); |
1733 observer.Wait(); | 1731 observer.Wait(); |
1734 } | 1732 } |
1735 | 1733 |
1736 } // namespace safe_browsing | 1734 } // namespace safe_browsing |
OLD | NEW |