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 "chrome/browser/safe_browsing/android_safe_browsing_api_handler.h" | |
18 #include "chrome/browser/safe_browsing/database_manager.h" | |
19 #include "url/gurl.h" | |
20 | |
21 // An implementation that proxies requests to a service outside of Chromium. | |
22 // Does not manage a local database. | |
23 class RemoteSafeBrowsingDatabaseManager | |
24 : public SafeBrowsingDatabaseManager { | |
25 public: | |
26 // Need to initialize before using. | |
27 RemoteSafeBrowsingDatabaseManager(); | |
28 | |
29 // | |
30 // SafeBrowsingDatabaseManager implementation | |
31 // | |
32 | |
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; | |
39 | |
40 // These will DCHECK fail with "not implemented". | |
41 // We may later add support for a subset of these. | |
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; | |
53 SafeBrowsingProtocolManagerDelegate* GetProtocolManagerDelegate() override; | |
54 | |
55 // | |
56 // RemoteSafeBrowsingDatabaseManager implementation | |
57 // | |
58 | |
59 protected: | |
mattm
2015/05/06 02:42:46
Why are these things protected instead of private?
Nathan Parker
2015/05/06 22:27:36
Fixed.
| |
60 ~RemoteSafeBrowsingDatabaseManager() override; | |
61 bool enabled_; | |
mattm
2015/05/06 02:42:46
members should go after all types and methods in t
Nathan Parker
2015/05/06 22:27:36
Done.
| |
62 | |
63 // Per-request tracker. | |
64 class ClientRequest : public base::RefCounted<ClientRequest> { | |
mattm
2015/05/06 02:42:45
I think generally inner classes will go near the t
Nathan Parker
2015/05/06 22:27:36
Done.
| |
65 public: | |
66 // Passes the results to client, if it's not null. | |
67 void OnRequestDone(SBThreatType matched_threat_type, | |
68 const std::string& metadata); | |
69 | |
70 Client* client; | |
mattm
2015/05/06 02:42:45
members of classes should have trailing _
Nathan Parker
2015/05/06 22:27:36
Done.
| |
71 // Only valid if client is not NULL. | |
72 RemoteSafeBrowsingDatabaseManager* db_manager; | |
73 GURL url; | |
74 | |
75 private: | |
76 friend class base::RefCounted<ClientRequest>; | |
77 }; | |
78 | |
79 // Requests currently outstanding. | |
80 std::vector<scoped_refptr<ClientRequest>> current_requests_; | |
81 | |
82 AndroidSafeBrowsingAPIHandler api_handler_; | |
83 | |
84 private: | |
85 friend class base::RefCountedThreadSafe<RemoteSafeBrowsingDatabaseManager>; | |
86 DISALLOW_COPY_AND_ASSIGN(RemoteSafeBrowsingDatabaseManager); | |
87 }; // class RemoteSafeBrowsingDatabaseManager | |
88 | |
89 #endif // CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_ | |
OLD | NEW |