blink_converter.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. // Copyright (c) 2015 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ELECTRON_SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_H_
  5. #define ELECTRON_SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_H_
  6. #include "gin/converter.h"
  7. #include "third_party/blink/public/common/context_menu_data/context_menu_data.h"
  8. #include "third_party/blink/public/common/input/web_input_event.h"
  9. #include "third_party/blink/public/common/messaging/cloneable_message.h"
  10. #include "third_party/blink/public/common/web_cache/web_cache_resource_type_stats.h"
  11. #include "third_party/blink/public/mojom/devtools/console_message.mojom-forward.h"
  12. #include "third_party/blink/public/mojom/loader/referrer.mojom-forward.h"
  13. namespace blink {
  14. class WebMouseEvent;
  15. class WebMouseWheelEvent;
  16. class WebKeyboardEvent;
  17. struct DeviceEmulationParams;
  18. } // namespace blink
  19. namespace gin {
  20. blink::WebInputEvent::Type GetWebInputEventType(v8::Isolate* isolate,
  21. v8::Local<v8::Value> val);
  22. template <>
  23. struct Converter<blink::WebInputEvent::Type> {
  24. static bool FromV8(v8::Isolate* isolate,
  25. v8::Local<v8::Value> val,
  26. blink::WebInputEvent::Type* out);
  27. static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
  28. const blink::WebInputEvent::Type& in);
  29. };
  30. template <>
  31. struct Converter<blink::WebInputEvent> {
  32. static bool FromV8(v8::Isolate* isolate,
  33. v8::Local<v8::Value> val,
  34. blink::WebInputEvent* out);
  35. static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
  36. const blink::WebInputEvent& in);
  37. };
  38. template <>
  39. struct Converter<blink::WebKeyboardEvent> {
  40. static bool FromV8(v8::Isolate* isolate,
  41. v8::Local<v8::Value> val,
  42. blink::WebKeyboardEvent* out);
  43. static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
  44. const blink::WebKeyboardEvent& in);
  45. };
  46. template <>
  47. struct Converter<blink::WebMouseEvent> {
  48. static bool FromV8(v8::Isolate* isolate,
  49. v8::Local<v8::Value> val,
  50. blink::WebMouseEvent* out);
  51. };
  52. template <>
  53. struct Converter<blink::WebMouseWheelEvent> {
  54. static bool FromV8(v8::Isolate* isolate,
  55. v8::Local<v8::Value> val,
  56. blink::WebMouseWheelEvent* out);
  57. };
  58. template <>
  59. struct Converter<blink::DeviceEmulationParams> {
  60. static bool FromV8(v8::Isolate* isolate,
  61. v8::Local<v8::Value> val,
  62. blink::DeviceEmulationParams* out);
  63. };
  64. template <>
  65. struct Converter<blink::mojom::ContextMenuDataMediaType> {
  66. static v8::Local<v8::Value> ToV8(
  67. v8::Isolate* isolate,
  68. const blink::mojom::ContextMenuDataMediaType& in);
  69. };
  70. template <>
  71. struct Converter<std::optional<blink::mojom::FormControlType>> {
  72. static v8::Local<v8::Value> ToV8(
  73. v8::Isolate* isolate,
  74. const std::optional<blink::mojom::FormControlType>& in);
  75. };
  76. template <>
  77. struct Converter<blink::WebCacheResourceTypeStat> {
  78. static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
  79. const blink::WebCacheResourceTypeStat& stat);
  80. };
  81. template <>
  82. struct Converter<blink::WebCacheResourceTypeStats> {
  83. static v8::Local<v8::Value> ToV8(
  84. v8::Isolate* isolate,
  85. const blink::WebCacheResourceTypeStats& stats);
  86. };
  87. template <>
  88. struct Converter<network::mojom::ReferrerPolicy> {
  89. static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
  90. const network::mojom::ReferrerPolicy& in);
  91. static bool FromV8(v8::Isolate* isolate,
  92. v8::Local<v8::Value> val,
  93. network::mojom::ReferrerPolicy* out);
  94. };
  95. template <>
  96. struct Converter<blink::mojom::Referrer> {
  97. static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
  98. const blink::mojom::Referrer& val);
  99. static bool FromV8(v8::Isolate* isolate,
  100. v8::Local<v8::Value> val,
  101. blink::mojom::Referrer* out);
  102. };
  103. template <>
  104. struct Converter<blink::CloneableMessage> {
  105. static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
  106. const blink::CloneableMessage& in);
  107. static bool FromV8(v8::Isolate* isolate,
  108. v8::Local<v8::Value> val,
  109. blink::CloneableMessage* out);
  110. };
  111. template <>
  112. struct Converter<blink::mojom::ConsoleMessageLevel> {
  113. static v8::Local<v8::Value> ToV8(v8::Isolate* isolate,
  114. const blink::mojom::ConsoleMessageLevel& in);
  115. };
  116. v8::Local<v8::Value> EditFlagsToV8(v8::Isolate* isolate, int editFlags);
  117. v8::Local<v8::Value> MediaFlagsToV8(v8::Isolate* isolate, int mediaFlags);
  118. } // namespace gin
  119. #endif // ELECTRON_SHELL_COMMON_GIN_CONVERTERS_BLINK_CONVERTER_H_