Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1112)

Side by Side Diff: chrome/browser/safe_browsing/remote_database_manager.h

Issue 1110723002: Split to SafeBrowsingDatabaseManager into Local* and Remote*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move delegate mgmt to sb service. Use weak_ptr for ClientRequest Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 <set>
12 #include <string>
13 #include <vector>
14
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"
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.
mattm 2015/05/08 02:17:26 nit: clarify comment & match style guide. maybe so
Nathan Parker 2015/05/12 01:04:01 Done. Is there some other style violation here?
mattm 2015/05/12 07:00:40 Ah, no. I just meant the comment style.
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
54 //
55 // RemoteSafeBrowsingDatabaseManager implementation
56 //
57
58 private:
59 // Per-request tracker.
60 class ClientRequest {
61 public:
62 ClientRequest() : weak_factory_(this) {}
63 static void OnRequestDoneWeak(const base::WeakPtr<ClientRequest>& req,
64 SBThreatType matched_threat_type,
65 const std::string& metadata);
66 void OnRequestDone(SBThreatType matched_threat_type,
67 const std::string& metadata);
68
69 Client* client_;
70 RemoteSafeBrowsingDatabaseManager* db_manager_;
71 GURL url_;
72 base::WeakPtrFactory<ClientRequest> weak_factory_;
mattm 2015/05/08 02:17:26 I guess the members should also be private and hav
Nathan Parker 2015/05/12 01:04:01 Sure, done. My theory was that since it's a priva
73 };
74
75 ~RemoteSafeBrowsingDatabaseManager() override;
76
77 // Requests currently outstanding. This owns the ptrs.
78 std::vector<ClientRequest*> current_requests_;
79 AndroidSafeBrowsingAPIHandler api_handler_;
80 bool enabled_;
81
82 friend class base::RefCountedThreadSafe<RemoteSafeBrowsingDatabaseManager>;
83 DISALLOW_COPY_AND_ASSIGN(RemoteSafeBrowsingDatabaseManager);
84 }; // class RemoteSafeBrowsingDatabaseManager
85
86 #endif // CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698