| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/safe_browsing_db/database_manager.h" | 5 #include "components/safe_browsing_db/database_manager.h" |
| 6 | 6 |
| 7 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" | 7 #include "components/safe_browsing_db/v4_get_hash_protocol_manager.h" |
| 8 #include "content/public/browser/browser_thread.h" | 8 #include "content/public/browser/browser_thread.h" |
| 9 #include "net/url_request/url_request_context_getter.h" | 9 #include "net/url_request/url_request_context_getter.h" |
| 10 #include "url/gurl.h" | 10 #include "url/gurl.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 base::Unretained(this), check)); | 79 base::Unretained(this), check)); |
| 80 | 80 |
| 81 return false; | 81 return false; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void SafeBrowsingDatabaseManager::HandleGetHashesWithApisResults( | 84 void SafeBrowsingDatabaseManager::HandleGetHashesWithApisResults( |
| 85 std::shared_ptr<SafeBrowsingApiCheck> check, | 85 std::shared_ptr<SafeBrowsingApiCheck> check, |
| 86 const std::vector<SBFullHashResult>& full_hash_results, | 86 const std::vector<SBFullHashResult>& full_hash_results, |
| 87 const base::TimeDelta& negative_cache_duration) { | 87 const base::TimeDelta& negative_cache_duration) { |
| 88 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 88 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 89 // TODO(kcarattini): Implement response handler. | 89 DCHECK(check); |
| 90 |
| 91 ThreatMetadata md; |
| 92 // Merge the metadata from all matching results. |
| 93 // TODO(kcarattini): This is O(N^2). Look at improving performance by |
| 94 // using a map, sorting or doing binary search etc.. |
| 95 for (const SBFullHashResult& result : full_hash_results) { |
| 96 for (const SBFullHash& full_hash : check->full_hashes()) { |
| 97 if (SBFullHashEqual(full_hash, result.hash)) { |
| 98 md.api_permissions.insert(md.api_permissions.end(), |
| 99 result.metadata.api_permissions.begin(), |
| 100 result.metadata.api_permissions.end()); |
| 101 break; |
| 102 } |
| 103 } |
| 104 } |
| 105 |
| 106 check->client()->OnCheckApiBlacklistUrlResult(check->url(), md); |
| 90 } | 107 } |
| 91 | 108 |
| 92 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::SafeBrowsingApiCheck( | 109 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::SafeBrowsingApiCheck( |
| 93 const GURL& url, const std::vector<SBFullHash>& full_hashes, Client* client) | 110 const GURL& url, const std::vector<SBFullHash>& full_hashes, Client* client) |
| 94 : url_(url), full_hashes_(full_hashes), client_(client) { | 111 : url_(url), full_hashes_(full_hashes), client_(client) { |
| 95 } | 112 } |
| 96 | 113 |
| 97 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::~SafeBrowsingApiCheck() { | 114 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::~SafeBrowsingApiCheck() { |
| 98 } | 115 } |
| 99 | 116 |
| 100 } // namespace safe_browsing | 117 } // namespace safe_browsing |
| OLD | NEW |