navigation_policy_handler.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_HANDLER_H_
  5. #define FUCHSIA_WEB_WEBENGINE_BROWSER_NAVIGATION_POLICY_HANDLER_H_
  6. #include <fuchsia/web/cpp/fidl.h>
  7. #include "base/containers/flat_set.h"
  8. #include "fuchsia_web/webengine/web_engine_export.h"
  9. class NavigationPolicyThrottle;
  10. namespace content {
  11. class NavigationHandle;
  12. } // namespace content
  13. class WEB_ENGINE_EXPORT NavigationPolicyHandler {
  14. public:
  15. NavigationPolicyHandler(
  16. fuchsia::web::NavigationPolicyProviderParams params,
  17. fidl::InterfaceHandle<fuchsia::web::NavigationPolicyProvider> delegate);
  18. ~NavigationPolicyHandler();
  19. NavigationPolicyHandler(const NavigationPolicyHandler&) = delete;
  20. NavigationPolicyHandler& operator=(const NavigationPolicyHandler&) = delete;
  21. void RegisterNavigationThrottle(
  22. NavigationPolicyThrottle* navigation_throttle);
  23. void RemoveNavigationThrottle(NavigationPolicyThrottle* navigation_throttle);
  24. bool is_provider_connected();
  25. // Sends the request to evaluate the `requested_navigation` to the
  26. // `NavigationPolicyProvider`.
  27. void EvaluateRequestedNavigation(
  28. fuchsia::web::RequestedNavigation requested_navigation,
  29. fuchsia::web::NavigationPolicyProvider::
  30. EvaluateRequestedNavigationCallback callback);
  31. // Determines whether or not the client is interested in evaluating |handle|.
  32. bool ShouldEvaluateNavigation(content::NavigationHandle* handle,
  33. fuchsia::web::NavigationPhase phase);
  34. private:
  35. void OnNavigationPolicyProviderDisconnected(zx_status_t status);
  36. fuchsia::web::NavigationPolicyProviderParams params_;
  37. fuchsia::web::NavigationPolicyProviderPtr provider_;
  38. // Keeps track of the NavigationThrottles associated with the Frame that owns
  39. // |this|.
  40. base::flat_set<NavigationPolicyThrottle*> navigation_throttles_;
  41. };
  42. #endif // FUCHSIA_WEB_WEBENGINE_BROWSER_NAVIGATION_POLICY_HANDLER_H_