| 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> |
| 11 | 11 |
| 12 #include "base/callback.h" | 12 #include "base/callback.h" |
| 13 #include "components/safe_browsing_db/safebrowsing.pb.h" |
| 13 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 14 | 15 |
| 15 using content::BrowserThread; | 16 using content::BrowserThread; |
| 16 | 17 |
| 17 namespace safe_browsing { | 18 namespace safe_browsing { |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 21 #if defined(OS_WIN) |
| 22 #define PLATFORM_TYPE WINDOWS_PLATFORM |
| 23 #elif defined(OS_LINUX) |
| 24 #define PLATFORM_TYPE LINUX_PLATFORM |
| 25 #elif defined(OS_MACOSX) |
| 26 #define PLATFORM_TYPE OSX_PLATFORM |
| 27 #else |
| 28 // This should ideally never compile but it is getting compiled on Android. |
| 29 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=621647 |
| 30 // TODO(vakh): Once that bug is fixed, this should be removed. If we leave |
| 31 // the platform_type empty, the server won't recognize the request and |
| 32 // return an error response which will pollute our UMA metrics. |
| 33 #define PLATFORM_TYPE LINUX_PLATFORM |
| 34 #endif |
| 20 | 35 |
| 21 // TODO(vakh): Implement this to populate the map appopriately. | 36 // TODO(vakh): Implement this to populate the map appopriately. |
| 22 // Filed as http://crbug.com/608075 | 37 // Filed as http://crbug.com/608075 |
| 23 StoreFileNameMap GetStoreFileNameMap() { | 38 StoreFileNameMap GetStoreFileNameMap() { |
| 24 return StoreFileNameMap( | 39 return StoreFileNameMap( |
| 25 {{kUrlMalwareId, "UrlMalware.store"}, {kUrlSocengId, "UrlSoceng.store"}}); | 40 {{UpdateListIdentifier(PLATFORM_TYPE, URL, MALWARE_THREAT), |
| 41 "UrlMalware.store"}, |
| 42 {UpdateListIdentifier(PLATFORM_TYPE, URL, SOCIAL_ENGINEERING_PUBLIC), |
| 43 "UrlSoceng.store"}}); |
| 26 } | 44 } |
| 27 | 45 |
| 28 } // namespace | 46 } // namespace |
| 29 | 47 |
| 30 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) | 48 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) |
| 31 : base_path_(base_path), enabled_(false) { | 49 : base_path_(base_path), enabled_(false) { |
| 32 DCHECK(!base_path_.empty()); | 50 DCHECK(!base_path_.empty()); |
| 33 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " | 51 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " |
| 34 << "base_path_: " << base_path_.AsUTF8Unsafe(); | 52 << "base_path_: " << base_path_.AsUTF8Unsafe(); |
| 35 } | 53 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 | 147 |
| 130 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { | 148 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { |
| 131 // TODO(vakh): Implement this skeleton. | 149 // TODO(vakh): Implement this skeleton. |
| 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 150 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 133 return true; | 151 return true; |
| 134 } | 152 } |
| 135 | 153 |
| 136 bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) { | 154 bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) { |
| 137 // TODO(vakh): Implement this skeleton. | 155 // TODO(vakh): Implement this skeleton. |
| 138 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 156 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 139 if (!enabled_ || !CanCheckUrl(url)) { | 157 if (!enabled_) { |
| 140 return true; | 158 return true; |
| 141 } | 159 } |
| 142 | 160 |
| 143 // Don't defer the resource load. | 161 // Don't defer the resource load. |
| 144 return true; | 162 return true; |
| 145 } | 163 } |
| 146 | 164 |
| 147 void V4LocalDatabaseManager::CancelCheck(Client* client) { | 165 void V4LocalDatabaseManager::CancelCheck(Client* client) { |
| 148 // TODO(vakh): Implement this skeleton. | 166 // TODO(vakh): Implement this skeleton. |
| 149 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 167 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 } | 261 } |
| 244 | 262 |
| 245 void V4LocalDatabaseManager::DatabaseUpdated() { | 263 void V4LocalDatabaseManager::DatabaseUpdated() { |
| 246 if (enabled_) { | 264 if (enabled_) { |
| 247 v4_update_protocol_manager_->ScheduleNextUpdate( | 265 v4_update_protocol_manager_->ScheduleNextUpdate( |
| 248 v4_database_->GetStoreStateMap()); | 266 v4_database_->GetStoreStateMap()); |
| 249 } | 267 } |
| 250 } | 268 } |
| 251 | 269 |
| 252 } // namespace safe_browsing | 270 } // namespace safe_browsing |
| OLD | NEW |