aw_url_loader_throttle.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2019 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. #ifndef ANDROID_WEBVIEW_BROWSER_NETWORK_SERVICE_AW_URL_LOADER_THROTTLE_H_
  5. #define ANDROID_WEBVIEW_BROWSER_NETWORK_SERVICE_AW_URL_LOADER_THROTTLE_H_
  6. #include <string>
  7. #include <vector>
  8. #include "base/memory/raw_ptr.h"
  9. #include "third_party/blink/public/common/loader/url_loader_throttle.h"
  10. #include "url/origin.h"
  11. class GURL;
  12. namespace net {
  13. class HttpRequestHeaders;
  14. }
  15. namespace android_webview {
  16. class AwResourceContext;
  17. class AwURLLoaderThrottle : public blink::URLLoaderThrottle {
  18. public:
  19. explicit AwURLLoaderThrottle(AwResourceContext* aw_resource_context);
  20. AwURLLoaderThrottle(const AwURLLoaderThrottle&) = delete;
  21. AwURLLoaderThrottle& operator=(const AwURLLoaderThrottle&) = delete;
  22. ~AwURLLoaderThrottle() override;
  23. // blink::URLLoaderThrottle implementation:
  24. void WillStartRequest(network::ResourceRequest* request,
  25. bool* defer) override;
  26. void WillRedirectRequest(
  27. net::RedirectInfo* redirect_info,
  28. const network::mojom::URLResponseHead& response_head,
  29. bool* defer,
  30. std::vector<std::string>* to_be_removed_request_headers,
  31. net::HttpRequestHeaders* modified_request_headers,
  32. net::HttpRequestHeaders* modified_cors_exempt_request_headers) override;
  33. private:
  34. void AddExtraHeadersIfNeeded(const GURL& url,
  35. net::HttpRequestHeaders* headers);
  36. raw_ptr<AwResourceContext> aw_resource_context_;
  37. std::vector<std::string> added_headers_;
  38. url::Origin original_origin_;
  39. };
  40. } // namespace android_webview
  41. #endif // ANDROID_WEBVIEW_BROWSER_NETWORK_SERVICE_AW_URL_LOADER_THROTTLE_H_