| Index: chrome/browser/safe_browsing/remote_database_manager.h
|
| diff --git a/chrome/browser/safe_browsing/remote_database_manager.h b/chrome/browser/safe_browsing/remote_database_manager.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..148a031130e8512c9f9c0243b5399b53ec4d3e1a
|
| --- /dev/null
|
| +++ b/chrome/browser/safe_browsing/remote_database_manager.h
|
| @@ -0,0 +1,96 @@
|
| +// Copyright (c) 2015 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +//
|
| +// Implementation of the SafeBrowsingDatabaseManager that sends URLs
|
| +// via IPC to a database that chromium doesn't manage locally.
|
| +
|
| +#ifndef CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_
|
| +#define CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_
|
| +
|
| +#include <hash_map>
|
| +#include <set>
|
| +#include <string>
|
| +#include <vector>
|
| +
|
| +#include "base/memory/ref_counted.h"
|
| +#include "base/memory/weak_ptr.h"
|
| +#include "chrome/browser/safe_browsing/database_manager.h"
|
| +#include "url/gurl.h"
|
| +
|
| +class AndroidSafeBrowsingAPIHandler;
|
| +
|
| +// An implementation that proxies requests to a service outside of Chromium.
|
| +// Does not manage a local database.
|
| +class RemoteSafeBrowsingDatabaseManager
|
| + : public SafeBrowsingDatabaseManager {
|
| + public:
|
| + // Need to initialize before using.
|
| + RemoteSafeBrowsingDatabaseManager();
|
| +
|
| + //
|
| + // SafeBrowsingDatabaseManager implementation
|
| + //
|
| +
|
| + // Returns true if the url's scheme can be checked.
|
| + bool CanCheckUrl(const GURL& url) const override;
|
| +
|
| + // Returns whether download protection is enabled.
|
| + bool download_protection_enabled() const override {
|
| + return false;
|
| + }
|
| +
|
| + bool CheckBrowseUrl(const GURL& url, Client* client) override;
|
| + void CancelCheck(Client* client) override;
|
| + void StartOnIOThread() override;
|
| + void StopOnIOThread(bool shutdown) override;
|
| +
|
| + // These will DCHECK fail with "not implemented".
|
| + // We may later add support for a subset of these.
|
| + bool CheckDownloadUrl(const std::vector<GURL>& url_chain,
|
| + Client* client) override;
|
| + bool CheckExtensionIDs(const std::set<std::string>& extension_ids,
|
| + Client* client) override;
|
| + bool MatchCsdWhitelistUrl(const GURL& url) override;
|
| + bool MatchMalwareIP(const std::string& ip_address) override;
|
| + bool MatchDownloadWhitelistUrl(const GURL& url) override;
|
| + bool MatchDownloadWhitelistString(const std::string& str) override;
|
| + bool MatchInclusionWhitelistUrl(const GURL& url) override;
|
| + bool IsMalwareKillSwitchOn() override;
|
| + bool IsCsdWhitelistKillSwitchOn() override;
|
| + SafeBrowsingProtocolManagerDelegate* GetProtocolManagerDelegate() override {
|
| + return NULL;
|
| + }
|
| +
|
| + //
|
| + // RemoteSafeBrowsingDatabaseManager implementation
|
| + //
|
| +
|
| + // Per-request tracker.
|
| + struct ClientRequest {
|
| + base::WeakPtr<RemoteSafeBrowsingDatabaseManager> db_manager;
|
| + // If client is null, this request was canceled or completed.
|
| + Client* client;
|
| + // URL of resource being checked.
|
| + GURL url;
|
| + // Threat types to check
|
| + std::vector<SBThreatType> threat_types;
|
| + };
|
| +
|
| + protected:
|
| + ~RemoteSafeBrowsingDatabaseManager() override;
|
| +
|
| + private:
|
| + bool enabled_;
|
| +
|
| + // Requests currently outstanding. Ptrs not owned here.
|
| + std::set<ClientRequest*> current_requests_;
|
| +
|
| + scoped_ptr<AndroidSafeBrowsingAPIHandler> api_handler_;
|
| + base::WeakPtrFactory<RemoteSafeBrowsingDatabaseManager> weak_ptr_factory_;
|
| +
|
| + friend class base::RefCountedThreadSafe<RemoteSafeBrowsingDatabaseManager>;
|
| + DISALLOW_COPY_AND_ASSIGN(RemoteSafeBrowsingDatabaseManager);
|
| +}; // class RemoteSafeBrowsingDatabaseManager
|
| +
|
| +#endif // CHROME_BROWSER_SAFE_BROWSING_REMOTE_DATABASE_MANAGER_H_
|
|
|