| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 file should not be build on Android but is currently getting built. | 5 // This file should not be build on Android but is currently getting built. |
| 6 // TODO(vakh): Fix that: http://crbug.com/621647 | 6 // TODO(vakh): Fix that: http://crbug.com/621647 |
| 7 | 7 |
| 8 #include "components/safe_browsing_db/v4_local_database_manager.h" | 8 #include "components/safe_browsing_db/v4_local_database_manager.h" |
| 9 | 9 |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 return true; | 127 return true; |
| 128 } | 128 } |
| 129 | 129 |
| 130 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { | 130 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { |
| 131 // TODO(vakh): Implement this skeleton. | 131 // TODO(vakh): Implement this skeleton. |
| 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 133 return true; | 133 return true; |
| 134 } | 134 } |
| 135 | 135 |
| 136 bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) { | 136 bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) { |
| 137 // TODO(vakh): Implement this skeleton. | |
| 138 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 137 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 139 if (!enabled_ || !CanCheckUrl(url)) { | 138 if (!enabled_ || !CanCheckUrl(url)) { |
| 140 return true; | 139 return true; |
| 141 } | 140 } |
| 142 | 141 |
| 143 if (v4_database_) { | 142 if (v4_database_) { |
| 144 base::hash_set<FullHash> full_hashes; | 143 base::hash_set<FullHash> full_hashes; |
| 145 V4ProtocolManagerUtil::UrlToFullHashes(url, &full_hashes); | 144 V4ProtocolManagerUtil::UrlToFullHashes(url, &full_hashes); |
| 146 | 145 |
| 147 base::hash_set<UpdateListIdentifier> stores_to_look( | 146 base::hash_set<UpdateListIdentifier> stores_to_look( |
| 148 {GetUrlMalwareId(), GetUrlSocEngId()}); | 147 {GetUrlMalwareId(), GetUrlSocEngId()}); |
| 149 base::hash_set<HashPrefix> matched_hash_prefixes; | 148 base::hash_set<HashPrefix> matched_hash_prefixes; |
| 150 base::hash_set<UpdateListIdentifier> matched_stores; | 149 base::hash_set<UpdateListIdentifier> matched_stores; |
| 151 MatchedHashPrefixMap matched_hash_prefix_map; | 150 StoreAndHashPrefixes matched_store_and_full_hashes; |
| 151 FullHashToStoreAndHashPrefixesMap full_hash_to_store_and_hash_prefixes; |
| 152 for (const auto& full_hash : full_hashes) { | 152 for (const auto& full_hash : full_hashes) { |
| 153 matched_store_and_full_hashes.clear(); |
| 153 v4_database_->GetStoresMatchingFullHash(full_hash, stores_to_look, | 154 v4_database_->GetStoresMatchingFullHash(full_hash, stores_to_look, |
| 154 &matched_hash_prefix_map); | 155 &matched_store_and_full_hashes); |
| 155 for (const auto& matched_pair : matched_hash_prefix_map) { | 156 if (!matched_store_and_full_hashes.empty()) { |
| 156 matched_stores.insert(matched_pair.first); | 157 full_hash_to_store_and_hash_prefixes[full_hash] = |
| 157 matched_hash_prefixes.insert(matched_pair.second); | 158 matched_store_and_full_hashes; |
| 158 } | 159 } |
| 159 } | 160 } |
| 160 | 161 |
| 161 DCHECK_EQ(matched_stores.empty(), matched_hash_prefixes.empty()); | 162 if (full_hash_to_store_and_hash_prefixes.empty()) { |
| 162 | 163 return true; |
| 163 // TODO(vakh): Return false and fetch full hashes for the matching hash | 164 } else { |
| 164 // prefixes. | 165 // TODO(vakh): Pass more information to the callback for it to be able to |
| 165 return matched_hash_prefixes.empty(); | 166 // do something meaningful. |
| 167 v4_get_hash_protocol_manager_->GetFullHashes( |
| 168 full_hash_to_store_and_hash_prefixes, |
| 169 base::Bind(&V4LocalDatabaseManager::OnFullHashResponse, |
| 170 base::Unretained(this))); |
| 171 return false; |
| 172 } |
| 166 } else { | 173 } else { |
| 167 // TODO(vakh): Queue the check and process it when the database becomes | 174 // TODO(vakh): Queue the check and process it when the database becomes |
| 168 // ready. | 175 // ready. |
| 169 return false; | 176 return false; |
| 170 } | 177 } |
| 171 } | 178 } |
| 172 | 179 |
| 180 void V4LocalDatabaseManager::OnFullHashResponse( |
| 181 const std::vector<FullHashInfo>& full_hash_infos) { |
| 182 // TODO(vakh): Implement this skeleton. |
| 183 } |
| 184 |
| 173 void V4LocalDatabaseManager::CancelCheck(Client* client) { | 185 void V4LocalDatabaseManager::CancelCheck(Client* client) { |
| 174 // TODO(vakh): Implement this skeleton. | 186 // TODO(vakh): Implement this skeleton. |
| 175 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 187 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 176 DCHECK(enabled_); | 188 DCHECK(enabled_); |
| 177 } | 189 } |
| 178 | 190 |
| 179 void V4LocalDatabaseManager::StartOnIOThread( | 191 void V4LocalDatabaseManager::StartOnIOThread( |
| 180 net::URLRequestContextGetter* request_context_getter, | 192 net::URLRequestContextGetter* request_context_getter, |
| 181 const V4ProtocolConfig& config) { | 193 const V4ProtocolConfig& config) { |
| 182 SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config); | 194 SafeBrowsingDatabaseManager::StartOnIOThread(request_context_getter, config); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 } | 281 } |
| 270 | 282 |
| 271 void V4LocalDatabaseManager::DatabaseUpdated() { | 283 void V4LocalDatabaseManager::DatabaseUpdated() { |
| 272 if (enabled_) { | 284 if (enabled_) { |
| 273 v4_update_protocol_manager_->ScheduleNextUpdate( | 285 v4_update_protocol_manager_->ScheduleNextUpdate( |
| 274 v4_database_->GetStoreStateMap()); | 286 v4_database_->GetStoreStateMap()); |
| 275 } | 287 } |
| 276 } | 288 } |
| 277 | 289 |
| 278 } // namespace safe_browsing | 290 } // namespace safe_browsing |
| OLD | NEW |