url_request_rewrite_type_converters.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435
  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 FUCHSIA_WEB_WEBENGINE_BROWSER_URL_REQUEST_REWRITE_TYPE_CONVERTERS_H_
  5. #define FUCHSIA_WEB_WEBENGINE_BROWSER_URL_REQUEST_REWRITE_TYPE_CONVERTERS_H_
  6. #include <fuchsia/web/cpp/fidl.h>
  7. #include "components/url_rewrite/mojom/url_request_rewrite.mojom.h"
  8. #include "fuchsia_web/webengine/web_engine_export.h"
  9. #include "mojo/public/cpp/bindings/type_converter.h"
  10. namespace mojo {
  11. // This conversion is done with a TypeCoverter rather than a typemap because
  12. // it is only done one way, from the FIDL type to the Mojo type. This conversion
  13. // is only done once, in the browser process. These rules are validated after
  14. // they have been converted into Mojo.
  15. // In WebEngine, we have a one-way flow from the untrusted embedder into the
  16. // browser process, via a FIDL API. From there, the rules are converted into
  17. // Mojo and then validated before being sent to renderer processes. No further
  18. // conversion is performed, the Mojo types are used as is to apply the rewrites
  19. // on URL requests.
  20. template <>
  21. struct WEB_ENGINE_EXPORT
  22. TypeConverter<url_rewrite::mojom::UrlRequestRewriteRulesPtr,
  23. std::vector<fuchsia::web::UrlRequestRewriteRule>> {
  24. static url_rewrite::mojom::UrlRequestRewriteRulesPtr Convert(
  25. const std::vector<fuchsia::web::UrlRequestRewriteRule>& input);
  26. };
  27. } // namespace mojo
  28. #endif // FUCHSIA_WEB_WEBENGINE_BROWSER_URL_REQUEST_REWRITE_TYPE_CONVERTERS_H_