aw_url_loader_throttle_provider.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2018 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_RENDERER_AW_URL_LOADER_THROTTLE_PROVIDER_H_
  5. #define ANDROID_WEBVIEW_RENDERER_AW_URL_LOADER_THROTTLE_PROVIDER_H_
  6. #include "base/threading/thread_checker.h"
  7. #include "components/safe_browsing/content/common/safe_browsing.mojom.h"
  8. #include "mojo/public/cpp/bindings/pending_remote.h"
  9. #include "mojo/public/cpp/bindings/remote.h"
  10. #include "third_party/blink/public/common/thread_safe_browser_interface_broker_proxy.h"
  11. #include "third_party/blink/public/platform/url_loader_throttle_provider.h"
  12. namespace android_webview {
  13. // Instances must be constructed on the render thread, and then used and
  14. // destructed on a single thread, which can be different from the render thread.
  15. class AwURLLoaderThrottleProvider : public blink::URLLoaderThrottleProvider {
  16. public:
  17. AwURLLoaderThrottleProvider(
  18. blink::ThreadSafeBrowserInterfaceBrokerProxy* broker,
  19. blink::URLLoaderThrottleProviderType type);
  20. AwURLLoaderThrottleProvider& operator=(const AwURLLoaderThrottleProvider&) =
  21. delete;
  22. ~AwURLLoaderThrottleProvider() override;
  23. // blink::URLLoaderThrottleProvider implementation.
  24. std::unique_ptr<blink::URLLoaderThrottleProvider> Clone() override;
  25. blink::WebVector<std::unique_ptr<blink::URLLoaderThrottle>> CreateThrottles(
  26. int render_frame_id,
  27. const blink::WebURLRequest& request) override;
  28. void SetOnline(bool is_online) override;
  29. private:
  30. // This copy constructor works in conjunction with Clone(), not intended for
  31. // general use.
  32. AwURLLoaderThrottleProvider(const AwURLLoaderThrottleProvider& other);
  33. blink::URLLoaderThrottleProviderType type_;
  34. mojo::PendingRemote<safe_browsing::mojom::SafeBrowsing> safe_browsing_remote_;
  35. mojo::Remote<safe_browsing::mojom::SafeBrowsing> safe_browsing_;
  36. THREAD_CHECKER(thread_checker_);
  37. };
  38. } // namespace android_webview
  39. #endif // ANDROID_WEBVIEW_RENDERER_AW_URL_LOADER_THROTTLE_PROVIDER_H_