| Index: components/safe_browsing/resource_throttle.h
|
| diff --git a/components/safe_browsing/resource_throttle.h b/components/safe_browsing/resource_throttle.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..7e32c521fb9600fd3d2e8e8cc2dcb263d47507cd
|
| --- /dev/null
|
| +++ b/components/safe_browsing/resource_throttle.h
|
| @@ -0,0 +1,101 @@
|
| +// Copyright (c) 2017 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.
|
| +
|
| +#ifndef COMPONENTS_SAFE_BROWSING_RESOURCE_THROTTLE_H_
|
| +#define COMPONENTS_SAFE_BROWSING_RESOURCE_THROTTLE_H_
|
| +
|
| +#include <memory>
|
| +#include <vector>
|
| +
|
| +#include "base/callback.h"
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "components/safe_browsing/request_checker.h"
|
| +#include "content/public/browser/resource_throttle.h"
|
| +#include "content/public/common/resource_type.h"
|
| +
|
| +namespace net {
|
| +class URLRequest;
|
| +}
|
| +
|
| +namespace security_interstitials {
|
| +struct UnsafeResource;
|
| +}
|
| +
|
| +namespace safe_browsing {
|
| +
|
| +class BaseUIManager;
|
| +class SafeBrowsingDatabaseManager;
|
| +
|
| +// ResourceThrottle checks that URLs are "safe" before
|
| +// navigating to them. To be considered "safe", a URL must not appear in the
|
| +// malware/phishing blacklists (see SafeBrowsingService for details).
|
| +//
|
| +// Note that the safe browsing check takes at most kCheckUrlTimeoutMs
|
| +// milliseconds. If it takes longer than this, then the system defaults to
|
| +// treating the URL as safe.
|
| +//
|
| +// If the URL is classified as dangerous, a warning page is thrown up and
|
| +// the request remains suspended. If the user clicks "proceed" on warning
|
| +// page, we resume the request.
|
| +//
|
| +// Note: The ResourceThrottle interface is called in this order:
|
| +// WillStartRequest once, WillRedirectRequest zero or more times, and then
|
| +// WillProcessReponse once.
|
| +class ResourceThrottle final : public content::ResourceThrottle,
|
| + public RequestChecker::Delegate {
|
| + public:
|
| + class Delegate {
|
| + public:
|
| + Delegate() {}
|
| + virtual ~Delegate() {}
|
| + virtual void MaybeDestroyPrerenderContents(
|
| + const net::URLRequest* request) = 0;
|
| + virtual void StartDisplayingBlockingPage(
|
| + const security_interstitials::UnsafeResource& resource,
|
| + scoped_refptr<BaseUIManager> ui_manager,
|
| + base::OnceClosure cancel_on_io_thread) = 0;
|
| +
|
| + private:
|
| + DISALLOW_COPY_AND_ASSIGN(Delegate);
|
| + };
|
| +
|
| + ResourceThrottle(const net::URLRequest* request,
|
| + content::ResourceType resource_type,
|
| + scoped_refptr<SafeBrowsingDatabaseManager> database_manager,
|
| + scoped_refptr<BaseUIManager> ui_manager,
|
| + std::unique_ptr<Delegate> delegate);
|
| +
|
| + ~ResourceThrottle() final;
|
| +
|
| + // content::ResourceThrottle implementation (called on IO thread):
|
| + void WillStartRequest(bool* defer) final;
|
| + void WillRedirectRequest(const net::RedirectInfo& redirect_info,
|
| + bool* defer) final;
|
| + void WillProcessResponse(bool* defer) final;
|
| + bool MustProcessResponseBeforeReadingBody() final;
|
| +
|
| + const char* GetNameForLogging() const final;
|
| +
|
| + // RequestChecker::Delegate implementation.
|
| + void MaybeDestroyPrerenderContents(const net::URLRequest* request) final;
|
| + RequestChecker::Delegate::WebContentsGetter GetWebContentsGetterForRequest(
|
| + const net::URLRequest* request) const final;
|
| + void StartDisplayingBlockingPage(
|
| + const security_interstitials::UnsafeResource& resource,
|
| + scoped_refptr<BaseUIManager> ui_manager) final;
|
| + void CancelResourceLoad() final;
|
| + void ResumeResourceRequest() final;
|
| +
|
| + private:
|
| + RequestChecker request_checker_;
|
| + std::unique_ptr<Delegate> delegate_;
|
| + base::WeakPtrFactory<ResourceThrottle> weak_factory_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ResourceThrottle);
|
| +};
|
| +
|
| +} // namespace safe_browsing
|
| +
|
| +#endif // COMPONENTS_SAFE_BROWSING_RESOURCE_THROTTLE_H_
|
|
|