OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 // |
| 5 // Implementation of the SafeBrowsingDatabaseManager that sends URLs |
| 6 // via IPC to a database that chromium doesn't manage locally. |
| 7 |
| 8 #ifndef CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_ |
| 9 #define CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_ |
| 10 |
| 11 #include <hash_map> |
| 12 #include <set> |
| 13 #include <string> |
| 14 #include <vector> |
| 15 |
| 16 #include "base/memory/ref_counted.h" |
| 17 #include "base/memory/weak_ptr.h" |
| 18 #include "chrome/browser/safe_browsing/database_manager.h" |
| 19 #include "url/gurl.h" |
| 20 |
| 21 class AndroidSafeBrowsingAPIHandler; |
| 22 |
| 23 // An implementation that proxies requests to a service outside of Chromium. |
| 24 // Does not manage a local database. |
| 25 class RemoteSafeBrowsingDatabaseManager |
| 26 : public SafeBrowsingDatabaseManager { |
| 27 public: |
| 28 // Need to initialize before using. |
| 29 RemoteSafeBrowsingDatabaseManager(); |
| 30 |
| 31 // |
| 32 // SafeBrowsingDatabaseManager implementation |
| 33 // |
| 34 |
| 35 // Returns true if the url's scheme can be checked. |
| 36 bool CanCheckUrl(const GURL& url) const override; |
| 37 |
| 38 // Returns whether download protection is enabled. |
| 39 bool download_protection_enabled() const override { |
| 40 return false; |
| 41 } |
| 42 |
| 43 bool CheckBrowseUrl(const GURL& url, Client* client) override; |
| 44 void CancelCheck(Client* client) override; |
| 45 void StartOnIOThread() override; |
| 46 void StopOnIOThread(bool shutdown) override; |
| 47 |
| 48 // These will DCHECK fail with "not implemented". |
| 49 // We may later add support for a subset of these. |
| 50 bool CheckDownloadUrl(const std::vector<GURL>& url_chain, |
| 51 Client* client) override; |
| 52 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, |
| 53 Client* client) override; |
| 54 bool MatchCsdWhitelistUrl(const GURL& url) override; |
| 55 bool MatchMalwareIP(const std::string& ip_address) override; |
| 56 bool MatchDownloadWhitelistUrl(const GURL& url) override; |
| 57 bool MatchDownloadWhitelistString(const std::string& str) override; |
| 58 bool MatchInclusionWhitelistUrl(const GURL& url) override; |
| 59 bool IsMalwareKillSwitchOn() override; |
| 60 bool IsCsdWhitelistKillSwitchOn() override; |
| 61 SafeBrowsingProtocolManagerDelegate* GetProtocolManagerDelegate() override { |
| 62 return NULL; |
| 63 } |
| 64 |
| 65 // |
| 66 // RemoteSafeBrowsingDatabaseManager implementation |
| 67 // |
| 68 |
| 69 // Per-request tracker. |
| 70 struct ClientRequest { |
| 71 base::WeakPtr<RemoteSafeBrowsingDatabaseManager> db_manager; |
| 72 // If client is null, this request was canceled or completed. |
| 73 Client* client; |
| 74 // URL of resource being checked. |
| 75 GURL url; |
| 76 // Threat types to check |
| 77 std::vector<SBThreatType> threat_types; |
| 78 }; |
| 79 |
| 80 protected: |
| 81 ~RemoteSafeBrowsingDatabaseManager() override; |
| 82 |
| 83 private: |
| 84 bool enabled_; |
| 85 |
| 86 // Requests currently outstanding. Ptrs not owned here. |
| 87 std::set<ClientRequest*> current_requests_; |
| 88 |
| 89 scoped_ptr<AndroidSafeBrowsingAPIHandler> api_handler_; |
| 90 base::WeakPtrFactory<RemoteSafeBrowsingDatabaseManager> weak_ptr_factory_; |
| 91 |
| 92 friend class base::RefCountedThreadSafe<RemoteSafeBrowsingDatabaseManager>; |
| 93 DISALLOW_COPY_AND_ASSIGN(RemoteSafeBrowsingDatabaseManager); |
| 94 }; // class RemoteSafeBrowsingDatabaseManager |
| 95 |
| 96 #endif // CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_ |
OLD | NEW |