navigation_policy_throttle.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright 2020 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 FUCHSIA_WEB_WEBENGINE_BROWSER_NAVIGATION_POLICY_THROTTLE_H_
  5. #define FUCHSIA_WEB_WEBENGINE_BROWSER_NAVIGATION_POLICY_THROTTLE_H_
  6. #include <fuchsia/web/cpp/fidl.h>
  7. #include "content/public/browser/navigation_throttle.h"
  8. #include "fuchsia_web/webengine/web_engine_export.h"
  9. class NavigationPolicyHandler;
  10. class WEB_ENGINE_EXPORT NavigationPolicyThrottle
  11. : public content::NavigationThrottle {
  12. public:
  13. explicit NavigationPolicyThrottle(content::NavigationHandle* handle,
  14. NavigationPolicyHandler* policy_handler);
  15. ~NavigationPolicyThrottle() override;
  16. NavigationPolicyThrottle(const NavigationPolicyThrottle&) = delete;
  17. NavigationPolicyThrottle& operator=(const NavigationPolicyThrottle&) = delete;
  18. void OnNavigationPolicyProviderDisconnected(ThrottleCheckResult check_result);
  19. // content::NavigationThrottle implementation.
  20. ThrottleCheckResult WillStartRequest() override;
  21. ThrottleCheckResult WillRedirectRequest() override;
  22. ThrottleCheckResult WillFailRequest() override;
  23. ThrottleCheckResult WillProcessResponse() override;
  24. const char* GetNameForLogging() override;
  25. private:
  26. void OnRequestedNavigationEvaluated(
  27. fuchsia::web::NavigationDecision decision);
  28. content::NavigationThrottle::ThrottleCheckResult HandleNavigationPhase(
  29. fuchsia::web::NavigationPhase phase);
  30. NavigationPolicyHandler* policy_handler_;
  31. content::NavigationHandle* navigation_handle_;
  32. // Indicates if the navigation is currently paused.
  33. bool is_paused_ = false;
  34. // Used for `EvaluateRequestedNavigation()` results callbacks that may outlive
  35. // this object.
  36. base::WeakPtrFactory<NavigationPolicyThrottle> weak_factory_{this};
  37. };
  38. #endif // FUCHSIA_WEB_WEBENGINE_BROWSER_NAVIGATION_POLICY_THROTTLE_H_