| 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" | |
| 14 #include "content/public/browser/browser_thread.h" | 13 #include "content/public/browser/browser_thread.h" |
| 15 | 14 |
| 16 using content::BrowserThread; | 15 using content::BrowserThread; |
| 17 | 16 |
| 18 namespace safe_browsing { | 17 namespace safe_browsing { |
| 19 | 18 |
| 20 namespace { | 19 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 | |
| 35 | 20 |
| 36 // TODO(vakh): Implement this to populate the map appopriately. | 21 // TODO(vakh): Implement this to populate the map appopriately. |
| 37 // Filed as http://crbug.com/608075 | 22 // Filed as http://crbug.com/608075 |
| 38 StoreFileNameMap GetStoreFileNameMap() { | 23 StoreFileNameMap GetStoreFileNameMap() { |
| 39 return StoreFileNameMap( | 24 return StoreFileNameMap( |
| 40 {{UpdateListIdentifier(PLATFORM_TYPE, URL, MALWARE_THREAT), | 25 {{kUrlMalwareId, "UrlMalware.store"}, {kUrlSocengId, "UrlSoceng.store"}}); |
| 41 "UrlMalware.store"}, | |
| 42 {UpdateListIdentifier(PLATFORM_TYPE, URL, SOCIAL_ENGINEERING_PUBLIC), | |
| 43 "UrlSoceng.store"}}); | |
| 44 } | 26 } |
| 45 | 27 |
| 46 } // namespace | 28 } // namespace |
| 47 | 29 |
| 48 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) | 30 V4LocalDatabaseManager::V4LocalDatabaseManager(const base::FilePath& base_path) |
| 49 : base_path_(base_path), enabled_(false) { | 31 : base_path_(base_path), enabled_(false) { |
| 50 DCHECK(!base_path_.empty()); | 32 DCHECK(!base_path_.empty()); |
| 51 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " | 33 DVLOG(1) << "V4LocalDatabaseManager::V4LocalDatabaseManager: " |
| 52 << "base_path_: " << base_path_.AsUTF8Unsafe(); | 34 << "base_path_: " << base_path_.AsUTF8Unsafe(); |
| 53 } | 35 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 129 |
| 148 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { | 130 bool V4LocalDatabaseManager::IsCsdWhitelistKillSwitchOn() { |
| 149 // TODO(vakh): Implement this skeleton. | 131 // TODO(vakh): Implement this skeleton. |
| 150 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 132 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 151 return true; | 133 return true; |
| 152 } | 134 } |
| 153 | 135 |
| 154 bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) { | 136 bool V4LocalDatabaseManager::CheckBrowseUrl(const GURL& url, Client* client) { |
| 155 // TODO(vakh): Implement this skeleton. | 137 // TODO(vakh): Implement this skeleton. |
| 156 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 138 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 157 if (!enabled_) { | 139 if (!enabled_ || !CanCheckUrl(url)) { |
| 158 return true; | 140 return true; |
| 159 } | 141 } |
| 160 | 142 |
| 161 // Don't defer the resource load. | 143 // Don't defer the resource load. |
| 162 return true; | 144 return true; |
| 163 } | 145 } |
| 164 | 146 |
| 165 void V4LocalDatabaseManager::CancelCheck(Client* client) { | 147 void V4LocalDatabaseManager::CancelCheck(Client* client) { |
| 166 // TODO(vakh): Implement this skeleton. | 148 // TODO(vakh): Implement this skeleton. |
| 167 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 149 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 } | 243 } |
| 262 | 244 |
| 263 void V4LocalDatabaseManager::DatabaseUpdated() { | 245 void V4LocalDatabaseManager::DatabaseUpdated() { |
| 264 if (enabled_) { | 246 if (enabled_) { |
| 265 v4_update_protocol_manager_->ScheduleNextUpdate( | 247 v4_update_protocol_manager_->ScheduleNextUpdate( |
| 266 v4_database_->GetStoreStateMap()); | 248 v4_database_->GetStoreStateMap()); |
| 267 } | 249 } |
| 268 } | 250 } |
| 269 | 251 |
| 270 } // namespace safe_browsing | 252 } // namespace safe_browsing |
| OLD | NEW |