Chromium Code Reviews| 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); |
|
Nathan Parker
2016/04/15 23:22:00
Sounds like a microphone check. "Check. Check. Ch
kcarattini
2016/04/18 07:12:02
Acknowledged.
| |
| 90 | |
| 91 ThreatMetadata md; | |
| 92 // Merge the metadata from all matching results. | |
| 93 for (const SBFullHashResult& result : full_hash_results) { | |
|
Nathan Parker
2016/04/15 23:22:00
This is sort of O(N^2), where N is small but could
kcarattini
2016/04/18 07:12:02
Done.
| |
| 94 for (const SBFullHash& full_hash : check->full_hashes()) { | |
| 95 if (SBFullHashEqual(full_hash, result.hash)) { | |
| 96 md.api_permissions.insert(md.api_permissions.end(), | |
| 97 result.metadata.api_permissions.begin(), | |
| 98 result.metadata.api_permissions.end()); | |
| 99 break; | |
| 100 } | |
| 101 } | |
| 102 } | |
| 103 | |
| 104 check->client()->OnCheckApiBlacklistUrlResult(check->url(), md); | |
|
Nathan Parker
2016/04/15 23:22:00
Consider if we need the URL to be passed here, and
kcarattini
2016/04/18 07:12:02
I can imagine a client making calls for multiple u
Nathan Parker
2016/04/18 17:34:09
k. Another approach is that the caller could use
| |
| 90 } | 105 } |
| 91 | 106 |
| 92 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::SafeBrowsingApiCheck( | 107 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::SafeBrowsingApiCheck( |
| 93 const GURL& url, const std::vector<SBFullHash>& full_hashes, Client* client) | 108 const GURL& url, const std::vector<SBFullHash>& full_hashes, Client* client) |
| 94 : url_(url), full_hashes_(full_hashes), client_(client) { | 109 : url_(url), full_hashes_(full_hashes), client_(client) { |
| 95 } | 110 } |
| 96 | 111 |
| 97 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::~SafeBrowsingApiCheck() { | 112 SafeBrowsingDatabaseManager::SafeBrowsingApiCheck::~SafeBrowsingApiCheck() { |
| 98 } | 113 } |
| 99 | 114 |
| 100 } // namespace safe_browsing | 115 } // namespace safe_browsing |
| OLD | NEW |