1 // Copyright 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.
5 // Implementation of the SafeBrowsingDatabaseManager that sends URLs
6 // via IPC to a database that chromium doesn't manage locally.
8 #ifndef CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_
9 #define CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_
15 #include "base/memory/ref_counted.h"
16 #include "base/memory/weak_ptr.h"
17 #include "chrome/browser/safe_browsing/android_safe_browsing_api_handler.h"
18 #include "chrome/browser/safe_browsing/database_manager.h"
21 // An implementation that proxies requests to a service outside of Chromium.
22 // Does not manage a local database.
23 class RemoteSafeBrowsingDatabaseManager
: public SafeBrowsingDatabaseManager
{
25 // Construct RemoteSafeBrowsingDatabaseManager.
26 // Must be initialized by calling StartOnIOThread() before using.
27 RemoteSafeBrowsingDatabaseManager();
30 // SafeBrowsingDatabaseManager implementation
33 bool CanCheckUrl(const GURL
& url
) const override
;
34 bool download_protection_enabled() const override
;
35 bool CheckBrowseUrl(const GURL
& url
, Client
* client
) override
;
36 void CancelCheck(Client
* client
) override
;
37 void StartOnIOThread() override
;
38 void StopOnIOThread(bool shutdown
) override
;
40 // These will fail with DCHECK() since their functionality isn't implemented.
41 // We may later add support for a subset of them.
42 bool CheckDownloadUrl(const std::vector
<GURL
>& url_chain
,
43 Client
* client
) override
;
44 bool CheckExtensionIDs(const std::set
<std::string
>& extension_ids
,
45 Client
* client
) override
;
46 bool MatchCsdWhitelistUrl(const GURL
& url
) override
;
47 bool MatchMalwareIP(const std::string
& ip_address
) override
;
48 bool MatchDownloadWhitelistUrl(const GURL
& url
) override
;
49 bool MatchDownloadWhitelistString(const std::string
& str
) override
;
50 bool MatchInclusionWhitelistUrl(const GURL
& url
) override
;
51 bool IsMalwareKillSwitchOn() override
;
52 bool IsCsdWhitelistKillSwitchOn() override
;
55 // RemoteSafeBrowsingDatabaseManager implementation
59 ~RemoteSafeBrowsingDatabaseManager() override
;
60 class ClientRequest
; // Per-request tracker.
62 // Requests currently outstanding. This owns the ptrs.
63 std::vector
<ClientRequest
*> current_requests_
;
64 AndroidSafeBrowsingAPIHandler api_handler_
;
67 friend class base::RefCountedThreadSafe
<RemoteSafeBrowsingDatabaseManager
>;
68 DISALLOW_COPY_AND_ASSIGN(RemoteSafeBrowsingDatabaseManager
);
69 }; // class RemoteSafeBrowsingDatabaseManager
71 #endif // CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_