OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Safe Browsing Database Manager implementation that manages a local | 5 // Safe Browsing Database Manager implementation that manages a local |
6 // database. This is used by Desktop Chromium. | 6 // database. This is used by Desktop Chromium. |
7 | 7 |
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ | 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ |
9 #define CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ | 9 #define CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ |
10 | 10 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 SafeBrowsingCheck(const std::vector<GURL>& urls, | 59 SafeBrowsingCheck(const std::vector<GURL>& urls, |
60 const std::vector<SBFullHash>& full_hashes, | 60 const std::vector<SBFullHash>& full_hashes, |
61 Client* client, | 61 Client* client, |
62 ListType check_type, | 62 ListType check_type, |
63 const std::vector<SBThreatType>& expected_threats); | 63 const std::vector<SBThreatType>& expected_threats); |
64 ~SafeBrowsingCheck(); | 64 ~SafeBrowsingCheck(); |
65 | 65 |
66 // Either |urls| or |full_hashes| is used to lookup database. |*_results| | 66 // Either |urls| or |full_hashes| is used to lookup database. |*_results| |
67 // are parallel vectors containing the results. They are initialized to | 67 // are parallel vectors containing the results. They are initialized to |
68 // contain SB_THREAT_TYPE_SAFE. | 68 // contain SB_THREAT_TYPE_SAFE. |
69 // |url_hit_hash| and |url_metadata| are parallel vectors containing full | |
70 // hash and metadata of a database record provided the result. They are | |
71 // initialized to be empty strings. | |
69 std::vector<GURL> urls; | 72 std::vector<GURL> urls; |
70 std::vector<SBThreatType> url_results; | 73 std::vector<SBThreatType> url_results; |
71 std::vector<std::string> url_metadata; | 74 std::vector<std::string> url_metadata; |
75 std::vector<std::string> url_hit_hash; | |
Nathan Parker
2016/02/16 21:42:00
Why is this needed?
veranika
2016/02/17 15:37:54
In the resource request incident report we don't r
| |
72 std::vector<SBFullHash> full_hashes; | 76 std::vector<SBFullHash> full_hashes; |
73 std::vector<SBThreatType> full_hash_results; | 77 std::vector<SBThreatType> full_hash_results; |
74 | 78 |
75 SafeBrowsingDatabaseManager::Client* client; | 79 SafeBrowsingDatabaseManager::Client* client; |
76 bool is_extended_reporting; | 80 bool is_extended_reporting; |
77 bool need_get_hash; | 81 bool need_get_hash; |
78 base::TimeTicks start; // When check was sent to SB service. | 82 base::TimeTicks start; // When check was sent to SB service. |
79 ListType check_type; // See comment in constructor. | 83 ListType check_type; // See comment in constructor. |
80 std::vector<SBThreatType> expected_threats; | 84 std::vector<SBThreatType> expected_threats; |
81 std::vector<SBPrefix> prefix_hits; | 85 std::vector<SBPrefix> prefix_hits; |
(...skipping 26 matching lines...) Expand all Loading... | |
108 safe_browsing::ThreatSource GetThreatSource() const override; | 112 safe_browsing::ThreatSource GetThreatSource() const override; |
109 bool ChecksAreAlwaysAsync() const override; | 113 bool ChecksAreAlwaysAsync() const override; |
110 bool CanCheckResourceType(content::ResourceType resource_type) const override; | 114 bool CanCheckResourceType(content::ResourceType resource_type) const override; |
111 bool CanCheckUrl(const GURL& url) const override; | 115 bool CanCheckUrl(const GURL& url) const override; |
112 | 116 |
113 bool CheckBrowseUrl(const GURL& url, Client* client) override; | 117 bool CheckBrowseUrl(const GURL& url, Client* client) override; |
114 bool CheckDownloadUrl(const std::vector<GURL>& url_chain, | 118 bool CheckDownloadUrl(const std::vector<GURL>& url_chain, |
115 Client* client) override; | 119 Client* client) override; |
116 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, | 120 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, |
117 Client* client) override; | 121 Client* client) override; |
122 bool CheckResourceUrl(const GURL& url, Client* client) override; | |
118 bool MatchCsdWhitelistUrl(const GURL& url) override; | 123 bool MatchCsdWhitelistUrl(const GURL& url) override; |
119 bool MatchMalwareIP(const std::string& ip_address) override; | 124 bool MatchMalwareIP(const std::string& ip_address) override; |
120 bool MatchDownloadWhitelistUrl(const GURL& url) override; | 125 bool MatchDownloadWhitelistUrl(const GURL& url) override; |
121 bool MatchDownloadWhitelistString(const std::string& str) override; | 126 bool MatchDownloadWhitelistString(const std::string& str) override; |
122 bool MatchInclusionWhitelistUrl(const GURL& url) override; | 127 bool MatchInclusionWhitelistUrl(const GURL& url) override; |
123 bool IsMalwareKillSwitchOn() override; | 128 bool IsMalwareKillSwitchOn() override; |
124 bool IsCsdWhitelistKillSwitchOn() override; | 129 bool IsCsdWhitelistKillSwitchOn() override; |
125 void CancelCheck(Client* client) override; | 130 void CancelCheck(Client* client) override; |
126 void StartOnIOThread() override; | 131 void StartOnIOThread() override; |
127 void StopOnIOThread(bool shutdown) override; | 132 void StopOnIOThread(bool shutdown) override; |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
278 void TimeoutCallback(SafeBrowsingCheck* check); | 283 void TimeoutCallback(SafeBrowsingCheck* check); |
279 | 284 |
280 // Calls the Client's callback on IO thread after CheckDownloadUrl finishes. | 285 // Calls the Client's callback on IO thread after CheckDownloadUrl finishes. |
281 void OnAsyncCheckDone(SafeBrowsingCheck* check, | 286 void OnAsyncCheckDone(SafeBrowsingCheck* check, |
282 const std::vector<SBPrefix>& prefix_hits); | 287 const std::vector<SBPrefix>& prefix_hits); |
283 | 288 |
284 // Checks all extension ID hashes on |safe_browsing_task_runner_|. | 289 // Checks all extension ID hashes on |safe_browsing_task_runner_|. |
285 std::vector<SBPrefix> CheckExtensionIDsOnSBThread( | 290 std::vector<SBPrefix> CheckExtensionIDsOnSBThread( |
286 const std::vector<SBPrefix>& prefixes); | 291 const std::vector<SBPrefix>& prefixes); |
287 | 292 |
293 // Checks all resource URL hashes on |safe_browsing_task_runner_|. | |
294 std::vector<SBPrefix> CheckResourceUrlOnSBThread( | |
295 const std::vector<SBPrefix>& prefixes); | |
296 | |
288 // Helper function that calls safe browsing client and cleans up |checks_|. | 297 // Helper function that calls safe browsing client and cleans up |checks_|. |
289 void SafeBrowsingCheckDone(SafeBrowsingCheck* check); | 298 void SafeBrowsingCheckDone(SafeBrowsingCheck* check); |
290 | 299 |
291 // Helper function to set |check| with default values and start a safe | 300 // Helper function to set |check| with default values and start a safe |
292 // browsing check with timeout of |timeout|. |task| will be called on | 301 // browsing check with timeout of |timeout|. |task| will be called on |
293 // success, otherwise TimeoutCallback will be called. | 302 // success, otherwise TimeoutCallback will be called. |
294 void StartSafeBrowsingCheck( | 303 void StartSafeBrowsingCheck( |
295 SafeBrowsingCheck* check, | 304 SafeBrowsingCheck* check, |
296 const base::Callback<std::vector<SBPrefix>(void)>& task); | 305 const base::Callback<std::vector<SBPrefix>(void)>& task); |
297 | 306 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
337 | 346 |
338 // Indicate if the extension blacklist should be enabled. | 347 // Indicate if the extension blacklist should be enabled. |
339 bool enable_extension_blacklist_; | 348 bool enable_extension_blacklist_; |
340 | 349 |
341 // Indicate if the csd malware IP blacklist should be enabled. | 350 // Indicate if the csd malware IP blacklist should be enabled. |
342 bool enable_ip_blacklist_; | 351 bool enable_ip_blacklist_; |
343 | 352 |
344 // Indicate if the unwanted software blacklist should be enabled. | 353 // Indicate if the unwanted software blacklist should be enabled. |
345 bool enable_unwanted_software_blacklist_; | 354 bool enable_unwanted_software_blacklist_; |
346 | 355 |
356 // Indicate if the resources blacklist should be enabled. | |
357 bool enable_resource_blacklist_; | |
Nathan Parker
2016/02/16 21:42:00
Do you need this? If you want a flag or a finch c
veranika
2016/02/17 15:37:54
Probably I don't. I added it here mostly to be uni
| |
358 | |
347 // The sequenced task runner for running safe browsing database operations. | 359 // The sequenced task runner for running safe browsing database operations. |
348 scoped_refptr<base::SequencedTaskRunner> safe_browsing_task_runner_; | 360 scoped_refptr<base::SequencedTaskRunner> safe_browsing_task_runner_; |
349 | 361 |
350 // Indicates if we're currently in an update cycle. | 362 // Indicates if we're currently in an update cycle. |
351 bool update_in_progress_; | 363 bool update_in_progress_; |
352 | 364 |
353 // When true, newly fetched chunks may not in the database yet since the | 365 // When true, newly fetched chunks may not in the database yet since the |
354 // database is still updating. | 366 // database is still updating. |
355 bool database_update_in_progress_; | 367 bool database_update_in_progress_; |
356 | 368 |
357 // Indicates if we're in the midst of trying to close the database. If this | 369 // Indicates if we're in the midst of trying to close the database. If this |
358 // is true, nothing on the IO thread should access the database. | 370 // is true, nothing on the IO thread should access the database. |
359 bool closing_database_; | 371 bool closing_database_; |
360 | 372 |
361 std::deque<QueuedCheck> queued_checks_; | 373 std::deque<QueuedCheck> queued_checks_; |
362 | 374 |
363 // Timeout to use for safe browsing checks. | 375 // Timeout to use for safe browsing checks. |
364 base::TimeDelta check_timeout_; | 376 base::TimeDelta check_timeout_; |
365 | 377 |
366 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager); | 378 DISALLOW_COPY_AND_ASSIGN(LocalSafeBrowsingDatabaseManager); |
367 }; // class LocalSafeBrowsingDatabaseManager | 379 }; // class LocalSafeBrowsingDatabaseManager |
368 | 380 |
369 } // namespace safe_browsing | 381 } // namespace safe_browsing |
370 | 382 |
371 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ | 383 #endif // CHROME_BROWSER_SAFE_BROWSING_LOCAL_DATABASE_MANAGER_H_ |
OLD | NEW |