| Index: content/browser/net/insecure_request_interceptor.h
|
| diff --git a/content/browser/net/insecure_request_interceptor.h b/content/browser/net/insecure_request_interceptor.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..1661e2956f31d2d45b869bd9ec358483969e3886
|
| --- /dev/null
|
| +++ b/content/browser/net/insecure_request_interceptor.h
|
| @@ -0,0 +1,64 @@
|
| +// Copyright 2016 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 CONTENT_BROWSER_NET_INSECURE_REQUEST_INTERCEPTOR_H_
|
| +#define CONTENT_BROWSER_NET_INSECURE_REQUEST_INTERCEPTOR_H_
|
| +
|
| +#include <stdint.h>
|
| +
|
| +#include "base/gtest_prod_util.h"
|
| +#include "base/macros.h"
|
| +#include "content/common/content_export.h"
|
| +#include "net/url_request/url_request_interceptor.h"
|
| +
|
| +class GURL;
|
| +
|
| +namespace net {
|
| +class URLRequest;
|
| +class NetworkDelegate;
|
| +}
|
| +
|
| +namespace content {
|
| +// An interceptor which implements 'upgrade-insecure-requests' by grabbing
|
| +// insecure
|
| +// requests which ought to be upgraded, and redirecting them to secure variants.
|
| +//
|
| +// https://w3c.github.io/webappsec-upgrade-insecure-requests/
|
| +class CONTENT_EXPORT InsecureRequestInterceptor
|
| + : public net::URLRequestInterceptor {
|
| + public:
|
| + InsecureRequestInterceptor();
|
| + ~InsecureRequestInterceptor() override;
|
| +
|
| + protected:
|
| + // Override from net::URLRequestInterceptor:
|
| + net::URLRequestJob* MaybeInterceptRequest(
|
| + net::URLRequest* request,
|
| + net::NetworkDelegate* delegate) const override;
|
| + net::URLRequestJob* MaybeInterceptRedirect(net::URLRequest* request,
|
| + net::NetworkDelegate* delegate,
|
| + const GURL& url) const override;
|
| +
|
| + private:
|
| + FRIEND_TEST_ALL_PREFIXES(InsecureRequestInterceptorTest,
|
| + UpgradeInsecureRequest);
|
| + FRIEND_TEST_ALL_PREFIXES(InsecureRequestInterceptorTest,
|
| + UpgradeSecureRequest);
|
| + FRIEND_TEST_ALL_PREFIXES(InsecureRequestInterceptorTest,
|
| + UpgradeInsecureRedirect);
|
| + FRIEND_TEST_ALL_PREFIXES(InsecureRequestInterceptorTest,
|
| + UpgradeSecureRedirect);
|
| +
|
| + // Returns a 'net::URLRequestRedirectJob' to the new, secure URL if the
|
| + // request should be upgraded, and 'nullptr' otherwise.
|
| + static net::URLRequestJob* MaybeUpgradeRequest(net::URLRequest* request,
|
| + net::NetworkDelegate* delegate,
|
| + const GURL& url);
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(InsecureRequestInterceptor);
|
| +};
|
| +
|
| +} // namespace content
|
| +
|
| +#endif // CONTENT_BROWSER_NET_INSECURE_REQUEST_INTERCEPTOR_H_
|
|
|